{"_id":"@cjser/sindresorhus__base62","name":"@cjser/sindresorhus__base62","dist-tags":{"latest":"1.0.0-cjser.2"},"versions":{"1.0.0-cjser.2":{"name":"@cjser/sindresorhus__base62","version":"1.0.0-cjser.2","description":"Encode & decode strings, bytes, and integers to Base62","license":"MIT","repository":{"type":"git","url":"https://code.moenext.com/3rdeye/cjser.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":{"types":"./index.d.ts","require":"./dist-cjser/index.cjs","default":"./index.js"},"sideEffects":false,"engines":{"node":">=18"},"scripts":{"test":"xo && ava"},"keywords":["base62","base","base64","base-62","encode","decode","shorten","compress","compact","alphanumeric","serialization","url","safe","text","string","number","integer","bigint","bytes","uint8array","algorithm","transformation","encoder","decoder","encoding","decoding","url-friendly","url-safe"],"devDependencies":{"ava":"^6.1.2","xo":"^0.58.0"},"types":"./index.d.ts","main":"./dist-cjser/index.cjs","cjser":{"sourceVersion":"1.0.0","cjserVersion":2,"original":{"name":"@sindresorhus/base62","version":"1.0.0","exports":{"types":"./index.d.ts","default":"./index.js"},"repository":"sindresorhus/base62","files":["index.js","index.d.ts","base.js","base.d.ts"],"scripts":{"test":"xo && ava"}}},"_id":"@cjser/sindresorhus__base62@1.0.0-cjser.2","gitHead":"0168e4aac54a1a9ca6f921419fa5ed9edb53ef4a","_nodeVersion":"20.14.0","_npmVersion":"10.7.0","dist":{"integrity":"sha512-wwplqg3k/fBCNoWi8BsmzYwWqYTOVVQzl+CdsUZzxMIjb7rHBi84Jh9fm7/gscZHO3UTNVX1uwIpQiSR1Cx4wA==","shasum":"8317afcd5c3399b8096b1a2deeadfefe646e2d8c","tarball":"https://registry.npmjs.org/@cjser/sindresorhus__base62/-/sindresorhus__base62-1.0.0-cjser.2.tgz","fileCount":8,"unpackedSize":22360,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIEQL4NpanVfuGxkE8AXMsVxyLgnBd8BMuikS2FOxlU1ZAiAh1AM+foxANamOoXD5248iZUbKpBDaqPZsQwTd12+/zg=="}]},"_npmUser":{"name":"nanahira","email":"nanahira@momobako.com"},"directories":{},"maintainers":[{"name":"nanahira","email":"nanahira@momobako.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/sindresorhus__base62_1.0.0-cjser.2_1778130975200_0.9893788447177794"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-07T05:16:15.078Z","1.0.0-cjser.2":"2026-05-07T05:16:15.399Z","modified":"2026-05-07T05:16:15.629Z"},"maintainers":[{"name":"nanahira","email":"nanahira@momobako.com"}],"description":"Encode & decode strings, bytes, and integers to Base62","keywords":["base62","base","base64","base-62","encode","decode","shorten","compress","compact","alphanumeric","serialization","url","safe","text","string","number","integer","bigint","bytes","uint8array","algorithm","transformation","encoder","decoder","encoding","decoding","url-friendly","url-safe"],"repository":{"type":"git","url":"https://code.moenext.com/3rdeye/cjser.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"license":"MIT","readme":"# base62\n\n> Encode & decode strings, bytes, and integers to [Base62](https://en.wikipedia.org/wiki/Base62)\n\nBase62 is ideal for URL shortening, creating readable codes, and compact data representation, because it compresses large values into shorter, alphanumeric strings, maximizing space efficiency and readability.\n\n## Install\n\n```sh\nnpm install @sindresorhus/base62\n```\n\n## Usage\n\n```js\nimport base62 from '@sindresorhus/base62';\n\nconst encodedString = base62.encodeString('Hello world!');\nconsole.log(encodedString);\n//=> '28B5ymDkgSU62aA0v'\n\nconsole.log(base62.decodeString(encodedString));\n//=> 'Hello world!'\n\nconsole.log(base62.encodeString('🦄'));\n//=> '95s3vg'\n\nconsole.log(base62.encodeInteger(1337));\n//=> 'LZ'\n```\n\n> [!NOTE]\n> The output may differ from other Base62 encoders due to variations in alphabet order and byte encoding.\n\n## API\n\nIt uses the most common alphabet for Base62: `0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`\n\n### `encodeString(string: string): string`\n\nEncodes a string to a Base62 string.\n\n> [!CAUTION]\n> The result format is not yet guaranteed to be stable across package versions. Avoid using it for persistent storage.\n\n### `decodeString(encodedString: string): string`\n\nDecodes a Base62 encoded string created with `encodeString()` back to the original string.\n\n### `encodeBytes(bytes: Uint8Array): string`\n\nEncodes bytes to a Base62 string.\n\n> [!CAUTION]\n> The result format is not yet guaranteed to be stable across package versions. Avoid using it for persistent storage.\n\n### `decodeBytes(encodedString: string): Uint8Array`\n\nDecodes a Base62 string created with `encodeBytes()` back to bytes.\n\n### `encodeInteger(integer: number): string`\n\nEncodes a non-negative integer to a Base62 string.\n\n### `decodeInteger(encodedString: string): number`\n\nDecodes a Base62 string to an integer.\n\n### `encodeBigInt(integer: bigint): string`\n\nEncodes a non-negative bigint to a Base62 string.\n\n### `decodeBigInt(encodedString: string): bigint`\n\nDecodes a Base62 string to a bigint.\n\n### Custom alphabets\n\nYou can use a custom alphabet by using the `Base62` class:\n\n```js\nimport {Base62} from '@sindresorhus/base62';\n\n// Create instance with custom alphabet\nconst customBase62 = new Base62({\n\talphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'\n});\n\nconsole.log(customBase62.encodeInteger(1337));\n//=> 'Vj' (different from default 'LZ')\n\n// Or use special characters\nconst symbolBase62 = new Base62({\n\talphabet: '!@#$%^&*()_+-=[]{}|;:,.<>?/~`0123456789ABCDEFGHIJKLMNOPQRSTUVW'\n});\nconsole.log(symbolBase62.encodeInteger(42));\n//=> 'D'\n```\n\n> [!NOTE]\n> The alphabet must be exactly 62 unique characters.\n\n### `Base62`\n\n#### `constructor(options?)`\n\nCreate a new Base62 encoder/decoder instance.\n\n##### options\n\nType: `object`\n\n###### alphabet\n\nType: `string`\\\nDefault: `'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'`\n\nCustom alphabet containing exactly 62 unique characters.\n\nThe `Base62` class has the same methods as the exported functions: `encodeString()`, `decodeString()`, `encodeBytes()`, `decodeBytes()`, `encodeInteger()`, `decodeInteger()`, `encodeBigInt()`, and `decodeBigInt()`.\n\n## cjser\n\nThis package is a CommonJS-compatible build generated by cjser for projects that still need `require()` support. The source version matches the original npm package version, with a cjser prerelease suffix for this generated build.\nOriginal repository: https://github.com/sindresorhus/base62\n","readmeFilename":"readme.md","_rev":"1-baba319dac1222081473cc814801b450"}