{"id":17184211,"url":"https://github.com/xgheaven/jsscript","last_synced_at":"2025-04-13T18:02:13.795Z","repository":{"id":208861939,"uuid":"715190901","full_name":"XGHeaven/jsscript","owner":"XGHeaven","description":"A flexible ESNext modern JavaScript engine running on another JavaScript engine.","archived":false,"fork":false,"pushed_at":"2024-06-17T14:57:39.000Z","size":444,"stargazers_count":40,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-22T00:31:45.518Z","etag":null,"topics":["javascript-vm","quickjs","v8"],"latest_commit_sha":null,"homepage":"https://jsscript.github-docs.xgheaven.com/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/XGHeaven.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"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}},"created_at":"2023-11-06T16:42:57.000Z","updated_at":"2025-02-08T06:00:57.000Z","dependencies_parsed_at":"2023-12-16T13:44:51.995Z","dependency_job_id":"1f232327-5170-4237-b31b-c6cd53c80c5e","html_url":"https://github.com/XGHeaven/jsscript","commit_stats":null,"previous_names":["xgheaven/jsscript"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XGHeaven%2Fjsscript","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XGHeaven%2Fjsscript/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XGHeaven%2Fjsscript/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XGHeaven%2Fjsscript/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/XGHeaven","download_url":"https://codeload.github.com/XGHeaven/jsscript/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240384370,"owners_count":19792970,"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":["javascript-vm","quickjs","v8"],"created_at":"2024-10-15T00:42:43.427Z","updated_at":"2025-02-23T21:31:35.834Z","avatar_url":"https://github.com/XGHeaven.png","language":"JavaScript","readme":"# jsscript\n\n![All](https://img.shields.io/endpoint?url=https%3A%2F%2Fgist.githubusercontent.com%2FXGHeaven%2Feb8c89fdddb8545a94c59c88b687fad5%2Fraw%2Fmain-all.json)\n![Strict mode](https://img.shields.io/endpoint?url=https%3A%2F%2Fgist.githubusercontent.com%2FXGHeaven%2Feb8c89fdddb8545a94c59c88b687fad5%2Fraw%2Fmain-strict%2520mode.json)\n\nA JavaScript Runtime implement in JavaScript.\n\nInspired by [QuickJS](https://github.com/bellard/quickjs).\n\n## Goal\n\n- Provide a easy way to learning JavaScript engine. No needs to learn C.\n- Only support `strict mode` and modern JavaScript feature.\n  - Such as `let`, `const`, `async`, `await`, `arrow function`, `class`, etc.\n  - Not implement `with`, `eval`, `var`, `label` etc.\n- Please do not using this project for your production without any tested.\n- Flexable, you can only use the part of JavaScript.\n- Some prototype function of Builtin Object depends on the host environmnet.\n  - For example, if you want to use `Array.prototype.at` in vm, you need make sure it can been used in host vm. Or you need to load ployfill.\n\n## How to use\n\n### CLI\n\n```bash\n# instal as global\nnpm install @xgheaven/jsscript -g\n```\n\nIt's like `Node.js` cli without special module.\n\n```bash\njsscript run your-file.js\n```\n\n### API\n\n```bash\n# install\nnpm install @xgheaven/jsscript\n```\n\n```typescript\nimport { Runtime, Features, parseScript, parseBytecode, toHostValue } from 'jsscript'\n\nconst runtime = new Runtime({\n  features: [\n    // inject builtin features\n    new Features.ECMA262Feature(), // inject All ECMA262 Spec object, like `Promise`/`RegExp`/...\n    // you can write your self feature\n  ],\n})\nconst context = runtime.newContext()\n\nconst script = `\u003cyour-script\u003e`;\n\n// parse it to function object\nconst fn = parseScript(context, script)\n// or compile it bytecode then parse it\nconst bc = compileToBytecode(script)\nconst fn = parseBytecode(context, bc)\n\n// run it\nconst ret = context.run(fn)\n\n// convert js value of vm to host vm\nconsole.log(toHostValue(ret))\n```\n\n#### Error Handle\n\nTODO\n\n#### Define Feature\n\nTODO\n\n# Benchmark(TODO)\n\n\u003e The performance is not the core of jsscript. But It's still important for using.\n\u003e Using [v8-7 version](https://github.com/mozilla/arewefastyet/tree/master/benchmarks/v8-v7) benchmark test. (It's so old, only support es5. I will find more newer test cases in the future to replace it)\n\n| | jsscript | [sablejs](https://github.com/sablejs/sablejs) | [eval5](https://github.com/bplok20010/eval5) |\n| --- | --- | --- | --- |\n| *Language* | TypeScript | JavaScript | TypeScript |\n| *Support Version* | ES6(target) | ES5 | ES5 |\n| *Version* | see `package.json` | `1.1.0` | `1.4.7` |\n| `crypto` Score | - | - | - |\n| `deltablue` Score | - | - | - |\n| `earley-boyer` Score | - | - | - |\n| `navier-stokes` Score | - | - | - |\n| `raytrace` Score | - | - | - |\n| `regexp` Score | - | - | - |\n| `richards` Score | - | - | - |\n| `splay` Score | - | - | - |\n| **Total Score** | - | - | - |\n\n## More\n\nI want to use `jsscript` as package name.\nBut it too similar to the package `js-script` which published 10+ years ago.\nI have to add the personal scope in the package name.\n\n## Same package\n\n- [engine262](https://github.com/engine262/engine262)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxgheaven%2Fjsscript","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxgheaven%2Fjsscript","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxgheaven%2Fjsscript/lists"}