{"_id":"@endo/immutable-arraybuffer","_rev":"9-d877dec0a8f984fc7710bb0da9d51f6f","name":"@endo/immutable-arraybuffer","dist-tags":{"latest":"2.0.0"},"versions":{"1.0.0":{"name":"@endo/immutable-arraybuffer","version":"1.0.0","keywords":["immutable","arraybuffer","typedarray","shim"],"author":{"name":"Endo contributors"},"license":"Apache-2.0","_id":"@endo/immutable-arraybuffer@1.0.0","maintainers":[{"name":"kriskowal","email":"kris.kowal@cixar.com"},{"name":"michaelfig","email":"michael@fig.org"},{"name":"erights","email":"erights@gmail.com"},{"name":"warner","email":"warner-npm@lothar.com"},{"name":"mhofman","email":"mathieu+npmjs@agoric.com"}],"homepage":"https://github.com/endojs/endo/tree/master/packages/immutable-arraybuffer#readme","bugs":{"url":"https://github.com/endojs/endo/issues"},"ava":{"files":["test/**/*.test.*"],"timeout":"2m"},"dist":{"shasum":"4b6f391fa41e7d0b34ffef99adaa24c3f3adb6f0","tarball":"https://registry.npmjs.org/@endo/immutable-arraybuffer/-/immutable-arraybuffer-1.0.0.tgz","fileCount":10,"integrity":"sha512-byFWWpfqpYu8uZ4bcgPvfKs1gOIrR2onwlEVs4zZ7a2htGZgzrVUmIU4JJdMoZs10e8e40K5uZxgHmylZkKWQw==","signatures":[{"sig":"MEQCIGmwIQVA4B+m1UPKJ4SO/0x8GvJZfPXVRMr540p7bLl/AiAA46QIUYwRRoSC+wh6j5ug5qasUM1dq0UnPrcJ+/7GpQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":35950},"main":"./index.js","type":"module","module":"./index.js","exports":{".":"./index.js","./shim.js":"./shim.js","./package.json":"./package.json"},"gitHead":"1078398eb8508e6ffc61873bc819a5e15d73328c","scripts":{"lint":"yarn lint:types && yarn lint:eslint","test":"ava","build":"exit 0","prepack":"tsc --build tsconfig.build.json","test:c8":"c8 $C8_OPTIONS ava --config=ava-nesm.config.js","test:xs":"exit 0","lint-fix":"yarn lint:eslint --fix && yarn lint:types","postpack":"git clean -f '*.d.ts*'","lint-check":"yarn lint","lint:types":"tsc","lint:eslint":"eslint '**/*.js'"},"_npmUser":{"name":"kriskowal","email":"kris.kowal@cixar.com"},"repository":{"url":"git+https://github.com/endojs/endo.git","type":"git","directory":"packages/immutable-arraybuffer"},"_npmVersion":"10.2.3","description":"Immutable ArrayBuffer (the shim!)","directories":{},"_nodeVersion":"18.19.0","eslintConfig":{"extends":["plugin:@endo/internal"]},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"c8":"^7.14.0","ava":"^6.1.3","tsd":"^0.31.2","typescript":"~5.6.3"},"_npmOperationalInternal":{"tmp":"tmp/immutable-arraybuffer_1.0.0_1746656646451_0.976159211251955","host":"s3://npm-registry-packages-npm-production"}},"1.1.0":{"name":"@endo/immutable-arraybuffer","version":"1.1.0","keywords":["immutable","arraybuffer","typedarray","shim"],"author":"Endo contributors","license":"Apache-2.0","_id":"@endo/immutable-arraybuffer@1.1.0","maintainers":[{"name":"kriskowal","email":"kris.kowal@cixar.com"},{"name":"michaelfig","email":"michael@fig.org"},{"name":"erights","email":"erights@gmail.com"},{"name":"warner","email":"warner-npm@lothar.com"},{"name":"mhofman","email":"mathieu+npmjs@agoric.com"}],"homepage":"https://github.com/endojs/endo/tree/master/packages/immutable-arraybuffer#readme","bugs":{"url":"https://github.com/endojs/endo/issues"},"ava":{"files":["test/**/*.test.*"],"timeout":"2m"},"dist":{"shasum":"81283ad1587e78e2f85ea7140e0d72e2932020d7","tarball":"https://registry.npmjs.org/@endo/immutable-arraybuffer/-/immutable-arraybuffer-1.1.0.tgz","fileCount":16,"integrity":"sha512-WAGGKiNiS3geaxLVOia9UYPzfKOASFHuu8lV4n76dyVf7BFlEx//URxRzLrcUR0bK+99Gju+g3sRnA97ytVh5w==","signatures":[{"sig":"MEUCIQDMgVm2qv4TrXie5eYqhT3AfcFCu37JUPwzdCTYpj5yAQIgVYA1wtMPanNHSrnniuUyqtM7omYe0jwrzbmUW4tVQFI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":41764},"main":"./index.js","type":"module","module":"./index.js","exports":{".":"./index.js","./shim.js":"./shim.js","./package.json":"./package.json","./shim-hermes.js":"./shim-hermes.js"},"gitHead":"571b7803cf10df7cb4fa9d70e4d53a0b53767fa8","scripts":{"lint":"yarn lint:types && yarn lint:eslint","test":"ava","build":"exit 0","prepack":"tsc --build tsconfig.build.json","test:c8":"c8 $C8_OPTIONS ava --config=ava-nesm.config.js","test:xs":"exit 0","lint-fix":"yarn lint:eslint --fix && yarn lint:types","postpack":"git clean -f '*.d.ts*' '*.tsbuildinfo'","lint:types":"tsc","lint:eslint":"eslint '**/*.js'"},"_npmUser":{"name":"kriskowal","email":"kris.kowal@cixar.com"},"repository":{"url":"git+https://github.com/endojs/endo.git","type":"git","directory":"packages/immutable-arraybuffer"},"_npmVersion":"lerna/8.1.8/node@v18.19.0+x64 (darwin)","description":"Immutable ArrayBuffer (the shim!)","directories":{},"_nodeVersion":"18.19.0","eslintConfig":{"extends":["plugin:@endo/internal"]},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"c8":"^7.14.0","ava":"^6.1.3","tsd":"^0.31.2","typescript":"~5.8.3"},"_npmOperationalInternal":{"tmp":"tmp/immutable-arraybuffer_1.1.0_1748907765547_0.5875340647546778","host":"s3://npm-registry-packages-npm-production"}},"1.1.1":{"name":"@endo/immutable-arraybuffer","version":"1.1.1","keywords":["immutable","arraybuffer","typedarray","shim"],"author":"Endo contributors","license":"Apache-2.0","_id":"@endo/immutable-arraybuffer@1.1.1","maintainers":[{"name":"kriskowal","email":"kris.kowal@cixar.com"},{"name":"michaelfig","email":"michael@fig.org"},{"name":"erights","email":"erights@gmail.com"},{"name":"warner","email":"warner-npm@lothar.com"},{"name":"mhofman","email":"mathieu+npmjs@agoric.com"}],"homepage":"https://github.com/endojs/endo/tree/master/packages/immutable-arraybuffer#readme","bugs":{"url":"https://github.com/endojs/endo/issues"},"ava":{"files":["test/**/*.test.*"],"timeout":"2m"},"dist":{"shasum":"ba81f43b80ab2c87aaab19eccc6e794977187b9f","tarball":"https://registry.npmjs.org/@endo/immutable-arraybuffer/-/immutable-arraybuffer-1.1.1.tgz","fileCount":16,"integrity":"sha512-v57HL0airAsQi278qAxf7UM788EE1U/8D1JoALtWsDjz+bZ2C84NKy9uwVi7G1YmzesbQMB2nrvWRXavL6LftA==","signatures":[{"sig":"MEYCIQC3LfhwqL1mWjem7MzxBY2lzvRgocW85DrkPwxa3WEDzgIhAItVdcIS6E0tRby6T0rjaq3KigD17v7SVtjOM8dxK4nX","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":43367},"main":"./index.js","type":"module","module":"./index.js","exports":{".":"./index.js","./shim.js":"./shim.js","./package.json":"./package.json","./shim-hermes.js":"./shim-hermes.js"},"gitHead":"03b92fc383da5d8bb4ea993b90149a0db5799d0b","scripts":{"lint":"yarn lint:types && yarn lint:eslint","test":"ava","build":"exit 0","prepack":"tsc --build tsconfig.build.json","test:c8":"c8 $C8_OPTIONS ava --config=ava-nesm.config.js","test:xs":"exit 0","lint-fix":"yarn lint:eslint --fix && yarn lint:types","postpack":"git clean -fX \"*.d.ts*\" \"*.d.cts*\" \"*.d.mts*\" \"*.tsbuildinfo\"","lint:types":"tsc","lint:eslint":"eslint '**/*.js'"},"_npmUser":{"name":"kriskowal","actor":{"name":"kriskowal","type":"user","email":"kris.kowal@cixar.com"},"email":"kris.kowal@cixar.com"},"repository":{"url":"git+https://github.com/endojs/endo.git","type":"git","directory":"packages/immutable-arraybuffer"},"_npmVersion":"lerna/8.1.8/node@v18.19.0+x64 (darwin)","description":"Immutable ArrayBuffer (the shim!)","directories":{},"_nodeVersion":"18.19.0","eslintConfig":{"extends":["plugin:@endo/internal"]},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"c8":"^7.14.0","ava":"^6.1.3","tsd":"^0.31.2","typescript":"~5.8.3"},"_npmOperationalInternal":{"tmp":"tmp/immutable-arraybuffer_1.1.1_1750204539563_0.2136212584000905","host":"s3://npm-registry-packages-npm-production"}},"1.1.2":{"name":"@endo/immutable-arraybuffer","version":"1.1.2","keywords":["immutable","arraybuffer","typedarray","shim"],"author":"Endo contributors","license":"Apache-2.0","_id":"@endo/immutable-arraybuffer@1.1.2","maintainers":[{"name":"kriskowal","email":"kris.kowal@cixar.com"},{"name":"michaelfig","email":"michael@fig.org"},{"name":"erights","email":"erights@gmail.com"},{"name":"warner","email":"warner-npm@lothar.com"},{"name":"mhofman","email":"mathieu+npmjs@agoric.com"}],"homepage":"https://github.com/endojs/endo/tree/master/packages/immutable-arraybuffer#readme","bugs":{"url":"https://github.com/endojs/endo/issues"},"ava":{"files":["test/**/*.test.*"],"timeout":"2m"},"dist":{"shasum":"76bf0f1c4a8f925e52cc461c74c2032876d733aa","tarball":"https://registry.npmjs.org/@endo/immutable-arraybuffer/-/immutable-arraybuffer-1.1.2.tgz","fileCount":16,"integrity":"sha512-u+NaYB2aqEugQ3u7w3c5QNkPogf8q/xGgsPaqdY6pUiGWtYiTiFspKFcha6+oeZhWXWQ23rf0KrUq0kfuzqYyQ==","signatures":[{"sig":"MEUCIQC7mCp3eDl5UVGblbjgEKJaMfS5BR1TpCN/Thb61EMV6QIgBAsgTLgzOX9ak3nIXYKnGvW42iEYw+QI2ncYEWqR3rc=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":39926},"main":"./index.js","type":"module","module":"./index.js","exports":{".":"./index.js","./shim.js":"./shim.js","./package.json":"./package.json"},"gitHead":"9815aea9541f241389d2135c6097a7442bdffa17","scripts":{"lint":"yarn lint:types && yarn lint:eslint","test":"ava","build":"exit 0","prepack":"tsc --build tsconfig.build.json","test:c8":"c8 $C8_OPTIONS ava --config=ava-nesm.config.js","test:xs":"exit 0","lint-fix":"yarn lint:eslint --fix && yarn lint:types","postpack":"git clean -fX \"*.d.ts*\" \"*.d.cts*\" \"*.d.mts*\" \"*.tsbuildinfo\"","lint:types":"tsc","lint:eslint":"eslint '**/*.js'"},"_npmUser":{"name":"kriskowal","email":"kris.kowal@cixar.com"},"repository":{"url":"git+https://github.com/endojs/endo.git","type":"git","directory":"packages/immutable-arraybuffer"},"_npmVersion":"lerna/8.1.8/node@v18.19.0+x64 (darwin)","description":"Immutable ArrayBuffer (the shim!)","directories":{},"_nodeVersion":"18.19.0","eslintConfig":{"extends":["plugin:@endo/ses"]},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"c8":"^7.14.0","ava":"^6.1.3","tsd":"^0.31.2","eslint":"^8.57.1","typescript":"~5.8.3","babel-eslint":"^10.1.0","eslint-plugin-import":"^2.31.0","eslint-config-prettier":"^9.1.0","eslint-config-airbnb-base":"^15.0.0","eslint-plugin-eslint-comments":"^3.2.0"},"_npmOperationalInternal":{"tmp":"tmp/immutable-arraybuffer_1.1.2_1752290939042_0.3335064396548695","host":"s3://npm-registry-packages-npm-production"}},"2.0.0":{"name":"@endo/immutable-arraybuffer","version":"2.0.0","description":"Immutable ArrayBuffer (the shim!)","keywords":["immutable","arraybuffer","typedarray","shim"],"author":{"name":"Endo contributors"},"license":"Apache-2.0","homepage":"https://github.com/endojs/endo/tree/master/packages/immutable-arraybuffer#readme","repository":{"type":"git","url":"git+https://github.com/endojs/endo.git","directory":"packages/immutable-arraybuffer"},"bugs":{"url":"https://github.com/endojs/endo/issues"},"type":"module","exports":{"./shim.js":{"types":"./shim.types.d.ts","default":"./shim.js"},"./package.json":"./package.json"},"scripts":{"build":"exit 0","lint":"yarn lint:types && yarn lint:eslint","lint-fix":"yarn lint:eslint --fix && yarn lint:types","lint:eslint":"eslint .","lint:types":"tsc","test":"ava","test:c8":"c8 ${C8_OPTIONS:-} ava","test:xs":"exit 0"},"devDependencies":{"ava":"^8.0.1","c8":"^11.0.0","eslint":"^10.4.1","tsd":"^0.33.0","typescript":"~6.0.3"},"publishConfig":{"access":"public"},"ava":{"files":["test/**/*.test.*"],"timeout":"2m"},"_id":"@endo/immutable-arraybuffer@2.0.0","_integrity":"sha512-xvfJvo4CgETh6UjSKwhNsFLZrqrTf2k4ZFpcprEN2UtCQRSOk+CcLP70kFbrOesB2Z/c1z9MaUZDS1JY6IlnUg==","_resolved":"/Users/boneskull/projects/endojs/endo-fresh/dist/@endo-immutable-arraybuffer-2.0.0.tgz","_from":"file:/Users/boneskull/projects/endojs/endo-fresh/dist/@endo-immutable-arraybuffer-2.0.0.tgz","_nodeVersion":"24.18.0","_npmVersion":"12.0.2","dist":{"integrity":"sha512-xvfJvo4CgETh6UjSKwhNsFLZrqrTf2k4ZFpcprEN2UtCQRSOk+CcLP70kFbrOesB2Z/c1z9MaUZDS1JY6IlnUg==","shasum":"6f3d82260c0e63d9c0c4e8fac0c86476c665ff57","tarball":"https://registry.npmjs.org/@endo/immutable-arraybuffer/-/immutable-arraybuffer-2.0.0.tgz","fileCount":15,"unpackedSize":54196,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDOhpvnO/KColHKHESOkFJD71bXr4NKkjldXV+NggU7EAIgeLcMWZ58SIiGYXrEAPz/jTzDBFyOityfoAZQGCSkF34="}]},"_npmUser":{"name":"boneskull","email":"boneskull@boneskull.com"},"directories":{},"maintainers":[{"name":"kriskowal","email":"kris.kowal@cixar.com"},{"name":"michaelfig","email":"michael@fig.org"},{"name":"erights","email":"erights@gmail.com"},{"name":"warner","email":"warner-npm@lothar.com"},{"name":"mhofman","email":"mathieu+npmjs@agoric.com"},{"name":"boneskull","email":"boneskull@boneskull.com"},{"name":"naugtur","email":"naugtur@gmail.com"},{"name":"turadga","email":"turadg@gmail.com"},{"name":"kriscendobot","email":"small.fan4812@fastmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/immutable-arraybuffer_2.0.0_1786661530750_0.5201794831617921"},"_hasShrinkwrap":false}},"time":{"created":"2025-05-07T22:24:06.346Z","modified":"2026-08-13T22:52:11.106Z","1.0.0":"2025-05-07T22:24:06.729Z","1.1.0":"2025-06-02T23:42:45.718Z","1.1.1":"2025-06-17T23:55:39.749Z","1.1.2":"2025-07-12T03:28:59.232Z","2.0.0":"2026-08-13T22:52:10.929Z"},"bugs":{"url":"https://github.com/endojs/endo/issues"},"author":{"name":"Endo contributors"},"license":"Apache-2.0","homepage":"https://github.com/endojs/endo/tree/master/packages/immutable-arraybuffer#readme","keywords":["immutable","arraybuffer","typedarray","shim"],"repository":{"type":"git","url":"git+https://github.com/endojs/endo.git","directory":"packages/immutable-arraybuffer"},"description":"Immutable ArrayBuffer (the shim!)","maintainers":[{"name":"kriskowal","email":"kris.kowal@cixar.com"},{"name":"michaelfig","email":"michael@fig.org"},{"name":"erights","email":"erights@gmail.com"},{"name":"warner","email":"warner-npm@lothar.com"},{"name":"mhofman","email":"mathieu+npmjs@agoric.com"},{"name":"boneskull","email":"boneskull@boneskull.com"},{"name":"naugtur","email":"naugtur@gmail.com"},{"name":"turadga","email":"turadg@gmail.com"},{"name":"kriscendobot","email":"small.fan4812@fastmail.com"}],"readme":"# `@endo/immutable-arraybuffer`\n\nThis `@endo/immutable-arraybuffer` package provides a shim for a proposed new JavaScript feature: *Immutable ArrayBuffers*.\nA shim modifies the existing JavaScript primordials as needed to most closely emulate the feature as proposed.\nImporting `@endo/immutable-arraybuffer/shim.js` will cause these changes.\n\nBelow, we use the term \"buffer\" to refer informally to an instance of an `ArrayBuffer`, whether immutable or not.\n\n## Background\n\nPrior proposals [In-Place Resizable and Growable `ArrayBuffer`s](https://github.com/tc39/proposal-resizablearraybuffer) and [ArrayBuffer.prototype.transfer and friends](https://github.com/tc39/proposal-arraybuffer-transfer) have both reached stage 4, and so are now an official part of JavaScript.\nAltogether, `ArrayBuffer.prototype` now has the following methods:\n- `transfer(newByteLength?: number) :ArrayBuffer` -- move the contents of the original buffer to a new buffer, detach the original buffer, and return the new buffer.\nThe new buffer will be as resizable as the original was.\n- `transferToFixedLength(newByteLength?: number) :ArrayBuffer` -- like `transfer` but the new buffer is not resizable.\n- `resize(newByteLength: number) :void` -- change the size of this buffer if possible, or throw otherwise.\n- `slice(start?: number, end?: number) :ArrayBuffer` -- Return a new buffer whose initial contents are a copy of that region of the original buffer.\nThe original buffer is unmodified.\n\nand the following read-only accessor properties\n- `detached: boolean` -- is this buffer detached, or are its contents still available from this buffer object?\n- `resizable: boolean` -- can this buffer be resized, or is it fixed-length?\n- `byteLength: number` -- how big are the current contents of this buffer?\n- `maxByteLength: number` -- how big could this buffer be resized to be?\n\nNone of the operations above enable the creation of an immutable buffer, that is, a non-detached buffer whose contents cannot be changed, resized, or detached.\n\nBoth a `DataView` object and a `TypedArray` object are views into a buffer backing store.\nFor a `TypedArray` object, the contents of the backing store appear as indexed data properties of the `TypeArray` object that reflect the current contents of this backing store.\nCurrently, because there is no way to prevent the contents of the backing store from being changed, `TypedArray`s cannot be frozen.\n\nSome JavaScript implementations, like Moddable XS, bring JavaScript to embedded systems, like device controllers, where ROM is much more plentiful and cheaper than RAM.\nThese systems need to place voluminous fixed data into ROM, and currently do so using semantics outside the official JavaScript standard.\n\nThe [OCapN](https://ocapn.org/) network protocol treats strings and byte-arrays as distinct forms of bulk data to be transmitted by copy.\nAt JavaScript endpoints speaking OCapN such as `@endo/pass-style` + `@endo/marshal`, JavaScript strings represent OCapN strings.\nThe immutability of strings in the JavaScript language reflects their by-copy nature in the protocol.\nLikewise, to reflect an OCapN byte-array well into the JavaScript language, we need an immutable container of bulk binary data.\nThere currently are none.\nA frozen `Uint8Array` would provide exactly the low-level machinery we need.\n\n## Overview of the *Immutable ArrayBuffer* Proposal\n\nThe *Immutable ArrayBuffer* proposal introduces additional methods and read-only accessor properties to `ArrayBuffer.prototype` that fit naturally into those explained above.\nJust as a buffer can be resizable or not, or detached or not, this proposal enables buffers to be immutable or not.\nJust as `transferToFixedSize` moves the contents of a original buffer into a newly created non-resizable buffer, this proposal provides a transfer operation that moves the contents of an original original buffer into a newly created immutable buffer.\nAltogether, this proposal only adds to `ArrayBuffer.prototype` one method\n- `transferToImmutable() :ArrayBuffer` -- move the contents of the original buffer into a new immutable buffer, detach the original buffer, and return the new buffer.\n\nand one read-only accessor\n- `immutable: boolean` -- is this buffer immutable, or can its contents be changed?\n\nAn immutable buffer cannot be detached or resized.\nIts `maxByteLength` is the same as its `byteLength`.\nA `DataView` or `TypedArray` using an immutable buffer as its backing store can be frozen and immutable.\n`ArrayBuffer`s, `DataView`s, and `TypedArray`s that are frozen and immutable could be placed in ROM without going beyond JavaScript's official semantics.\n\n## The Shim\n\nImporting `@endo/immutable-arraybuffer/shim.js` installs the proposed methods (`transferToImmutable`, `sliceToImmutable`) and accessor (`immutable`) onto `ArrayBuffer.prototype`, along with replacements for the genuine `slice`, `resize`, `transfer`, and `transferToFixedLength` methods that discriminate on whether the receiver is an emulated immutable buffer.\nFor genuine ArrayBuffers, the replacements delegate to the captured genuine methods and behave identically to before.\nFor emulated immutable buffers, the methods either return the appropriate immutable behaviour (for `slice`) or throw the appropriate \"cannot mutate\" `TypeError` (for the mutators).\n\nThe shim's install policy is detect-then-skip: if `'sliceToImmutable' in ArrayBuffer.prototype` is already true when the shim loads (a native implementation, or a previously loaded shim), the shim does nothing and the prior installation wins.\nThe Immutable ArrayBuffer proposal has reached stage 3; at that threshold an earlier installation is presumed authoritative.\n\n## Caveats\n\nThe *Immutable ArrayBuffer* shim falls short of the proposal in the following ways\n- The shim relies on the underlying platform having either `structuredClone` or `ArrayBuffer.prototype.transfer`.\nSee [Platform support for `transferToImmutable`](#platform-support-for-transfertoimmutable) below for the per-engine version thresholds and the guidance on when feature-testing is necessary.\nWithout either, the shim still shims `ArrayBuffer.prototype.sliceToImmutable` but omits `ArrayBuffer.prototype.transferToImmutable`.\n- The shim's emulated immutable buffers are not real `ArrayBuffer` exotic objects.\nIf they were, the shim would not be able to protect them from being written.\nEven though they implement the full proposed `ArrayBuffer` API, they cannot be plug-compatible: they cannot be used as the backing stores of `DataView`s or `TypedArray`s.\nPerhaps follow-on shims might modify `DataView` and `TypedArray` to emulate that as well, but that is hard and beyond the ambition of this shim.\n- Unlike genuine `ArrayBuffer` or `SharedArrayBuffer` exotic objects, the shim's emulated immutable buffers cannot be cloned or transfered between JS threads.\n- This is a plain *JavaScript* shim, not by itself a *Hardened JavaScript* polyfill/shim.\nThus, the objects and function it creates are not hardened by this shim itself.\nRather, the ses-shim is expected to import this, and then treat the resulting objects as if they were additional primordials, to be hardened during `lockdown`'s harden phase.\n\n## Platform support for `transferToImmutable`\n\nThe shim's emulation of `ArrayBuffer.prototype.transferToImmutable` requires the underlying platform to provide either `ArrayBuffer.prototype.transfer` (preferred when present) or the global `structuredClone` (used as a fallback to move the buffer's contents into a new backing store).\n`sliceToImmutable` and the `immutable` accessor work on every platform; only `transferToImmutable` carries this dependency.\n\nThe following table records the first engine version that ships at least one of those primitives.\nA cell marked **either** means the platform has both `structuredClone` and `ArrayBuffer.prototype.transfer`; a cell marked **structuredClone only** means the shim uses the structured-clone fallback path.\n\"Deficient\" means neither primitive is present and `ArrayBuffer.prototype.transferToImmutable` is therefore absent after the shim loads.\n\n### Engines\n\n| Engine | First version with `structuredClone` | First version with `ArrayBuffer.prototype.transfer` | Status as of shipping today |\n| --- | --- | --- | --- |\n| V8 (Chromium) | 9.8 (with Chrome 98, Feb 2022) | 11.4 (with Chrome 114, May 2023) | **either** |\n| SpiderMonkey (Firefox) | shipped with Firefox 94 (Nov 2021) | shipped with Firefox 122 (Jan 2024) | **either** |\n| JavaScriptCore (WebKit) | shipped with Safari 15.4 (Mar 2022) | shipped with Safari 17.4 (Mar 2024) | **either** |\n| Hermes | not implemented | not implemented | **deficient** |\n\nThe `structuredClone` global is a Web/HTML platform feature exposed to script through the engine's host environment; the dates above are for the host build that first exposed it.\n`ArrayBuffer.prototype.transfer` is a TC39 language feature (ES2024) implemented in the engine itself.\n\n### Runtimes and browsers\n\n| Runtime / browser | First version with `structuredClone` | First version with `ArrayBuffer.prototype.transfer` | Status as of shipping today |\n| --- | --- | --- | --- |\n| Node.js | 17.0.0 (Oct 2021) | 21.0.0 (Oct 2023) | **either** on Node 21 and later; **structuredClone only** on Node 17 through 20; **deficient** on Node 16 and earlier |\n| Deno | 1.14 (Sep 2021) | 1.33 (May 2023) | **either** on Deno 1.33 and later |\n| Chrome / Edge | 98 (Feb 2022) | 114 (May 2023) | **either** on Chrome 114 and later; **structuredClone only** on Chrome 98 through 113 |\n| Firefox | 94 (Nov 2021) | 122 (Jan 2024) | **either** on Firefox 122 and later; **structuredClone only** on Firefox 94 through 121 |\n| Safari | 15.4 (Mar 2022) | 17.4 (Mar 2024) | **either** on Safari 17.4 and later; **structuredClone only** on Safari 15.4 through 17.3 |\n| React Native (Hermes) | not implemented | not implemented | **deficient** |\n\nNode 22 (active LTS at the time of writing) and Node 24 (current) both have `ArrayBuffer.prototype.transfer` and use the preferred path.\nNode 18 and Node 20 reach the structured-clone fallback path; both are past or near end-of-life under the Node release schedule.\n\n### Feature-testing guidance\n\nOnly code that might run on a **deficient** platform needs to feature-test for `ArrayBuffer.prototype.transferToImmutable`:\n\n```js\nimport '@endo/immutable-arraybuffer/shim.js';\n\nif (typeof ArrayBuffer.prototype.transferToImmutable === 'function') {\n  // use transferToImmutable\n} else {\n  // fall back to sliceToImmutable (always present once the shim loads)\n}\n```\n\nCode whose deployment targets are all non-deficient (any modern browser, Node.js 17 and later, Deno 1.14 and later) can rely on `transferToImmutable` being present after `import '@endo/immutable-arraybuffer/shim.js'` and skip the feature test.\nReact Native on Hermes and pre-Node-17 server environments are the practical cases that still require the test.\n\n## Purposeful Violation\n\nThis package sets `[Symbol.toStringTag]` to `'ImmutableArrayBuffer'` on each emulated immutable buffer (as an own property of the instance, not on the shared `ArrayBuffer.prototype`).\nThe rationale: Node's [concordance](https://github.com/concordancejs/concordance/blob/791d2a89b40eb13f2c889ac270dd8be190cf8073/lib/describe.js#L36) (used by ava for diagnostic output) sniffs the result of `Object.prototype.toString.call(value)` to decide whether it can do `Buffer.from(value)` on the object.\n`Buffer.from` only works on genuine `ArrayBuffer` exotic objects; passing an emulated immutable buffer to it throws a `TypeError` that concordance does not handle gracefully.\nThe own-property `[Symbol.toStringTag] = 'ImmutableArrayBuffer'` slot keeps concordance from routing the value through `Buffer.from` and lets it fall through to the unrenderable-value path.\n\nThe drop-the-pseudo-prototype redesign removed the intermediate prototype that earlier versions hung this slot on; the slot is now installed per-instance via `defineProperty` in `makeImmutableArrayBufferInternal`.\nGenuine ArrayBuffers continue to inherit `'ArrayBuffer'` from the prototype: `Object.prototype.toString.call(new ArrayBuffer(0))` reads as `'[object ArrayBuffer]'`.\nOnly emulated immutable buffers carry the `'ImmutableArrayBuffer'` slot: `Object.prototype.toString.call(new ArrayBuffer(0).sliceToImmutable())` reads as `'[object ImmutableArrayBuffer]'`.\nCallers that need to distinguish emulated immutable buffers from genuine ones programmatically should prefer the `immutable` accessor on `ArrayBuffer.prototype` (installed by the shim), which is the canonical brand check.\n","readmeFilename":"README.md"}