Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
TokenType.DEFAULT, TokenType.DO, TokenType.ELSE, TokenType.EXPORT,
TokenType.EXTENDS, TokenType.FINALLY, TokenType.FOR, TokenType.FUNCTION,
TokenType.IF, TokenType.IMPORT, TokenType.LET, TokenType.NEW,
TokenType.RETURN, TokenType.SUPER, TokenType.SWITCH, TokenType.THIS,
TokenType.THROW, TokenType.TRY, TokenType.VAR, TokenType.WHILE,
TokenType.WITH, TokenType.NULL, TokenType.TRUE, TokenType.FALSE,
TokenType.YIELD, TokenType.NUMBER, TokenType.STRING, TokenType.REGEXP,
TokenType.IDENTIFIER, TokenType.CONST, TokenType.TEMPLATE,
TokenType.ILLEGAL];
let ListHandler = transit.makeWriteHandler({
tag: () => "array",
rep: (v) => v
});
let MapHandler = transit.makeWriteHandler({
tag: function() { return "map"; },
rep: function(v) { return v; },
stringRep: function() { return null; }
});
let SyntaxHandler = transit.makeWriteHandler({
tag: () => "stx",
rep: (v) => {
if (List.isList(v.token)) {
return [v.token, v.scopesets];
} else {
let t = transit.objectToMap(v.token);
t.set("type", typeMap.indexOf(v.token.type));
return [t, v.scopesets];
}
}
TokenType.YIELD, TokenType.NUMBER, TokenType.STRING, TokenType.REGEXP,
TokenType.IDENTIFIER, TokenType.CONST, TokenType.TEMPLATE,
TokenType.ILLEGAL];
let ListHandler = transit.makeWriteHandler({
tag: () => "array",
rep: (v) => v
});
let MapHandler = transit.makeWriteHandler({
tag: function() { return "map"; },
rep: function(v) { return v; },
stringRep: function() { return null; }
});
let SyntaxHandler = transit.makeWriteHandler({
tag: () => "stx",
rep: (v) => {
if (List.isList(v.token)) {
return [v.token, v.scopesets];
} else {
let t = transit.objectToMap(v.token);
t.set("type", typeMap.indexOf(v.token.type));
return [t, v.scopesets];
}
}
});
let SymbolHandler = transit.makeWriteHandler({
tag: () => "symb",
rep: (v) => [v.name]
});
stringRep: function() { return null; }
});
let SyntaxHandler = transit.makeWriteHandler({
tag: () => "stx",
rep: (v) => {
if (List.isList(v.token)) {
return [v.token, v.scopesets];
} else {
let t = transit.objectToMap(v.token);
t.set("type", typeMap.indexOf(v.token.type));
return [t, v.scopesets];
}
}
});
let SymbolHandler = transit.makeWriteHandler({
tag: () => "symb",
rep: (v) => [v.name]
});
let writer = transit.writer("json", {
handlers: transit.map([
List, ListHandler,
Map, MapHandler,
Syntax, SyntaxHandler,
SymbolClass, SymbolHandler
])
});
function makeReader(bindings) {
return transit.reader("json", {
arrayBuilder: {
TokenType.EQ_STRICT, TokenType.NE_STRICT, TokenType.LT, TokenType.GT,
TokenType.LTE, TokenType.GTE, TokenType.INSTANCEOF, TokenType.IN,
TokenType.NOT, TokenType.BIT_NOT, TokenType.AWAIT, TokenType.DELETE,
TokenType.TYPEOF, TokenType.VOID, TokenType.BREAK, TokenType.CASE,
TokenType.CATCH, TokenType.CLASS, TokenType.CONTINUE, TokenType.DEBUGGER,
TokenType.DEFAULT, TokenType.DO, TokenType.ELSE, TokenType.EXPORT,
TokenType.EXTENDS, TokenType.FINALLY, TokenType.FOR, TokenType.FUNCTION,
TokenType.IF, TokenType.IMPORT, TokenType.LET, TokenType.NEW,
TokenType.RETURN, TokenType.SUPER, TokenType.SWITCH, TokenType.THIS,
TokenType.THROW, TokenType.TRY, TokenType.VAR, TokenType.WHILE,
TokenType.WITH, TokenType.NULL, TokenType.TRUE, TokenType.FALSE,
TokenType.YIELD, TokenType.NUMBER, TokenType.STRING, TokenType.REGEXP,
TokenType.IDENTIFIER, TokenType.CONST, TokenType.TEMPLATE,
TokenType.ILLEGAL];
let ListHandler = transit.makeWriteHandler({
tag: () => "array",
rep: (v) => v
});
let MapHandler = transit.makeWriteHandler({
tag: function() { return "map"; },
rep: function(v) { return v; },
stringRep: function() { return null; }
});
let SyntaxHandler = transit.makeWriteHandler({
tag: () => "stx",
rep: (v) => {
if (List.isList(v.token)) {
return [v.token, v.scopesets];
} else {