{"library":"sbg-utility","title":"SBG Utility","description":"SBG Utility is a collection of helper functions and modules primarily designed to support the `static-blog-generator` ecosystem. It provides functionalities such as file management (reading, writing, checking file stats), date mapping, and logging utilities. The current stable version is `2.0.11`. As a sub-package within a larger monorepo, its release cadence is tied to the main project, though specific updates for `sbg-utility` are less frequent. Key differentiators include its tight integration with the `static-blog-generator`'s internal workings and its CommonJS base with TypeScript type definitions, making it usable in both legacy and modern Node.js environments.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install sbg-utility"],"cli":null},"imports":["import { debug } from 'sbg-utility';","import { read, write } from 'sbg-utility';","import type { ReadOptions } from 'sbg-utility';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { read, write, debug } from 'sbg-utility';\nimport { join } from 'path';\nimport { existsSync, mkdirSync } from 'fs';\n\nconst outputDir = join(__dirname, 'temp_output');\nif (!existsSync(outputDir)) {\n  mkdirSync(outputDir, { recursive: true });\n}\n\nconst filePath = join(__dirname, 'example.txt');\nconst outputPath = join(outputDir, 'output.txt');\n\nasync function runUtilityExample() {\n  debug('Starting SBG Utility example...');\n  try {\n    // Create a dummy file for reading\n    await write(filePath, 'Hello from sbg-utility!', 'utf8');\n    debug(`Written to ${filePath}`);\n\n    const content = await read(filePath, { encoding: 'utf8' });\n    debug(`Read content: ${content}`);\n\n    await write(outputPath, `Processed: ${content.toUpperCase()}`, 'utf8');\n    debug(`Transformed and written to ${outputPath}`);\n  } catch (error) {\n    console.error('An error occurred:', error);\n    debug('Example failed.', 'error');\n  }\n  debug('SBG Utility example finished.');\n}\n\nrunUtilityExample();","lang":"typescript","description":"Demonstrates reading from and writing to files using `sbg-utility`'s file manager functions, along with logging capabilities.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}