Decodes an encoded string of token IDs into an array of individual token IDs using bigint for precise calculations.
The encoded token IDs can be in the following formats:
The encoded string of token IDs to be decoded.
An array of individual token IDs after decoding the input.
If the input is not correctly formatted or if bigint operations fail.
const encoded = '1,3:5,8';const decoded = decodeTokenIds(encoded); // Output: ['1', '3', '4', '5', '8'] Copy
const encoded = '1,3:5,8';const decoded = decodeTokenIds(encoded); // Output: ['1', '3', '4', '5', '8']
const encodedWildcard = '*';const decodedWildcard = decodeTokenIds(encodedWildcard); // Output: ['*'] Copy
const encodedWildcard = '*';const decodedWildcard = decodeTokenIds(encodedWildcard); // Output: ['*']
const emptyEncoded = '';const decodedEmpty = decodeTokenIds(emptyEncoded); // Output: [] Copy
const emptyEncoded = '';const decodedEmpty = decodeTokenIds(emptyEncoded); // Output: []
Decodes an encoded string of token IDs into an array of individual token IDs using bigint for precise calculations.
The encoded token IDs can be in the following formats: