word-math
Version:
Extended version to compatible with OMML of Word Processing Document library
76 lines • 2.65 kB
JavaScript
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var TrieNode = /** @class */ (function () {
function TrieNode(value, filename) {
this.filename = filename;
this.value = value;
}
return TrieNode;
}());
function testfunction() {
var a = new TrieNode();
a.value = 0x50dcef;
a.filename = 'doc';
var b = new TrieNode();
b.value = 0xdc;
a.filename = 'docx';
var c = new TrieNode(0xef, 'doas');
a.children = { 'b': b };
// console.log(a);
a.children = __assign(__assign({}, a.children), { 'c': c });
// console.log(a)
a.children = __assign(__assign({}, a.children), { 'c': c });
console.log(a);
b.children = { 'd': c };
console.log(a.children['b'].children['d']);
console.log(a);
console.log(a.children['t']);
}
var numberFromHex = function (number, index) { return parseInt(number.toString(16).slice(index, index + 2), 16); };
var test = 0x50dcef;
var index = 2;
// console.log(numberFromHex(test, index));
var Trie = /** @class */ (function () {
function Trie() {
this.root = new TrieNode();
}
Trie.prototype.insert = function (fileName, signature, index, node) {
if (index === signature.toString(16).length / 2 - 1) {
node.filename = fileName;
node.value = signature;
return (node);
}
else {
if (!node.children[numberFromHex(signature, index)]) {
node.children = __assign({}, node.children);
}
}
// if (index === string.length - 1) {
// return (node[string[index]] = { value: string })
// } else {
// if (!node[string[index]]) {
// node[string[index]] = { value: string.slice(0, index + 1) }
// }
// node[string[index]][string[index + 1]] = {
// ...node[string[index]][string[index + 1]],
// ...this._traverseInsert(node[string[index]], string, index + 1)
// }
// }
// return node[string[index]];
};
return Trie;
}());
var testTrie = new Trie();
testTrie.insert('xls', 0x50, 0, testTrie.root);
console.log(testTrie);
// testfunction();
//# sourceMappingURL=triebyte.js.map