MCPcopy Create free account
hub / github.com/dchester/jsonpath / isKeyword

Function isKeyword

jsonpath.js:306–340  ·  view source on GitHub ↗
(id)

Source from the content-addressed store, hash-verified

304 // 7.6.1.1 Keywords
305
306 function isKeyword(id) {
307 if (strict && isStrictModeReservedWord(id)) {
308 return true;
309 }
310
311 // 'const' is specialized as Keyword in V8.
312 // 'yield' and 'let' are for compatiblity with SpiderMonkey and ES.next.
313 // Some others are from future reserved words.
314
315 switch (id.length) {
316 case 2:
317 return (id === 'if') || (id === 'in') || (id === 'do');
318 case 3:
319 return (id === 'var') || (id === 'for') || (id === 'new') ||
320 (id === 'try') || (id === 'let');
321 case 4:
322 return (id === 'this') || (id === 'else') || (id === 'case') ||
323 (id === 'void') || (id === 'with') || (id === 'enum');
324 case 5:
325 return (id === 'while') || (id === 'break') || (id === 'catch') ||
326 (id === 'throw') || (id === 'const') || (id === 'yield') ||
327 (id === 'class') || (id === 'super');
328 case 6:
329 return (id === 'return') || (id === 'typeof') || (id === 'delete') ||
330 (id === 'switch') || (id === 'export') || (id === 'import');
331 case 7:
332 return (id === 'default') || (id === 'finally') || (id === 'extends');
333 case 8:
334 return (id === 'function') || (id === 'continue') || (id === 'debugger');
335 case 10:
336 return (id === 'instanceof');
337 default:
338 return false;
339 }
340 }
341
342 // 7.4 Comments
343

Callers 1

scanIdentifierFunction · 0.85

Calls 1

isStrictModeReservedWordFunction · 0.85

Tested by

no test coverage detected