Skip to content

Instantly share code, notes, and snippets.

View KFlash's full-sized avatar
🙂
Retired!

Kenny F. KFlash

🙂
Retired!
  • Stuck somewhere in Asia (temporary)
View GitHub Profile
export function parseSource(source: string, options: Options | void, context: Context): ESTree.Program {
if (options != null) {
if (options.module) context |= Context.Module | Context.Strict;
if (options.next) context |= Context.OptionsNext;
if (options.loc) context |= Context.OptionsLoc;
if (options.disableWebCompat) context |= Context.OptionsDisableWebCompat;
if (options.directives) context |= Context.OptionsDirectives | Context.OptionsRaw;
if (options.raw) context |= Context.OptionsRaw;
if (options.impliedStrict) context |= Context.Strict;
}
// Bad practice
1) function x() { while (i < length) { let x = i; ... } }
2) while (i < length) { x.y.z[i] = 'hello'; }
// God practice
(a, [b], {c})
--------------
{
"type": "Script",
"directives": [],
"items": [
{
"type": "ExpressionStatement",
let a = b;
==========
{
"type": "Script",
"directives": [],
"items": [
{
"type": "LexicalDeclaration",
"kind": "let",