{"id":17034105,"url":"https://github.com/theolampert/ecmaswift","last_synced_at":"2025-11-01T04:04:24.192Z","repository":{"id":165256788,"uuid":"640150680","full_name":"theolampert/ECMASwift","owner":"theolampert","description":"A tiny Javascript runtime for iOS and macOS","archived":false,"fork":false,"pushed_at":"2024-09-26T08:25:05.000Z","size":90,"stargazers_count":27,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-14T06:46:57.031Z","etag":null,"topics":["codable","ecmascript","javascript","javascriptcore","swift"],"latest_commit_sha":null,"homepage":"","language":"Swift","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/theolampert.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":"2023-05-13T06:35:28.000Z","updated_at":"2025-02-10T22:10:57.000Z","dependencies_parsed_at":null,"dependency_job_id":"7fdb927f-c321-473c-b88a-a8ad14c566f1","html_url":"https://github.com/theolampert/ECMASwift","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theolampert%2FECMASwift","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theolampert%2FECMASwift/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theolampert%2FECMASwift/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theolampert%2FECMASwift/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/theolampert","download_url":"https://codeload.github.com/theolampert/ECMASwift/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244995112,"owners_count":20544287,"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":["codable","ecmascript","javascript","javascriptcore","swift"],"created_at":"2024-10-14T08:37:25.321Z","updated_at":"2025-11-01T04:04:24.155Z","avatar_url":"https://github.com/theolampert.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"### ECMASwift\n\nECMASwift intends to implement a tiny subset of Browser APIs (mostly networking related) to make code sharing between iOS/macOS apps and the web easier.\n\n### Features\n\nECMASwift exposes the following browser APIs to JavascriptCore, some of these are incomplete, contributions welcome.\n\n- Blob\n- Console\n- Crypto\n- Fetch\n- FormData\n- Headers\n- Request\n- TextEncoder\n- Timers\n- URL\n- URLSearchParams\n\n### Examples\n\nIn Javascript:\n```js\n// Define an async function to fetch some dummy data in Javascript\nasync function fetchProducts() {\n    try {\n        const res = await fetch(\"https://google.com\")\n        return await res.json()\n    } catch(error) {\n        console.log(error)\n    }\n}\n```\n\nIn Swift:\n```swift\nimport ECMASwift\nimport JavaScriptCore\n\n// Initialise the runtime\nlet runtime = JSRuntime()\n\n// Load the javascript source file defined above, alternatively JS can be written inline.\nlet javascriptSource = try! String(contentsOfFile: \"./example.js\")\n\n// Evaluate the script\n_ = runtime.context.evaluateScript(javascriptSource)\n\n// Call the `fetchProducts` function defined in the source file.\nlet result = try! await runtime.context.callAsyncFunction(key: \"fetchProducts\")\n\n// Print the result\nprint(result.toString())\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheolampert%2Fecmaswift","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftheolampert%2Fecmaswift","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheolampert%2Fecmaswift/lists"}