{"id":18867740,"url":"https://github.com/kuoruan/v8go-polyfills","last_synced_at":"2025-04-14T14:31:36.778Z","repository":{"id":42509333,"uuid":"344755565","full_name":"kuoruan/v8go-polyfills","owner":"kuoruan","description":"Add polyfills to rogchap/v8go","archived":false,"fork":false,"pushed_at":"2023-11-22T20:53:03.000Z","size":174,"stargazers_count":64,"open_issues_count":6,"forks_count":17,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T03:41:24.997Z","etag":null,"topics":["javascript","polyfill","v8","v8go"],"latest_commit_sha":null,"homepage":"","language":"Go","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/kuoruan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2021-03-05T09:13:40.000Z","updated_at":"2025-03-10T15:58:01.000Z","dependencies_parsed_at":"2024-11-08T05:11:09.905Z","dependency_job_id":"2d40bc4f-c13d-4c84-b66a-4c45feb2de43","html_url":"https://github.com/kuoruan/v8go-polyfills","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/kuoruan%2Fv8go-polyfills","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kuoruan%2Fv8go-polyfills/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kuoruan%2Fv8go-polyfills/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kuoruan%2Fv8go-polyfills/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kuoruan","download_url":"https://codeload.github.com/kuoruan/v8go-polyfills/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248897179,"owners_count":21179552,"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","polyfill","v8","v8go"],"created_at":"2024-11-08T05:10:59.233Z","updated_at":"2025-04-14T14:31:36.387Z","avatar_url":"https://github.com/kuoruan.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Polyfills for [V8Go](https://github.com/rogchap/v8go)\n\n## Install\n\n```shell\ngo get -u go.kuoruan.net/v8go-polyfills\n```\n\n\u003e This module uses Golang [embed](https://golang.org/pkg/embed/), so requires Go version 1.16\n\n## Polyfill List\n\n* base64: `atob` and `btoa`\n\n* console: `console.log`\n\n* fetch: `fetch`\n\n* timers: `setTimeout`, `clearTimeout`, `setInterval` and `clearInterval`\n\n* url: `URL` and `URLSearchParams`\n\n## Usage\n\n### fetch polyfill\n\n```go\npackage main\n\nimport (\n\t\"errors\"\n\t\"fmt\"\n\t\"time\"\n\n\t\"go.kuoruan.net/v8go-polyfills/fetch\"\n\t\"rogchap.com/v8go\"\n)\n\nfunc main() {\n\tiso, _ := v8go.NewIsolate()\n\tglobal, _ := v8go.NewObjectTemplate(iso)\n\n\tif err := fetch.InjectTo(iso, global); err != nil {\n\t\tpanic(err)\n\t}\n\n\tctx, _ := v8go.NewContext(iso, global)\n\n\tval, err := ctx.RunScript(\"fetch('https://www.example.com').then(res =\u003e res.text())\", \"fetch.js\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tproms, err := val.AsPromise()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdone := make(chan bool, 1)\n\n\tgo func() {\n\t\tfor proms.State() == v8go.Pending {\n\t\t\tcontinue\n\t\t}\n\t\tdone \u003c- true\n\t}()\n\n\tselect {\n\tcase \u003c-time.After(time.Second * 10):\n\t\tpanic(errors.New(\"request timeout\"))\n\tcase \u003c-done:\n\t\thtml := proms.Result().String()\n\t\tfmt.Println(html)\n\t}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkuoruan%2Fv8go-polyfills","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkuoruan%2Fv8go-polyfills","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkuoruan%2Fv8go-polyfills/lists"}