{"id":16305712,"url":"https://github.com/cafe01/javascript-v8-commonjs","last_synced_at":"2025-10-16T03:01:46.414Z","repository":{"id":56830237,"uuid":"132292096","full_name":"cafe01/javascript-v8-commonjs","owner":"cafe01","description":"CommonJS environment for JavaScript::V8 (Perl)","archived":false,"fork":false,"pushed_at":"2018-06-14T20:15:32.000Z","size":60,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-11T18:06:37.758Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cafe01.png","metadata":{"files":{"readme":"README.md","changelog":"Changes","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-05-05T23:30:28.000Z","updated_at":"2018-06-14T20:15:28.000Z","dependencies_parsed_at":"2022-09-02T03:51:40.206Z","dependency_job_id":null,"html_url":"https://github.com/cafe01/javascript-v8-commonjs","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cafe01%2Fjavascript-v8-commonjs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cafe01%2Fjavascript-v8-commonjs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cafe01%2Fjavascript-v8-commonjs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cafe01%2Fjavascript-v8-commonjs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cafe01","download_url":"https://codeload.github.com/cafe01/javascript-v8-commonjs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248456370,"owners_count":21106603,"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":[],"created_at":"2024-10-10T21:08:10.949Z","updated_at":"2025-10-16T03:01:41.371Z","avatar_url":"https://github.com/cafe01.png","language":"Perl","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/cafe01/javascript-v8-commonjs.svg?branch=master)](https://travis-ci.org/cafe01/javascript-v8-commonjs) [![Coverage Status](https://img.shields.io/coveralls/cafe01/javascript-v8-commonjs/master.svg?style=flat)](https://coveralls.io/r/cafe01/javascript-v8-commonjs?branch=master)\n# NAME\n\nJavaScript::V8::CommonJS - Modules/1.0 for JavaScript::V8\n\n# SYNOPSIS\n\n    use JavaScript::V8::CommonJS;\n\n    my $js = JavaScript::V8::CommonJS-\u003enew(paths =\u003e [\"./modules\"]);\n\n    print $js-\u003eeval('require(\"foo\").add(4, 2)');  # prints 6\n\n    # modules/foo.js\n    # exports.add = function(a, b) { return a + b }\n\n# DESCRIPTION\n\nCommonJS implementation for JavaScript::V8. Currently only Module/1.0 spec is implemented. (Passing all unit tests at [https://github.com/commonjs/commonjs/tree/master/tests/modules/1.0](https://github.com/commonjs/commonjs/tree/master/tests/modules/1.0))\n\n# CONSTRUCTOR\n\n## new\n\nAll arguments are optional.\n\n- paths\n\n    Arrayref of paths to search for modules. Default: \\[getcwd()\\].\n\n- modules\n\n    Hashref of native modules. Default: {}.\n\n- v8\\_params\n\n    Hashref passed directly to [\"new\" in JavaScript::V8::Context](https://metacpan.org/pod/JavaScript::V8::Context#new). Default: undef.\n\n# METHODS\n\n## add\\_module(name =\u003e module)\n\nRegister native modules. Attempting to register a module twice is a fatal error.\n\n    $js-\u003eadd_module( http =\u003e {\n        get =\u003e sub { ... },\n        post =\u003e sub { ... },\n        ...\n    });\n\n## eval(js\\_code, source)\n\nEvaluates javascript source code on the global context. JS exceptions are rethrown as [JavaScript::V8::CommonJS::Exception](https://metacpan.org/pod/JavaScript::V8::CommonJS::Exception) instances.\n\n    $js-\u003eeval('require(\"program\").doSomething()', \"main\")\n\nThe second argument is a source or filename to be reported on error messages.\n\n## eval\\_file(path)\n\n    $js-\u003eeval_file(\"main.js\")\n\n## c\n\nReturns the JavaScript::V8::Context instance.\n\n    # run v8 garbage collector\n    $js-\u003ec-\u003eidle_notification\n\n# LICENSE\n\nCopyright (C) Carlos Fernando Avila Gratz.\n\nThis library is free software; you can redistribute it and/or modify\nit under the same terms as Perl itself.\n\n# AUTHOR\n\nCarlos Fernando Avila Gratz \u003ccafe@kreato.com.br\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcafe01%2Fjavascript-v8-commonjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcafe01%2Fjavascript-v8-commonjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcafe01%2Fjavascript-v8-commonjs/lists"}