UNPKG

tsmaz

Version:

TypeScript port of the smaz string compression library

20 lines 622 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); function makeTrie(codebook) { const node = { chars: {}, code: undefined }; for (let i = 0; i < codebook.length; i += 1) { const tok = codebook[i]; let root = node; for (let j = 0; j < tok.length; j += 1) { const c = tok[j]; if (root.chars[c] === undefined) { root.chars[c] = { chars: {}, code: undefined }; } root = root.chars[c]; } root.code = i; } return node; } exports.default = makeTrie; //# sourceMappingURL=trie.js.map