The `b36` package provides a minimalist utility for converting between Node.js `Buffer` objects and Base36 encoded strings. Currently at version 1.0.0, this library offers a slightly more compact encoding scheme compared to hexadecimal, making it suitable for contexts where shorter, alphanumeric identifiers are beneficial, such as unique IDs in URLs or hostnames. Its release cadence is likely stable and infrequent, as it addresses a specific, well-defined encoding problem with a mature solution. Key differentiators include its simplicity, small footprint, and direct focus on Base36, providing a straightforward alternative to more complex encoding libraries when only Base36 is required, especially beneficial in Node.js environments.
npm install b36Verified import paths — ran on the pinned version, not inferred.
This example demonstrates how to encode a random Node.js `Buffer` into a Base36 string and then decode it back, verifying the integrity of the transformation.
Ensure that all inputs to the `encode` function are Node.js `Buffer` instances. Convert other data types to a Buffer first (e.g., `Buffer.from('my string')`).Validate input strings before passing them to `decode`. If the application requires robustness against malformed inputs, consider wrapping `decode` in a `try-catch` block.
For projects requiring ESM, try `import { encode, decode } from 'b36';`. If issues arise, consider configuring a build tool like Webpack or Rollup to handle CommonJS modules, or stick to `require()` in a CJS context.Use correct named destructuring for CommonJS: `const { encode } = require('b36');`Convert the input to a Node.js Buffer before encoding, e.g., `encode(Buffer.from('my data'))`.Ensure the input string for `decode` is a valid Base36 string. Only characters '0'-'9' and 'a'-'z' (case-insensitive depending on implementation, but typically lowercase) are allowed.
No dependency data recorded yet.