summaryrefslogtreecommitdiff
path: root/extensions/web/02_structured_clone.js
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2021-07-06 14:38:12 +0200
committerGitHub <noreply@github.com>2021-07-06 14:38:12 +0200
commit1aac47720b8dad6826d59263f8e825c221f2a328 (patch)
tree198e239c8389ef168fbb8dde5aecb11105a170e4 /extensions/web/02_structured_clone.js
parentf139a0cc11f0b3a7e3cb1975310c079e4741d199 (diff)
refactor: use primordials in extensions/web (#11273)
Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
Diffstat (limited to 'extensions/web/02_structured_clone.js')
-rw-r--r--extensions/web/02_structured_clone.js17
1 files changed, 14 insertions, 3 deletions
diff --git a/extensions/web/02_structured_clone.js b/extensions/web/02_structured_clone.js
index 265d89247..4845c6508 100644
--- a/extensions/web/02_structured_clone.js
+++ b/extensions/web/02_structured_clone.js
@@ -2,6 +2,7 @@
// @ts-check
/// <reference path="../../core/lib.deno_core.d.ts" />
+/// <reference path="../../core/internal.d.ts" />
/// <reference path="../web/internal.d.ts" />
/// <reference path="../web/lib.deno_web.d.ts" />
@@ -10,6 +11,15 @@
((window) => {
const core = window.Deno.core;
const { DOMException } = window.__bootstrap.domException;
+ const {
+ ArrayBuffer,
+ ArrayBufferIsView,
+ DataView,
+ TypedArrayPrototypeSlice,
+ TypeError,
+ WeakMap,
+ WeakMapPrototypeSet,
+ } = window.__bootstrap.primordials;
const objectCloneMemo = new WeakMap();
@@ -20,7 +30,8 @@
_cloneConstructor,
) {
// this function fudges the return type but SharedArrayBuffer is disabled for a while anyway
- return srcBuffer.slice(
+ return TypedArrayPrototypeSlice(
+ srcBuffer,
srcByteOffset,
srcByteOffset + srcLength,
);
@@ -38,10 +49,10 @@
value.byteLength,
ArrayBuffer,
);
- objectCloneMemo.set(value, cloned);
+ WeakMapPrototypeSet(objectCloneMemo, value, cloned);
return cloned;
}
- if (ArrayBuffer.isView(value)) {
+ if (ArrayBufferIsView(value)) {
const clonedBuffer = structuredClone(value.buffer);
// Use DataViewConstructor type purely for type-checking, can be a
// DataView or TypedArray. They use the same constructor signature,