Registry / sbg-utility

sbg-utility

JSON →
library2.0.11jsnpmunverified

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.

npm install sbg-utility
INSTALL
IMPORT
SIG · SBG-UTILITY
S
sbg-utility
javascriptv2.0.11
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

debug
import { debug } from 'sbg-utility';
const debug = require('sbg-utility').log.debug;
Many utility functions like logging are re-exported directly from the root module for convenience, despite their internal file structure. The package is fundamentally CommonJS but provides TypeScript types, allowing for modern ESM import syntax.
read, write
import { read, write } from 'sbg-utility';
const { read, write } = require('sbg-utility').filemanager;
File management functions `read` and `write` are directly available as named exports from the top-level package, simplifying their usage compared to accessing them via nested module properties.
ReadOptions (Type)
import type { ReadOptions } from 'sbg-utility';
import { ReadOptions } from 'sbg-utility';
The package ships with TypeScript definitions. Always use `import type` for importing types to ensure they are stripped from the JavaScript output, preventing potential runtime errors or unnecessary bundle size.

Demonstrates reading from and writing to files using `sbg-utility`'s file manager functions, along with logging capabilities.

import { read, write, debug } from 'sbg-utility'; import { join } from 'path'; import { existsSync, mkdirSync } from 'fs'; const outputDir = join(__dirname, 'temp_output'); if (!existsSync(outputDir)) { mkdirSync(outputDir, { recursive: true }); } const filePath = join(__dirname, 'example.txt'); const outputPath = join(outputDir, 'output.txt'); async function runUtilityExample() { debug('Starting SBG Utility example...'); try { // Create a dummy file for reading await write(filePath, 'Hello from sbg-utility!', 'utf8'); debug(`Written to ${filePath}`); const content = await read(filePath, { encoding: 'utf8' }); debug(`Read content: ${content}`); await write(outputPath, `Processed: ${content.toUpperCase()}`, 'utf8'); debug(`Transformed and written to ${outputPath}`); } catch (error) { console.error('An error occurred:', error); debug('Example failed.', 'error'); } debug('SBG Utility example finished.'); } runUtilityExample();
Debug
Known issues
gotchaWhile the package provides TypeScript types and supports ESM `import` syntax, it is fundamentally a CommonJS module. In environments where strict ESM loading is enforced (e.g., Node.js with `type: module` and no bundler), you might encounter issues. Prefer standard `require()` in pure CJS contexts or ensure your build system handles CJS interop for ESM imports.
fix
For CommonJS environments, explicitly use `const { func } = require('sbg-utility');`. For modern TypeScript/ESM projects, ensure your `tsconfig.json` and build tools (like Webpack, Rollup, esbuild) are configured to correctly handle CommonJS dependencies.
affects: >=2.0.0
gotchaThis `sbg-utility` package is part of a larger `static-blog-generator` monorepo. While usable standalone, its API and design choices are often influenced by its parent project's needs. Expect some functionalities to be tailored specifically for the static blog generator workflow.
fix
Review the GitHub repository and source code for the `static-blog-generator` project to understand the full context and intended usage of these utilities, especially for advanced or less documented features.
affects: >=2.0.0
Errors
Common errors & fixes
TypeError: (0, _sbg_utility.someFunction) is not a function
Attempting to use a named export as a default import or incorrect destructuring in a CommonJS context.
fix
Ensure you are using correct named imports for ESM (`import { someFunction } from 'sbg-utility';`) or proper destructuring for CommonJS (`const { someFunction } = require('sbg-utility');`). This package does not have a default export.
ERR_REQUIRE_ESM: Must use import to load ES Module: ...
This error is unlikely for `sbg-utility` itself (as it's CJS), but if you're trying to `require()` an ES module that *depends* on `sbg-utility` in a mixed environment, or incorrectly configure your build, it might surface.
fix
Ensure that the module causing the error is loaded via `import` if it's an ES module. For `sbg-utility`, stick to `import` in TypeScript/ESM contexts or `require` in CJS contexts, respecting its underlying module type.
Upgrade
Version history
2.0.11latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
10 hits · last 30 days
node
8
Amazon
1
OpenAI (training)
1
Resources
sbg-utility — npm install sbg-utility · libregistry