summaryrefslogtreecommitdiff
path: root/runtime/js/01_web_util.js
diff options
context:
space:
mode:
authorSatya Rohith <me@satyarohith.com>2021-06-07 17:49:33 +0530
committerGitHub <noreply@github.com>2021-06-07 14:19:33 +0200
commitb6400a25a0ee60467a0287d725e61c876677e103 (patch)
tree7577846005e160141ffb8bd9d861dbfe365324ff /runtime/js/01_web_util.js
parent89290741d18d9b247cefccdc95563ec688a28491 (diff)
refactor(runtime): move performance API to timers extension (#10818)
Co-authored-by: Luca Casonato <hello@lcas.dev>
Diffstat (limited to 'runtime/js/01_web_util.js')
-rw-r--r--runtime/js/01_web_util.js60
1 files changed, 0 insertions, 60 deletions
diff --git a/runtime/js/01_web_util.js b/runtime/js/01_web_util.js
index 5960691eb..11294a9bb 100644
--- a/runtime/js/01_web_util.js
+++ b/runtime/js/01_web_util.js
@@ -17,65 +17,6 @@
}
}
- const objectCloneMemo = new WeakMap();
-
- function cloneArrayBuffer(
- srcBuffer,
- srcByteOffset,
- srcLength,
- _cloneConstructor,
- ) {
- // this function fudges the return type but SharedArrayBuffer is disabled for a while anyway
- return srcBuffer.slice(
- srcByteOffset,
- srcByteOffset + srcLength,
- );
- }
-
- /** Clone a value in a similar way to structured cloning. It is similar to a
- * StructureDeserialize(StructuredSerialize(...)). */
- function cloneValue(value) {
- // Performance optimization for buffers, otherwise
- // `serialize/deserialize` will allocate new buffer.
- if (value instanceof ArrayBuffer) {
- const cloned = cloneArrayBuffer(
- value,
- 0,
- value.byteLength,
- ArrayBuffer,
- );
- objectCloneMemo.set(value, cloned);
- return cloned;
- }
- if (ArrayBuffer.isView(value)) {
- const clonedBuffer = cloneValue(value.buffer);
- // Use DataViewConstructor type purely for type-checking, can be a
- // DataView or TypedArray. They use the same constructor signature,
- // only DataView has a length in bytes and TypedArrays use a length in
- // terms of elements, so we adjust for that.
- let length;
- if (value instanceof DataView) {
- length = value.byteLength;
- } else {
- length = value.length;
- }
- return new (value.constructor)(
- clonedBuffer,
- value.byteOffset,
- length,
- );
- }
-
- try {
- return Deno.core.deserialize(Deno.core.serialize(value));
- } catch (e) {
- if (e instanceof TypeError) {
- throw new DOMException("Uncloneable value", "DataCloneError");
- }
- throw e;
- }
- }
-
const handlerSymbol = Symbol("eventHandlers");
function makeWrappedHandler(handler) {
function wrappedHandler(...args) {
@@ -114,6 +55,5 @@
illegalConstructorKey,
requiredArguments,
defineEventHandler,
- cloneValue,
};
})(this);