diff options
Diffstat (limited to 'ext/node/polyfills/internal')
-rw-r--r-- | ext/node/polyfills/internal/blob.mjs | 7 | ||||
-rw-r--r-- | ext/node/polyfills/internal/crypto/types.ts | 46 | ||||
-rw-r--r-- | ext/node/polyfills/internal/freelist.ts | 30 | ||||
-rw-r--r-- | ext/node/polyfills/internal/streams/legacy.mjs | 113 |
4 files changed, 0 insertions, 196 deletions
diff --git a/ext/node/polyfills/internal/blob.mjs b/ext/node/polyfills/internal/blob.mjs deleted file mode 100644 index 1b685fad4..000000000 --- a/ext/node/polyfills/internal/blob.mjs +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. -// Node's implementation checks for a symbol they put in the blob prototype -// Since the implementation of Blob is Deno's, the only option is to check the -// objects constructor -export function isBlob(object) { - return object instanceof Blob; -} diff --git a/ext/node/polyfills/internal/crypto/types.ts b/ext/node/polyfills/internal/crypto/types.ts deleted file mode 100644 index 3231d378e..000000000 --- a/ext/node/polyfills/internal/crypto/types.ts +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. -// Copyright Joyent, Inc. and Node.js contributors. All rights reserved. MIT license. - -import { Buffer } from "internal:deno_node/buffer.ts"; - -export type HASH_DATA = string | ArrayBufferView | Buffer; - -export type BinaryToTextEncoding = "base64" | "base64url" | "hex" | "binary"; - -export type CharacterEncoding = "utf8" | "utf-8" | "utf16le" | "latin1"; - -export type LegacyCharacterEncoding = "ascii" | "binary" | "ucs2" | "ucs-2"; - -export type Encoding = - | BinaryToTextEncoding - | CharacterEncoding - | LegacyCharacterEncoding; - -export type ECDHKeyFormat = "compressed" | "uncompressed" | "hybrid"; - -export type BinaryLike = string | ArrayBufferView; - -export type KeyFormat = "pem" | "der"; - -export type KeyType = - | "rsa" - | "rsa-pss" - | "dsa" - | "ec" - | "ed25519" - | "ed448" - | "x25519" - | "x448"; - -export interface PrivateKeyInput { - key: string | Buffer; - format?: KeyFormat | undefined; - type?: "pkcs1" | "pkcs8" | "sec1" | undefined; - passphrase?: string | Buffer | undefined; -} - -export interface PublicKeyInput { - key: string | Buffer; - format?: KeyFormat | undefined; - type?: "pkcs1" | "spki" | undefined; -} diff --git a/ext/node/polyfills/internal/freelist.ts b/ext/node/polyfills/internal/freelist.ts deleted file mode 100644 index 8faba8e68..000000000 --- a/ext/node/polyfills/internal/freelist.ts +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. -// Copyright Joyent and Node contributors. All rights reserved. MIT license. - -type Fn<T> = (...args: unknown[]) => T; -export class FreeList<T> { - name: string; - ctor: Fn<T>; - max: number; - list: Array<T>; - constructor(name: string, max: number, ctor: Fn<T>) { - this.name = name; - this.ctor = ctor; - this.max = max; - this.list = []; - } - - alloc(): T { - return this.list.length > 0 - ? this.list.pop() - : Reflect.apply(this.ctor, this, arguments); - } - - free(obj: T) { - if (this.list.length < this.max) { - this.list.push(obj); - return true; - } - return false; - } -} diff --git a/ext/node/polyfills/internal/streams/legacy.mjs b/ext/node/polyfills/internal/streams/legacy.mjs deleted file mode 100644 index bb2d30bc4..000000000 --- a/ext/node/polyfills/internal/streams/legacy.mjs +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. -// Copyright Joyent and Node contributors. All rights reserved. MIT license. -// deno-lint-ignore-file - -import EE from "internal:deno_node/events.ts"; - -function Stream(opts) { - EE.call(this, opts); -} -Object.setPrototypeOf(Stream.prototype, EE.prototype); -Object.setPrototypeOf(Stream, EE); - -Stream.prototype.pipe = function (dest, options) { - // deno-lint-ignore no-this-alias - const source = this; - - function ondata(chunk) { - if (dest.writable && dest.write(chunk) === false && source.pause) { - source.pause(); - } - } - - source.on("data", ondata); - - function ondrain() { - if (source.readable && source.resume) { - source.resume(); - } - } - - dest.on("drain", ondrain); - - // If the 'end' option is not supplied, dest.end() will be called when - // source gets the 'end' or 'close' events. Only dest.end() once. - if (!dest._isStdio && (!options || options.end !== false)) { - source.on("end", onend); - source.on("close", onclose); - } - - let didOnEnd = false; - function onend() { - if (didOnEnd) return; - didOnEnd = true; - - dest.end(); - } - - function onclose() { - if (didOnEnd) return; - didOnEnd = true; - - if (typeof dest.destroy === "function") dest.destroy(); - } - - // Don't leave dangling pipes when there are errors. - function onerror(er) { - cleanup(); - if (EE.listenerCount(this, "error") === 0) { - this.emit("error", er); - } - } - - prependListener(source, "error", onerror); - prependListener(dest, "error", onerror); - - // Remove all the event listeners that were added. - function cleanup() { - source.removeListener("data", ondata); - dest.removeListener("drain", ondrain); - - source.removeListener("end", onend); - source.removeListener("close", onclose); - - source.removeListener("error", onerror); - dest.removeListener("error", onerror); - - source.removeListener("end", cleanup); - source.removeListener("close", cleanup); - - dest.removeListener("close", cleanup); - } - - source.on("end", cleanup); - source.on("close", cleanup); - - dest.on("close", cleanup); - dest.emit("pipe", source); - - // Allow for unix-like usage: A.pipe(B).pipe(C) - return dest; -}; - -function prependListener(emitter, event, fn) { - // Sadly this is not cacheable as some libraries bundle their own - // event emitter implementation with them. - if (typeof emitter.prependListener === "function") { - return emitter.prependListener(event, fn); - } - - // This is a hack to make sure that our error handler is attached before any - // userland ones. NEVER DO THIS. This is here only because this code needs - // to continue to work with older versions of Node.js that do not include - // the prependListener() method. The goal is to eventually remove this hack. - if (!emitter._events || !emitter._events[event]) { - emitter.on(event, fn); - } else if (Array.isArray(emitter._events[event])) { - emitter._events[event].unshift(fn); - } else { - emitter._events[event] = [fn, emitter._events[event]]; - } -} - -export { prependListener, Stream }; |