Registry / bare-utils

bare-utils

JSON →
library1.6.0jsnpmunverified

`bare-utils` is a JavaScript utility library designed to provide Node.js-compatible functions primarily for the Bare runtime, a specialized environment often used within the Holepunch and Hypercore ecosystems. It offers a subset of commonly used functionalities akin to Node.js's built-in `util` module, ensuring that developers can leverage familiar utility patterns when building applications for Bare. The library's current stable version is 1.6.0. Its release cadence is typically aligned with the development cycle of the Bare runtime itself, focusing on maintaining API parity and addressing specific needs of the ecosystem. A key differentiator is its explicit compatibility and optimization for the Bare environment, making it a targeted tool rather than a general-purpose utility library for standard Node.js projects.

npm install bare-utils
INSTALL
IMPORT
SIG · BARE-UTILS
B
bare-utils
javascriptv1.6.0
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.

util
const util = require('bare-utils')
Primary CommonJS import pattern. The module exports an object containing utility functions.
util
import util from 'bare-utils'
import { format } from 'bare-utils'
For ESM environments, this interop import is typically used to access the default CommonJS export. Direct named imports like `import { format } = 'bare-utils'` will fail as the package is CJS-only.

Demonstrates how to import and use the `format` utility function with various specifiers.

const util = require('bare-utils'); console.log('Using bare-utils.format to construct strings:'); const name = 'Alice'; const age = 30; const greeting = util.format('Hello, my name is %s and I am %d years old.', name, age); console.log(`Example 1: ${greeting}`); const data = { id: 101, status: 'active' }; const dataString = util.format('User data: %j', data); console.log(`Example 2: ${dataString}`); const pi = 3.14159; const percentage = util.format('Pi to two decimal places: %.2f', pi); console.log(`Example 3: ${percentage}`); console.log('\nThis quickstart demonstrates various uses of the `format` function, which behaves similarly to Node.js's `util.format`.');
Debug
Known issues
gotchaThis package is primarily a CommonJS module. When used in an ES Module (ESM) environment, developers must use `import util from 'bare-utils'` for CJS interop. Direct named imports such as `import { format } from 'bare-utils'` will not work.
fix
For ESM, use `import util from 'bare-utils'` and then access functions like `util.format()`.
affects: >=1.0.0
gotchaThe API provided by `bare-utils` is a subset of Node.js's native `util` module. While it aims for compatibility, some functions or specific behaviors present in the full Node.js `util` module might be missing or subtly different. Always verify functionality if migrating from a standard Node.js environment.
fix
Consult the `bare-utils` source or documentation for exact API coverage. For critical functions, consider implementing polyfills or alternative solutions if `bare-utils` does not provide the exact behavior required.
affects: >=1.0.0
Errors
Common errors & fixes
ReferenceError: require is not defined in ES module scope
Attempting to use `require()` in an ECMAScript module (ESM) file.
fix
If in an ESM file, change `const util = require('bare-utils')` to `import util from 'bare-utils'`. Ensure your `package.json` has `"type": "module"` for ESM files or use the `.mjs` extension.
TypeError: __WEBPACK_IMPORTED_MODULE_0__.format is not a function
A bundler (like Webpack) or an ESM environment is attempting to destructure a named export (`format`) from a CommonJS module that exports a default object.
fix
Adjust the import statement in your ESM or bundled code to `import util from 'bare-utils'`, then access the function as `util.format(...)`.
Upgrade
Version history
1.6.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
8 hits · last 30 days
node
6
Resources
bare-utils — npm install bare-utils · libregistry