Repository navigation
Invalid input now throws instead of returning a wrong value. encode throws TypeError for anything that isn't a number or bigint, including numeric strings, and RangeError for negatives, fractions, NaN, Infinity and numbers above Number.MAX_SAFE_INTEGER. decode throws on empty strings, characters outside the character set, and results above Number.MAX_SAFE_INTEGER unless { bigint: true } is passed. In 2.x, decode("g7 ") returned 61922, decode("!g7") returned -56661 and encode(1.5) returned "undefined". Leading zeros are still accepted, and output for valid input in the safe range is unchanged from 1.x and 2.x.
BigInt is supported: encode accepts a bigint, and decode(str, { bigint: true }) returns one.
base62.create(charset) returns an encode/decode pair for any character set of at least 2 unique characters without changing the shared module, so a dependency calling setCharacterSet no longer changes encoding for everyone else in the process. Character sets with emoji or other characters outside the Basic Multilingual Plane now work.
Node 18 or later is required. TypeScript declarations are now referenced from package.json.