{"id":19168470,"url":"https://github.com/bloomberg/record-tuple-polyfill","last_synced_at":"2025-04-12T21:33:57.376Z","repository":{"id":38427017,"uuid":"251353916","full_name":"bloomberg/record-tuple-polyfill","owner":"bloomberg","description":"A polyfill for the ECMAScript Record and Tuple proposal.","archived":false,"fork":false,"pushed_at":"2023-07-18T21:30:28.000Z","size":3477,"stargazers_count":166,"open_issues_count":17,"forks_count":11,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-04-04T01:09:19.108Z","etag":null,"topics":["immutable","javascript","polyfill","record","tc39","tuple"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bloomberg.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":"2020-03-30T15:52:14.000Z","updated_at":"2025-03-18T02:42:24.000Z","dependencies_parsed_at":"2024-06-18T14:06:52.889Z","dependency_job_id":null,"html_url":"https://github.com/bloomberg/record-tuple-polyfill","commit_stats":{"total_commits":91,"total_committers":8,"mean_commits":11.375,"dds":0.5494505494505495,"last_synced_commit":"5f9cae34f0d331c4836efbc9cd618836c03e75f5"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bloomberg%2Frecord-tuple-polyfill","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bloomberg%2Frecord-tuple-polyfill/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bloomberg%2Frecord-tuple-polyfill/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bloomberg%2Frecord-tuple-polyfill/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bloomberg","download_url":"https://codeload.github.com/bloomberg/record-tuple-polyfill/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248636852,"owners_count":21137527,"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":["immutable","javascript","polyfill","record","tc39","tuple"],"created_at":"2024-11-09T09:42:47.488Z","updated_at":"2025-04-12T21:33:57.354Z","avatar_url":"https://github.com/bloomberg.png","language":"JavaScript","readme":"\n# Record \u0026 Tuple Polyfill\nThe [Record and Tuple](https://github.com/tc39/proposal-record-tuple) ECMAScript proposal introduces new deeply immutable value types to JavaScript\nthat have similar access idioms to objects and arrays.\n\nThis is an **experimental and explicitly not production ready** polyfill for the `Record and Tuple` proposal, and a [babel](https://babeljs.io) transform to support using the literal syntax.\n\nThe polyfill and transform are **constant works in progress** and are not the source of truth for the proposal.\n\n# Requirements\n\nIn order to use the syntax transform, [babel](https://babeljs.io) must be installed with at least version `7.9.0`.\n\nIn order to use the polyfill, the environment must support `WeakMap`, [`WeakRef`, and `FinalizationRegistry`](https://github.com/tc39/proposal-weakrefs). If implementations of these features are not provided, an error will be thrown.\n\n# Installation\n\nTo install the transform and polyfill:\n\n```\n# install the babel transform as a dev dependency, only needed at compile time\nnpm install -D @babel/plugin-proposal-record-and-tuple\n\n# install the polyfill as a regular dependency, needed at runtime\nnpm install --save @bloomberg/record-tuple-polyfill\n```\n\nNext, add the plugin to your `babel` configuration. Example:\n\n```json\n{\n    \"plugins\": [[\"@babel/plugin-proposal-record-and-tuple\", { \"syntaxType\": \"hash\" }]]\n}\n```\n\n\u003e Note, the `syntaxType` option is required, and must be set to either `hash` or `bar`.\n\n# Usage\n\nIf the `babel` transform and the polyfill are setup, you can start using the `Record and Tuple` literal syntax.\n\n```js\nconsole.log(#{ a: 1 } === #{ a: 1 });\nconsole.log(#[1, 2, 3] === #[1, 2, 3]);\n```\n\nIf you want to use the Record or Tuple global objects, you can import them from the polyfill directly.\n\n```js\nimport { Record, Tuple } from \"@bloomberg/record-tuple-polyfill\";\n\nconst record = Record({ a: 1 });\nconst tuple = Tuple(1, 2, 3);\nconst array = [1,2,3];\n\nconsole.log(Record.isRecord(record));\nconsole.log(Record.keys(record));\nconsole.log(Tuple.from(array));\n```\n\n# Unsupported Features\n\n`typeof` will return an incorrect value when provided a `Record` or `Tuple`.\nStoring `+/-0` differs from the spec, `Object.is( #[+0][0], #[-0][0] )` returns `true` when it should return `false`.\nThis is because the polyfill implements the proposal via [interning](https://en.wikipedia.org/wiki/String_interning) frozen objects.\n\n# Playground\n\nThe Record and Tuple polyfill has been deployed in an easy to use REPL [here](https://rickbutton.github.io/record-tuple-playground/).\n\n## Supported Environments/Browsers\n\nThe Record and Tuple polyfill requires several JavaScript features that are only available experimentally in browsers, specifically `WeakRef` and `FinalizationRegistry`.\n\nThe following environments support these experimental features out-of-the-box.\n\n| environment     | supported                                |\n|-----------------|------------------------------------------|\n| [Chrome Canary](https://www.google.com/chrome/canary/)   | :heavy_check_mark:                       |\n\n\nIn order to use these experimental features other browsers, you must run the browser/environment with specific flags:\n\n| environment     | flags                                    |\n|-----------------|------------------------------------------|\n| node            | --harmony-weak-refs                      |\n| Chrome          | --js-flags=\"--harmony-weak-refs\"         |\n| Firefox Nightly | javascript.options.experimental.weakrefs |\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbloomberg%2Frecord-tuple-polyfill","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbloomberg%2Frecord-tuple-polyfill","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbloomberg%2Frecord-tuple-polyfill/lists"}