File
Blob: src/node/internal/internal_types.ts
| 1 | // Copyright (c) 2017-2022 Cloudflare, Inc. |
| 2 | // Licensed under the Apache 2.0 license found in the LICENSE file or at: |
| 3 | // https://opensource.org/licenses/Apache-2.0 |
| 4 | // |
| 5 | // Adapted from Node.js. Copyright Joyent, Inc. and other Node contributors. |
| 6 | // |
| 7 | // Permission is hereby granted, free of charge, to any person obtaining a |
| 8 | // copy of this software and associated documentation files (the |
| 9 | // "Software"), to deal in the Software without restriction, including |
| 10 | // without limitation the rights to use, copy, modify, merge, publish, |
| 11 | // distribute, sublicense, and/or sell copies of the Software, and to permit |
| 12 | // persons to whom the Software is furnished to do so, subject to the |
| 13 | // following conditions: |
| 14 | // |
| 15 | // The above copyright notice and this permission notice shall be included |
| 16 | // in all copies or substantial portions of the Software. |
| 17 | // |
| 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 19 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 20 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN |
| 21 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
| 22 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
| 23 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE |
| 24 | // USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 25 | |
| 26 | import internal from 'node-internal:util'; |
| 27 | |
| 28 | import { kHandle } from 'node-internal:crypto_util'; |
| 29 | |
| 30 | export function isCryptoKey(value: unknown): boolean { |
| 31 | return value instanceof CryptoKey; |
| 32 | } |
| 33 | |
| 34 | export function isKeyObject(_value: unknown): boolean { |
| 35 | return _value != null && typeof _value === 'object' && kHandle in _value; |
| 36 | } |
| 37 | |
| 38 | export const isAsyncFunction = internal.isAsyncFunction.bind(internal); |
| 39 | export const isGeneratorFunction = internal.isGeneratorFunction.bind(internal); |
| 40 | export const isGeneratorObject = internal.isGeneratorObject.bind(internal); |
| 41 | export const isAnyArrayBuffer = internal.isAnyArrayBuffer.bind(internal); |
| 42 | export const isArrayBuffer = internal.isArrayBuffer.bind(internal); |
| 43 | export const isArgumentsObject = internal.isArgumentsObject.bind(internal); |
| 44 | export const isBoxedPrimitive = internal.isBoxedPrimitive.bind(internal); |
| 45 | export const isDataView = internal.isDataView.bind(internal); |
| 46 | export const isExternal = internal.isExternal.bind(internal); |
| 47 | export const isMap = internal.isMap.bind(internal); |
| 48 | export const isMapIterator = internal.isMapIterator.bind(internal); |
| 49 | export const isModuleNamespaceObject = |
| 50 | internal.isModuleNamespaceObject.bind(internal); |
| 51 | export const isNativeError = internal.isNativeError.bind(internal); |
| 52 | export const isPromise = internal.isPromise.bind(internal); |
| 53 | export const isProxy = internal.isProxy.bind(internal); |
| 54 | export const isSet = internal.isSet.bind(internal); |
| 55 | export const isSetIterator = internal.isSetIterator.bind(internal); |
| 56 | export const isSharedArrayBuffer = internal.isSharedArrayBuffer.bind(internal); |
| 57 | export const isWeakMap = internal.isWeakMap.bind(internal); |
| 58 | export const isWeakSet = internal.isWeakSet.bind(internal); |
| 59 | export const isRegExp = internal.isRegExp.bind(internal); |
| 60 | export const isDate = internal.isDate.bind(internal); |
| 61 | export const isStringObject = internal.isStringObject.bind(internal); |
| 62 | export const isSymbolObject = internal.isSymbolObject.bind(internal); |
| 63 | export const isNumberObject = internal.isNumberObject.bind(internal); |
| 64 | export const isBooleanObject = internal.isBooleanObject.bind(internal); |
| 65 | export const isBigIntObject = internal.isBigIntObject.bind(internal); |
| 66 | export const isArrayBufferView = internal.isArrayBufferView.bind(internal); |
| 67 | export const isBigInt64Array = internal.isBigInt64Array.bind(internal); |
| 68 | export const isBigUint64Array = internal.isBigUint64Array.bind(internal); |
| 69 | export const isFloat16Array = internal.isFloat16Array.bind(internal); |
| 70 | export const isFloat32Array = internal.isFloat32Array.bind(internal); |
| 71 | export const isFloat64Array = internal.isFloat64Array.bind(internal); |
| 72 | export const isInt8Array = internal.isInt8Array.bind(internal); |
| 73 | export const isInt16Array = internal.isInt16Array.bind(internal); |
| 74 | export const isInt32Array = internal.isInt32Array.bind(internal); |
| 75 | export const isTypedArray = internal.isTypedArray.bind(internal); |
| 76 | export const isUint8Array = internal.isUint8Array.bind(internal); |
| 77 | export const isUint8ClampedArray = internal.isUint8ClampedArray.bind(internal); |
| 78 | export const isUint16Array = internal.isUint16Array.bind(internal); |
| 79 | export const isUint32Array = internal.isUint32Array.bind(internal); |
| 80 | |
| 81 | export default { |
| 82 | isCryptoKey, |
| 83 | isKeyObject, |
| 84 | |
| 85 | isAsyncFunction, |
| 86 | isGeneratorFunction, |
| 87 | isGeneratorObject, |
| 88 | isAnyArrayBuffer, |
| 89 | isArrayBuffer, |
| 90 | isArgumentsObject, |
| 91 | isBoxedPrimitive, |
| 92 | isDataView, |
| 93 | isMap, |
| 94 | isMapIterator, |
| 95 | isModuleNamespaceObject, |
| 96 | isNativeError, |
| 97 | isPromise, |
| 98 | isProxy, |
| 99 | isSet, |
| 100 | isSetIterator, |
| 101 | isSharedArrayBuffer, |
| 102 | isWeakMap, |
| 103 | isWeakSet, |
| 104 | isRegExp, |
| 105 | isDate, |
| 106 | isStringObject, |
| 107 | isSymbolObject, |
| 108 | isNumberObject, |
| 109 | isBooleanObject, |
| 110 | isBigIntObject, |
| 111 | isArrayBufferView, |
| 112 | isBigInt64Array, |
| 113 | isBigUint64Array, |
| 114 | isFloat16Array, |
| 115 | isFloat32Array, |
| 116 | isFloat64Array, |
| 117 | isInt8Array, |
| 118 | isInt16Array, |
| 119 | isInt32Array, |
| 120 | isTypedArray, |
| 121 | isUint8Array, |
| 122 | isUint8ClampedArray, |
| 123 | isUint16Array, |
| 124 | isUint32Array, |
| 125 | isExternal, |
| 126 | }; |