summaryrefslogtreecommitdiff
path: root/cli/js/util.ts
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2020-03-11 15:49:53 +0100
committerGitHub <noreply@github.com>2020-03-11 15:49:53 +0100
commit2d1b39bef339edb19ae6be5fb2099e685cee93bb (patch)
tree4e1664f50e079e2f258d86cb0e4a1160fb6b3d7b /cli/js/util.ts
parent99a0c6df79b903e4fe72ce066787039bdede3868 (diff)
reorg: remove dispatch.ts, move signals, factor out web utils (#4316)
- moves signal definition from "cli/js/process.ts" to "cli/js/signals.ts" - removes "cli/js/dispatch.ts" - removes "cli/js/types.ts" - moves web specific utilities to "cli/js/web/util.ts"
Diffstat (limited to 'cli/js/util.ts')
-rw-r--r--cli/js/util.ts67
1 files changed, 0 insertions, 67 deletions
diff --git a/cli/js/util.ts b/cli/js/util.ts
index 9f0373721..3c67fa7f1 100644
--- a/cli/js/util.ts
+++ b/cli/js/util.ts
@@ -1,5 +1,4 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-import { TypedArray } from "./types.ts";
let logDebug = false;
let logSource = "JS";
@@ -81,30 +80,6 @@ export function notImplemented(): never {
}
// @internal
-export function unreachable(): never {
- throw new Error("Code not reachable");
-}
-
-const TypedArrayConstructor = Object.getPrototypeOf(Uint8Array);
-export function isTypedArray(x: unknown): x is TypedArray {
- return x instanceof TypedArrayConstructor;
-}
-
-// @internal
-export function requiredArguments(
- name: string,
- length: number,
- required: number
-): void {
- if (length < required) {
- const errMsg = `${name} requires at least ${required} argument${
- required === 1 ? "" : "s"
- }, but only ${length} present`;
- throw new TypeError(errMsg);
- }
-}
-
-// @internal
export function immutableDefine(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
o: any,
@@ -118,45 +93,3 @@ export function immutableDefine(
writable: false
});
}
-
-// Returns values from a WeakMap to emulate private properties in JavaScript
-export function getPrivateValue<
- K extends object,
- V extends object,
- W extends keyof V
->(instance: K, weakMap: WeakMap<K, V>, key: W): V[W] {
- if (weakMap.has(instance)) {
- return weakMap.get(instance)![key];
- }
- throw new TypeError("Illegal invocation");
-}
-
-/**
- * Determines whether an object has a property with the specified name.
- * Avoid calling prototype builtin `hasOwnProperty` for two reasons:
- *
- * 1. `hasOwnProperty` is defined on the object as something else:
- *
- * const options = {
- * ending: 'utf8',
- * hasOwnProperty: 'foo'
- * };
- * options.hasOwnProperty('ending') // throws a TypeError
- *
- * 2. The object doesn't inherit from `Object.prototype`:
- *
- * const options = Object.create(null);
- * options.ending = 'utf8';
- * options.hasOwnProperty('ending'); // throws a TypeError
- *
- * @param obj A Object.
- * @param v A property name.
- * @see https://eslint.org/docs/rules/no-prototype-builtins
- * @internal
- */
-export function hasOwnProperty<T>(obj: T, v: PropertyKey): boolean {
- if (obj == null) {
- return false;
- }
- return Object.prototype.hasOwnProperty.call(obj, v);
-}