The `base62` package provides JavaScript utilities for encoding and decoding numbers into Base62 strings. These strings use a character set of 0-9, a-z, and A-Z, typically resulting in shorter, human-readable identifiers compared to other encoding schemes. The current stable version is 2.0.2, though its last publish date was over two years ago, suggesting a maintenance rather than rapid development cadence. A key differentiator of `base62` is its dual API approach: a legacy API (v1.x) available directly from the main package import and a modernized API (v2.x) that allows selective imports for specific character sets (ASCII or custom). The v2.x API is designed for efficiency by enabling modular loading, particularly useful for larger applications.
npm install base62Verified import paths — ran on the pinned version, not inferred.
Demonstrates encoding and decoding numbers using both the modern (v2.x) API with default ASCII and a custom character set, as well as the legacy (v1.x) API.
For new projects, prefer `require('base62/lib/ascii')` or `require('base62/lib/custom')`. If migrating, consider updating import paths to leverage the modular v2.x API for specific needs.Manually ensure your custom character set passed to `indexCharset` is 62 unique characters if standard Base62 behavior is desired. For example, `new Set(charset.split('')).size === 62`.If relying on character set validation, ensure you are either using the legacy `setCharacterSet` method (which modifies global state) or implement your own validation when using `indexCharset` from `base62/lib/custom`.
Always use `const base62 = require('base62');` or `const base62 = require('base62/lib/ascii');` for consistency and compatibility in Node.js environments. If you are in an ESM context and absolutely need to use this package, you might need to use dynamic `import()` or a CommonJS wrapper.Ensure you are using `require()` for imports, e.g., `const base62 = require('base62');` for the legacy API, or `const base62 = require('base62/lib/ascii');` for the modern API.Confirm your Node.js version and `moduleResolution` in `tsconfig.json` (if using TypeScript). If the package itself were to add `exports`, it would need to include entries for subpaths. For `base62`, ensure you are using `require()` for these subpath imports.
No dependency data recorded yet.