{"id":13666968,"url":"https://github.com/engine262/engine262","last_synced_at":"2025-04-26T15:31:56.258Z","repository":{"id":38848431,"uuid":"143188703","full_name":"engine262/engine262","owner":"engine262","description":"An implementation of ECMA-262 in JavaScript","archived":false,"fork":false,"pushed_at":"2025-04-25T11:29:44.000Z","size":106586,"stargazers_count":864,"open_issues_count":26,"forks_count":66,"subscribers_count":21,"default_branch":"main","last_synced_at":"2025-04-25T12:32:15.406Z","etag":null,"topics":["ecma262","engine262","interpreter","javascript","reference-implementation"],"latest_commit_sha":null,"homepage":"https://engine262.js.org","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/engine262.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":["engine262","devsnek"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2018-08-01T17:39:53.000Z","updated_at":"2025-04-25T11:07:24.000Z","dependencies_parsed_at":"2024-01-16T17:02:13.319Z","dependency_job_id":"ffbd3638-e955-4cfc-93e5-a7e765215441","html_url":"https://github.com/engine262/engine262","commit_stats":{"total_commits":1103,"total_committers":22,"mean_commits":50.13636363636363,"dds":0.4043517679057117,"last_synced_commit":"dd05c163162914b12baca4fbabb6e9ce99a217bc"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/engine262%2Fengine262","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/engine262%2Fengine262/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/engine262%2Fengine262/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/engine262%2Fengine262/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/engine262","download_url":"https://codeload.github.com/engine262/engine262/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250821568,"owners_count":21492892,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ecma262","engine262","interpreter","javascript","reference-implementation"],"created_at":"2024-08-02T07:00:20.472Z","updated_at":"2025-04-26T15:31:56.251Z","avatar_url":"https://github.com/engine262.png","language":"TypeScript","readme":"# engine262\n\nAn implementation of ECMA-262 in JavaScript\n\nGoals\n\n- 100% Spec Compliance\n- Introspection\n- Ease of modification\n\nNon-Goals\n\n- Speed at the expense of any of the goals\n\nThis project is bound by a [Code of Conduct][COC].\n\nJoin us in `#engine262:matrix.org`.\n\n## Why this exists\n\nWhile helping develop new features for JavaScript, I've found that one of the\nmost useful methods of finding what works and what doesn't is being able to\nactually run code using the new feature. [Babel][] is fantastic for this, but\nsometimes features just can't be nicely represented with it. Similarly,\nimplementing a feature in one of the engines is a large undertaking, involving\nlong compile times and annoying bugs with the optimizing compilers.\n\nengine262 is a tool to allow JavaScript developers to have a sandbox where new\nfeatures can be quickly prototyped and explored. As an example, adding\n[do expressions][] to this engine is as simple as the following diff:\n\n```diff\n--- a/src/evaluator.mts\n+++ b/src/evaluator.mts\n@@ -232,6 +232,8 @@ export function* Evaluate(node) {\n     case 'GeneratorBody':\n     case 'AsyncGeneratorBody':\n       return yield* Evaluate_AnyFunctionBody(node);\n+    case 'DoExpression':\n+      return yield* Evaluate_Block(node.Block);\n     default:\n       throw new OutOfRange('Evaluate', node);\n   }\n--- a/src/parser/ExpressionParser.mts\n+++ b/src/parser/ExpressionParser.mts\n@@ -579,6 +579,12 @@ export class ExpressionParser extends FunctionParser {\n         return this.parseRegularExpressionLiteral();\n       case Token.LPAREN:\n         return this.parseParenthesizedExpression();\n+      case Token.DO: {\n+        const node = this.startNode\u003cParseNode.DoExpression\u003e();\n+        this.next();\n+        node.Block = this.parseBlock();\n+        return this.finishNode(node, 'DoExpression');\n+      }\n       default:\n         return this.unexpected();\n     }\n```\n\nThis simplicity applies to many other proposals, such as [optional chaining][],\n[pattern matching][], [the pipeline operator][], and more. This engine has also\nbeen used to find bugs in ECMA-262 and [test262][], the test suite for\nconforming JavaScript implementations.\n\n## Requirements\n\nTo run engine262 itself, a engine with support for recent ECMAScript features\nis needed. Additionally, the CLI (`bin/engine262.js`) and test262 runner\n(`test/test262/test262.js`) require a recent version of Node.js.\n\n## Using engine262\n\nUse it online: \u003chttps://engine262.js.org\u003e\n\nYou can install the latest engine262 build from [GitHub Packages][].\n\nIf you install it globally, you can use the CLI like so:\n\n`$ engine262`\n\nOr, you can install it locally and use the API:\n\n```js\nimport { Agent, setSurroundingAgent, ManagedRealm, Value, CreateDataProperty, inspect, CreateBuiltinFunction, skipDebugger } from '@engine262/engine262';\n\nconst agent = new Agent({\n  // onDebugger() {},\n  // ensureCanCompileStrings() {},\n  // hasSourceTextAvailable() {},\n  // loadImportedModule() {},\n  // onNodeEvaluation() {},\n  // features: [],\n});\nsetSurroundingAgent(agent);\n\nconst realm = new ManagedRealm({\n  // promiseRejectionTracker() {},\n  // getImportMetaProperties() {},\n  // finalizeImportMeta() {},\n  // randomSeed() {},\n});\n\nrealm.scope(() =\u003e {\n  // Add print function from host\n  const print = CreateBuiltinFunction((args) =\u003e {\n    console.log(...args.map((tmp) =\u003e inspect(tmp)));\n    return Value.undefined;\n  }, 1, Value('print'), []);\n  skipDebugger(CreateDataProperty(realm.GlobalObject, Value('print'), print));\n});\n\nrealm.evaluateScript(`\n'use strict';\n\nasync function* numbers() {\n  let i = 0;\n  while (true) {\n    const n = await Promise.resolve(i++);\n    yield n;\n  }\n}\n\n(async () =\u003e {\n  for await (const item of numbers()) {\n    print(item);\n  }\n})();\n`);\n\n// a stream of numbers fills your console. it fills you with determination.\n```\n\n## Testing engine262\n\nThis project can be run against [test262][], which is particularly useful\nfor developing new features and/or tests:\n\n```sh\n$ # build engine262\n$ npm run build\n\n$ # update local test262 in test/test262/test262\n$ git submodule update --init --recursive\n\n$ # update local test262 to a pull request\n$ pushd test/test262/test262\n$ git fetch origin refs/pull/$PR_NUMBER/head \u0026\u0026 git checkout FETCH_HEAD\n$ popd\n\n$ # run specific tests\n$ npm run test:test262 built-ins/AsyncGenerator*\n\n$ # run all tests\n$ npm run test:test262\n```\n\nThe output will indicate counts for total tests, passing tests, failing tests, and skipped tests.\n\n## Related Projects\n\nMany people and organizations have attempted to write a JavaScript interpreter\nin JavaScript much like engine262, with different goals. Some of them are\nincluded here for reference, though engine262 is not based on any of them.\n\n- \u003chttps://github.com/facebook/prepack\u003e\n- \u003chttps://github.com/mozilla/narcissus\u003e\n- \u003chttps://github.com/NeilFraser/JS-Interpreter\u003e\n- \u003chttps://github.com/metaes/metaes\u003e\n- \u003chttps://github.com/Siubaak/sval\u003e\n\n[Babel]: https://babeljs.io/\n[COC]: https://github.com/engine262/engine262/blob/master/CODE_OF_CONDUCT.md\n[do expressions]: https://github.com/tc39/proposal-do-expressions\n[optional chaining]: https://github.com/tc39/proposal-optional-chaining\n[pattern matching]: https://github.com/tc39/proposal-pattern-matching\n[test262]: https://github.com/tc39/test262\n[the pipeline operator]: https://github.com/tc39/proposal-pipeline-operator\n[GitHub Packages]: https://github.com/engine262/engine262/packages\n","funding_links":["https://github.com/sponsors/engine262","https://github.com/sponsors/devsnek"],"categories":["JavaScript","javascript interpreters","TypeScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fengine262%2Fengine262","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fengine262%2Fengine262","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fengine262%2Fengine262/lists"}