UNPKG

@stdlib/assert

Version:

Standard assertion utilities.

1,555 lines (1,487 loc) 188 kB
/* * @license Apache-2.0 * * Copyright (c) 2021 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // TypeScript Version: 4.1 /* eslint-disable max-lines */ import contains = require( './../../contains' ); import deepEqual = require( './../../deep-equal' ); import deepHasOwnProp = require( './../../deep-has-own-property' ); import deepHasProp = require( './../../deep-has-property' ); import hasArrayBufferSupport = require( './../../has-arraybuffer-support' ); import hasArrowFunctionSupport = require( './../../has-arrow-function-support' ); import hasAsyncAwaitSupport = require( './../../has-async-await-support' ); import hasAsyncIteratorSymbolSupport = require( './../../has-async-iterator-symbol-support' ); import hasBigIntSupport = require( './../../has-bigint-support' ); import hasBigInt64ArraySupport = require( './../../has-bigint64array-support' ); import hasBigUint64ArraySupport = require( './../../has-biguint64array-support' ); import hasClassSupport = require( './../../has-class-support' ); import hasDataViewSupport = require( './../../has-dataview-support' ); import hasDefinePropertiesSupport = require( './../../has-define-properties-support' ); import hasDefinePropertySupport = require( './../../has-define-property-support' ); import hasFloat32ArraySupport = require( './../../has-float32array-support' ); import hasFloat64ArraySupport = require( './../../has-float64array-support' ); import hasFunctionNameSupport = require( './../../has-function-name-support' ); import hasGeneratorSupport = require( './../../has-generator-support' ); import hasGlobalThisSupport = require( './../../has-globalthis-support' ); import hasInt8ArraySupport = require( './../../has-int8array-support' ); import hasInt16ArraySupport = require( './../../has-int16array-support' ); import hasInt32ArraySupport = require( './../../has-int32array-support' ); import hasIteratorSymbolSupport = require( './../../has-iterator-symbol-support' ); import hasMapSupport = require( './../../has-map-support' ); import hasNodeBufferSupport = require( './../../has-node-buffer-support' ); import hasOwnProp = require( './../../has-own-property' ); import hasProp = require( './../../has-property' ); import hasProxySupport = require( './../../has-proxy-support' ); import hasSetSupport = require( './../../has-set-support' ); import hasSharedArrayBufferSupport = require( './../../has-sharedarraybuffer-support' ); import hasSymbolSupport = require( './../../has-symbol-support' ); import hasToStringTagSupport = require( './../../has-tostringtag-support' ); import hasUint8ArraySupport = require( './../../has-uint8array-support' ); import hasUint8ClampedArraySupport = require( './../../has-uint8clampedarray-support' ); import hasUint16ArraySupport = require( './../../has-uint16array-support' ); import hasUint32ArraySupport = require( './../../has-uint32array-support' ); import hasUTF16SurrogatePairAt = require( './../../has-utf16-surrogate-pair-at' ); import hasWebAssemblySupport = require( './../../has-wasm-support' ); import hasWeakMapSupport = require( './../../has-weakmap-support' ); import hasWeakSetSupport = require( './../../has-weakset-support' ); import instanceOf = require( './../../instance-of' ); import isAbsoluteHttpURI = require( './../../is-absolute-http-uri' ); import isAbsolutePath = require( './../../is-absolute-path' ); import isAbsoluteURI = require( './../../is-absolute-uri' ); import isAccessorArray = require( './../../is-accessor-array' ); import isAccessorProperty = require( './../../is-accessor-property' ); import isAccessorPropertyIn = require( './../../is-accessor-property-in' ); import isAlphagram = require( './../../is-alphagram' ); import isAlphaNumeric = require( './../../is-alphanumeric' ); import isAnagram = require( './../../is-anagram' ); import isArguments = require( './../../is-arguments' ); import isArray = require( './../../is-array' ); import isArrayArray = require( './../../is-array-array' ); import isArrayLength = require( './../../is-array-length' ); import isArrayLike = require( './../../is-array-like' ); import isArrayLikeObject = require( './../../is-array-like-object' ); import isArrayBuffer = require( './../../is-arraybuffer' ); import isArrayBufferView = require( './../../is-arraybuffer-view' ); import isArrowFunction = require( './../../is-arrow-function' ); import isASCII = require( './../../is-ascii' ); import isBetween = require( './../../is-between' ); import isBetweenArray = require( './../../is-between-array' ); import IS_BIG_ENDIAN = require( './../../is-big-endian' ); import isBigInt = require( './../../is-bigint' ); import isBigInt64Array = require( './../../is-bigint64array' ); import isBigUint64Array = require( './../../is-biguint64array' ); import isBinaryString = require( './../../is-binary-string' ); import isBlankString = require( './../../is-blank-string' ); import isBoolean = require( './../../is-boolean' ); import isBooleanArray = require( './../../is-boolean-array' ); import isBoxedPrimitive = require( './../../is-boxed-primitive' ); import IS_BROWSER = require( './../../is-browser' ); import isBuffer = require( './../../is-buffer' ); import isCamelcase = require( './../../is-camelcase' ); import isCapitalized = require( './../../is-capitalized' ); import isCentrosymmetricMatrix = require( './../../is-centrosymmetric-matrix' ); import isCircular = require( './../../is-circular' ); import isCircularArray = require( './../../is-circular-array' ); import isCircularPlainObject = require( './../../is-circular-plain-object' ); import isClass = require( './../../is-class' ); import isCollection = require( './../../is-collection' ); import isComplex = require( './../../is-complex' ); import isComplexLike = require( './../../is-complex-like' ); import isComplexTypedArray = require( './../../is-complex-typed-array' ); import isComplexTypedArrayLike = require( './../../is-complex-typed-array-like' ); import isComplex64 = require( './../../is-complex64' ); import isComplex64Array = require( './../../is-complex64array' ); import isComplex64MatrixLike = require( './../../is-complex64matrix-like' ); import isComplex64ndarrayLike = require( './../../is-complex64ndarray-like' ); import isComplex64VectorLike = require( './../../is-complex64vector-like' ); import isComplex128 = require( './../../is-complex128' ); import isComplex128Array = require( './../../is-complex128array' ); import isComplex128MatrixLike = require( './../../is-complex128matrix-like' ); import isComplex128ndarrayLike = require( './../../is-complex128ndarray-like' ); import isComplex128VectorLike = require( './../../is-complex128vector-like' ); import isComposite = require( './../../is-composite' ); import isConfigurableProperty = require( './../../is-configurable-property' ); import isConfigurablePropertyIn = require( './../../is-configurable-property-in' ); import isConstantcase = require( './../../is-constantcase' ); import isCubeNumber = require( './../../is-cube-number' ); import isCurrentYear = require( './../../is-current-year' ); import IS_DARWIN = require( './../../is-darwin' ); import isDataProperty = require( './../../is-data-property' ); import isDataPropertyIn = require( './../../is-data-property-in' ); import isDataView = require( './../../is-dataview' ); import isDateObject = require( './../../is-date-object' ); import isDateObjectArray = require( './../../is-date-object-array' ); import isDigitString = require( './../../is-digit-string' ); import IS_DOCKER = require( './../../is-docker' ); import isDomainName = require( './../../is-domain-name' ); import isDurationString = require( './../../is-duration-string' ); import IS_ELECTRON = require( './../../is-electron' ); import IS_ELECTRON_MAIN = require( './../../is-electron-main' ); import IS_ELECTRON_RENDERER = require( './../../is-electron-renderer' ); import isEmailAddress = require( './../../is-email-address' ); import isEmptyArray = require( './../../is-empty-array' ); import isEmptyArrayLikeObject = require( './../../is-empty-array-like-object' ); import isEmptyCollection = require( './../../is-empty-collection' ); import isEmptyObject = require( './../../is-empty-object' ); import isEmptyString = require( './../../is-empty-string' ); import isEnumerableProperty = require( './../../is-enumerable-property' ); import isEnumerablePropertyIn = require( './../../is-enumerable-property-in' ); import isError = require( './../../is-error' ); import isEvalError = require( './../../is-eval-error' ); import isEven = require( './../../is-even' ); import isFalsy = require( './../../is-falsy' ); import isFalsyArray = require( './../../is-falsy-array' ); import isFinite = require( './../../is-finite' ); import isFiniteArray = require( './../../is-finite-array' ); import isFloat32Array = require( './../../is-float32array' ); import isFloat32MatrixLike = require( './../../is-float32matrix-like' ); import isFloat32ndarrayLike = require( './../../is-float32ndarray-like' ); import isFloat32VectorLike = require( './../../is-float32vector-like' ); import isFloat64Array = require( './../../is-float64array' ); import isFloat64MatrixLike = require( './../../is-float64matrix-like' ); import isFloat64ndarrayLike = require( './../../is-float64ndarray-like' ); import isFloat64VectorLike = require( './../../is-float64vector-like' ); import isFunction = require( './../../is-function' ); import isFunctionArray = require( './../../is-function-array' ); import isGeneratorObject = require( './../../is-generator-object' ); import isGeneratorObjectLike = require( './../../is-generator-object-like' ); import isgzipBuffer = require( './../../is-gzip-buffer' ); import isHexString = require( './../../is-hex-string' ); import isInfinite = require( './../../is-infinite' ); import isInheritedProperty = require( './../../is-inherited-property' ); import isInt8Array = require( './../../is-int8array' ); import isInt16Array = require( './../../is-int16array' ); import isInt32Array = require( './../../is-int32array' ); import isInteger = require( './../../is-integer' ); import isIntegerArray = require( './../../is-integer-array' ); import isIterableLike = require( './../../is-iterable-like' ); import isIteratorLike = require( './../../is-iterator-like' ); import isJSON = require( './../../is-json' ); import isKebabcase = require( './../../is-kebabcase' ); import isLeapYear = require( './../../is-leap-year' ); import IS_LITTLE_ENDIAN = require( './../../is-little-endian' ); import isLocalhost = require( './../../is-localhost' ); import isLowercase = require( './../../is-lowercase' ); import isMatrixLike = require( './../../is-matrix-like' ); import isMethod = require( './../../is-method' ); import isMethodIn = require( './../../is-method-in' ); import IS_MOBILE = require( './../../is-mobile' ); import isMultiSlice = require( './../../is-multi-slice' ); import isNamedTypedTupleLike = require( './../../is-named-typed-tuple-like' ); import isnan = require( './../../is-nan' ); import isNaNArray = require( './../../is-nan-array' ); import isNativeFunction = require( './../../is-native-function' ); import isndarrayLike = require( './../../is-ndarray-like' ); import isNegativeInteger = require( './../../is-negative-integer' ); import isNegativeIntegerArray = require( './../../is-negative-integer-array' ); import isNegativeNumber = require( './../../is-negative-number' ); import isNegativeNumberArray = require( './../../is-negative-number-array' ); import isNegativeZero = require( './../../is-negative-zero' ); import IS_NODE = require( './../../is-node' ); import isNodeBuiltin = require( './../../is-node-builtin' ); import isNodeDuplexStreamLike = require( './../../is-node-duplex-stream-like' ); import isNodeReadableStreamLike = require( './../../is-node-readable-stream-like' ); import isNodeREPL = require( './../../is-node-repl' ); import isNodeStreamLike = require( './../../is-node-stream-like' ); import isNodeTransformStreamLike = require( './../../is-node-transform-stream-like' ); import isNodeWritableStreamLike = require( './../../is-node-writable-stream-like' ); import isNonConfigurableProperty = require( './../../is-nonconfigurable-property' ); import isNonConfigurablePropertyIn = require( './../../is-nonconfigurable-property-in' ); import isNonEnumerableProperty = require( './../../is-nonenumerable-property' ); import isNonEnumerablePropertyIn = require( './../../is-nonenumerable-property-in' ); import isNonNegativeFinite = require( './../../is-nonnegative-finite' ); import isNonNegativeInteger = require( './../../is-nonnegative-integer' ); import isNonNegativeIntegerArray = require( './../../is-nonnegative-integer-array' ); import isNonNegativeNumber = require( './../../is-nonnegative-number' ); import isNonNegativeNumberArray = require( './../../is-nonnegative-number-array' ); import isNonPositiveInteger = require( './../../is-nonpositive-integer' ); import isNonPositiveIntegerArray = require( './../../is-nonpositive-integer-array' ); import isNonPositiveNumber = require( './../../is-nonpositive-number' ); import isNonPositiveNumberArray = require( './../../is-nonpositive-number-array' ); import isNonSymmetricMatrix = require( './../../is-nonsymmetric-matrix' ); import isNull = require( './../../is-null' ); import isNullArray = require( './../../is-null-array' ); import isNumber = require( './../../is-number' ); import isNumberArray = require( './../../is-number-array' ); import isNumericArray = require( './../../is-numeric-array' ); import isObject = require( './../../is-object' ); import isObjectArray = require( './../../is-object-array' ); import isObjectLike = require( './../../is-object-like' ); import isOdd = require( './../../is-odd' ); import isPascalcase = require( './../../is-pascalcase' ); import isPersymmetricMatrix = require( './../../is-persymmetric-matrix' ); import isPlainObject = require( './../../is-plain-object' ); import isPlainObjectArray = require( './../../is-plain-object-array' ); import isPositiveInteger = require( './../../is-positive-integer' ); import isPositiveIntegerArray = require( './../../is-positive-integer-array' ); import isPositiveNumber = require( './../../is-positive-number' ); import isPositiveNumberArray = require( './../../is-positive-number-array' ); import isPositiveZero = require( './../../is-positive-zero' ); import isPrime = require( './../../is-prime' ); import isPrimitive = require( './../../is-primitive' ); import isPrimitiveArray = require( './../../is-primitive-array' ); import isPRNGLike = require( './../../is-prng-like' ); import isProbability = require( './../../is-probability' ); import isProbabilityArray = require( './../../is-probability-array' ); import isPropertyKey = require( './../../is-property-key' ); import isPrototypeOf = require( './../../is-prototype-of' ); import isRangeError = require( './../../is-range-error' ); import isReadOnlyProperty = require( './../../is-read-only-property' ); import isReadOnlyPropertyIn = require( './../../is-read-only-property-in' ); import isReadWriteProperty = require( './../../is-read-write-property' ); import isReadWritePropertyIn = require( './../../is-read-write-property-in' ); import isReadableProperty = require( './../../is-readable-property' ); import isReadablePropertyIn = require( './../../is-readable-property-in' ); import isReferenceError = require( './../../is-reference-error' ); import isRegExp = require( './../../is-regexp' ); import isRegExpString = require( './../../is-regexp-string' ); import isRelativePath = require( './../../is-relative-path' ); import isRelativeURI = require( './../../is-relative-uri' ); import isSafeInteger = require( './../../is-safe-integer' ); import isSafeIntegerArray = require( './../../is-safe-integer-array' ); import isSameArray = require( './../../is-same-array' ); import isSameComplex64 = require( './../../is-same-complex64' ); import isSameComplex64Array = require( './../../is-same-complex64array' ); import isSameComplex128 = require( './../../is-same-complex128' ); import isSameComplex128Array = require( './../../is-same-complex128array' ); import isSameFloat32Array = require( './../../is-same-float32array' ); import isSameFloat64Array = require( './../../is-same-float64array' ); import isSameNativeClass = require( './../../is-same-native-class' ); import isSameType = require( './../../is-same-type' ); import isSameValue = require( './../../is-same-value' ); import isSameValueZero = require( './../../is-same-value-zero' ); import isSemVer = require( './../../is-semver' ); import isSharedArrayBuffer = require( './../../is-sharedarraybuffer' ); import isSkewCentrosymmetricMatrix = require( './../../is-skew-centrosymmetric-matrix' ); import isSkewPersymmetricMatrix = require( './../../is-skew-persymmetric-matrix' ); import isSkewSymmetricMatrix = require( './../../is-skew-symmetric-matrix' ); import isSlice = require( './../../is-slice' ); import isSnakecase = require( './../../is-snakecase' ); import isSquareMatrix = require( './../../is-square-matrix' ); import isSquareNumber = require( './../../is-square-number' ); import isSquareTriangularNumber = require( './../../is-square-triangular-number' ); import isStartcase = require( './../../is-startcase' ); import isStrictEqual = require( './../../is-strict-equal' ); import isString = require( './../../is-string' ); import isStringArray = require( './../../is-string-array' ); import isSymbol = require( './../../is-symbol' ); import isSymbolArray = require( './../../is-symbol-array' ); import isSymmetricMatrix = require( './../../is-symmetric-matrix' ); import isSyntaxError = require( './../../is-syntax-error' ); import IS_TOUCH_DEVICE = require( './../../is-touch-device' ); import isTriangularNumber = require( './../../is-triangular-number' ); import isTruthy = require( './../../is-truthy' ); import isTruthyArray = require( './../../is-truthy-array' ); import isTypeError = require( './../../is-type-error' ); import isTypedArray = require( './../../is-typed-array' ); import isTypedArrayLength = require( './../../is-typed-array-length' ); import isTypedArrayLike = require( './../../is-typed-array-like' ); import isUint8Array = require( './../../is-uint8array' ); import isUint8ClampedArray = require( './../../is-uint8clampedarray' ); import isUint16Array = require( './../../is-uint16array' ); import isUint32Array = require( './../../is-uint32array' ); import isUNCPath = require( './../../is-unc-path' ); import isUndefined = require( './../../is-undefined' ); import isUndefinedOrNull = require( './../../is-undefined-or-null' ); import isUnityProbabilityArray = require( './../../is-unity-probability-array' ); import isUppercase = require( './../../is-uppercase' ); import isURI = require( './../../is-uri' ); import isURIError = require( './../../is-uri-error' ); import isVectorLike = require( './../../is-vector-like' ); import IS_WEB_WORKER = require( './../../is-web-worker' ); import isWhitespace = require( './../../is-whitespace' ); import IS_WINDOWS = require( './../../is-windows' ); import isWritableProperty = require( './../../is-writable-property' ); import isWritablePropertyIn = require( './../../is-writable-property-in' ); import isWriteOnlyProperty = require( './../../is-write-only-property' ); import isWriteOnlyPropertyIn = require( './../../is-write-only-property-in' ); import tools = require( './../../tools' ); /** * Interface describing the `assert` namespace. */ interface Namespace { /** * Tests if an array-like value contains a search value. * * ## Notes * * - When `val` is a string, the function checks whether the characters of the search string are found in the input string. The search is case-sensitive. * - When `val` is an array-like object, the function checks whether the input array contains an element strictly equal to the specified search value. * - For strings, this function is modeled after `String.prototype.includes`, part of the ECMAScript 6 specification. This function is different from a call to `String.prototype.includes.call` insofar as type-checking is performed for all arguments. * - The function does not distinguish between positive and negative zero. * - If `position < 0`, the search is performed for the entire input array or string. * * @param val - input value * @param searchValue - search value * @param position - position at which to start searching for `searchValue` (default: 0) * @throws second argument must be a primitive string primitive when the first argument is a string * @returns boolean indicating whether one value contains another * * @example * var bool = ns.contains( 'last man standing', 'stand' ); * // returns true * * @example * var bool = ns.contains( [ 1, 2, 3, 4 ], 2 ); * // returns true * * @example * var bool = ns.contains( 'presidential election', 'president' ); * // returns true * * @example * var bool = ns.contains( [ NaN, 2, 3, 4 ], NaN ); * // returns true * * @example * var bool = ns.contains( 'javaScript', 'js' ); * // returns false * * @example * var bool = ns.contains( [ 1, 2, 3, {} ], {} ); * // returns false * * @example * var bool = ns.contains( 'Hidden Treasures', '' ); * // returns true */ contains: typeof contains; /** * Tests for deep equality between two values. * * @param a - first comparison value * @param b - second comparison value * @returns boolean indicating if `a` is deep equal to `b` * * @example * var bool = ns.deepEqual( [ 1, 2, 3 ], [ 1, 2, 3 ] ); * // returns true * * @example * var bool = ns.deepEqual( [ 1, 2, 3 ], [ 1, 2, '3' ] ); * // returns false * * @example * var bool = ns.deepEqual( { 'a': 2 }, { 'a': [ 2 ] } ); * // returns false * * @example * var bool = ns.deepEqual( [], {} ); * // returns false * * @example * var bool = ns.deepEqual( null, null ); * // returns true */ deepEqual: typeof deepEqual; /** * Tests whether an object contains a nested key path. * * @param value - value to test * @param path - key path * @param options - function options * @param options.sep - key path separator (default: '.') * @throws must provide valid options * @returns boolean indicating whether an object has a nested property * * @example * var obj = { 'a': { 'b': { 'c': 'd' } } }; * var bool = ns.deepHasOwnProp( obj, 'a.b.c' ); * // returns true * * @example * var arr = [ * { * 'a': [ * { * 'b': [ * { 'c': 'd' }, * { 'e': 'f' } * ] * } * ] * } * ]; * var bool = ns.deepHasOwnProp( arr, '0.a.0.b.0.c' ); * // returns true * * @example * var obj = { 'a': { 'b': { 'c': 'd' } } }; * var bool = ns.deepHasOwnProp( obj, [ 'a', 'b', 'c' ] ); * // returns true * * @example * var obj = { 'a': { 'b': { 'c': 'd' } } }; * var bool = ns.deepHasOwnProp( obj, 'a/b/c', { * 'sep': '/' * }); * // returns true * * @example * var obj = { 'a': { 'b': { 'c': 'd' } } }; * var has = ns.deepHasOwnProp.factory( 'a/b/c', { * 'sep': '/' * }); * var bool = has( obj ); * // returns true */ deepHasOwnProp: typeof deepHasOwnProp; /** * Tests whether an object contains a nested key path, either own or inherited. * * @param value - value to test * @param path - key path * @param options - function options * @param options.sep - key path separator (default: '.') * @throws must provide valid options * @returns boolean indicating whether an object has a nested property * * @example * function Foo() { * return this; * } * Foo.prototype.b = { * 'c': 'd' * }; * * var obj = { * 'a': new Foo() * }; * * var bool = ns.deepHasProp( obj, 'a.b.c' ); * // returns true * * @example * var arr = [ * { * 'a': [ * { * 'b': [ * { 'c': 'd' }, * { 'e': 'f' } * ] * } * ] * } * ]; * var bool = ns.deepHasProp( arr, '0.a.0.b.0.c' ); * // returns true * * @example * var obj = { 'a': { 'b': { 'c': 'd' } } }; * var bool = ns.deepHasProp( obj, [ 'a', 'b', 'c' ] ); * // returns true * * @example * var obj = { 'a': { 'b': { 'c': 'd' } } }; * var bool = ns.deepHasProp( obj, 'a/b/c', { * 'sep': '/' * }); * // returns true */ deepHasProp: typeof deepHasProp; /** * Tests for native `ArrayBuffer` support. * * @returns boolean indicating if an environment has `ArrayBuffer` support * * @example * var bool = ns.hasArrayBufferSupport(); * // returns <boolean> */ hasArrayBufferSupport: typeof hasArrayBufferSupport; /** * Tests for native arrow function support. * * @returns boolean indicating if an environment has native arrow function support * * @example * var bool = ns.hasArrowFunctionSupport(); * // returns <boolean> */ hasArrowFunctionSupport: typeof hasArrowFunctionSupport; /** * Tests for native `async/await` support. * * @returns boolean indicating if an environment has native `async`/`await` support * * @example * var bool = ns.hasAsyncAwaitSupport(); * if ( bool ) { * console.log( 'Environment has native async/await support.' ); * } else { * console.log( 'Environment lacks native async/await support.' ); * } */ hasAsyncAwaitSupport: typeof hasAsyncAwaitSupport; /** * Tests for native `Symbol.asyncIterator` support. * * @returns boolean indicating if an environment has `Symbol.asyncIterator` support * * @example * var bool = ns.hasAsyncIteratorSymbolSupport(); * // returns <boolean> */ hasAsyncIteratorSymbolSupport: typeof hasAsyncIteratorSymbolSupport; /** * Tests for native `BigInt` support. * * @returns boolean indicating if an environment has `BigInt` support * * @example * var bool = ns.hasBigIntSupport(); * // returns <boolean> */ hasBigIntSupport: typeof hasBigIntSupport; /** * Tests for native `BigInt64Array` support. * * @returns boolean indicating if an environment has `BigInt64Array` support * * @example * var bool = ns.hasBigInt64ArraySupport(); * // returns <boolean> */ hasBigInt64ArraySupport: typeof hasBigInt64ArraySupport; /** * Tests for native `BigUint64Array` support. * * @returns boolean indicating if an environment has `BigUint64Array` support * * @example * var bool = ns.hasBigUint64ArraySupport(); * // returns <boolean> */ hasBigUint64ArraySupport: typeof hasBigUint64ArraySupport; /** * Tests for native `class` support. * * @returns boolean indicating if an environment has native `class` support * * @example * var bool = ns.hasClassSupport(); * if ( bool ) { * console.log( 'Environment has native class support.' ); * } else { * console.log( 'Environment lacks native class support.' ); * } */ hasClassSupport: typeof hasClassSupport; /** * Tests for native `DataView` support. * * @returns boolean indicating if an environment has `DataView` support * * @example * var bool = ns.hasDataViewSupport(); * // returns <boolean> */ hasDataViewSupport: typeof hasDataViewSupport; /** * Tests for `Object.defineProperties` support. * * @returns boolean indicating if an environment has `Object.defineProperties` support * * @example * var bool = ns.hasDefinePropertiesSupport(); * // returns <boolean> */ hasDefinePropertiesSupport: typeof hasDefinePropertiesSupport; /** * Tests for `Object.defineProperty` support. * * @returns boolean indicating if an environment has `Object.defineProperty` support * * @example * var bool = ns.hasDefinePropertySupport(); * // returns <boolean> */ hasDefinePropertySupport: typeof hasDefinePropertySupport; /** * Tests for native `Float32Array` support. * * @returns boolean indicating if an environment has `Float32Array` support * * @example * var bool = ns.hasFloat32ArraySupport(); * // returns <boolean> */ hasFloat32ArraySupport: typeof hasFloat32ArraySupport; /** * Tests for native `Float64Array` support. * * @returns boolean indicating if an environment has `Float64Array` support * * @example * var bool = ns.hasFloat64ArraySupport(); * // returns <boolean> */ hasFloat64ArraySupport: typeof hasFloat64ArraySupport; /** * Tests for native function `name` support. * * @returns boolean indicating if an environment has function `name` support * * @example * var bool = ns.hasFunctionNameSupport(); * // returns <boolean> */ hasFunctionNameSupport: typeof hasFunctionNameSupport; /** * Tests for native `function*()` support. * * @returns boolean indicating if an environment has native `function*()` support * * @example * var bool = ns.hasGeneratorSupport(); * // returns <boolean> */ hasGeneratorSupport: typeof hasGeneratorSupport; /** * Tests for `globalThis` support. * * @returns boolean indicating if an environment has `globalThis` support * * @example * var bool = ns.hasGlobalThisSupport(); * // returns <boolean> */ hasGlobalThisSupport: typeof hasGlobalThisSupport; /** * Tests for native `Int8Array` support. * * @returns boolean indicating if an environment has `Int8Array` support * * @example * var bool = ns.hasInt8ArraySupport(); * // returns <boolean> */ hasInt8ArraySupport: typeof hasInt8ArraySupport; /** * Tests for native `Int16Array` support. * * @returns boolean indicating if an environment has `Int16Array` support * * @example * var bool = ns.hasInt16ArraySupport(); * // returns <boolean> */ hasInt16ArraySupport: typeof hasInt16ArraySupport; /** * Tests for native `Int32Array` support. * * @returns boolean indicating if an environment has `Int32Array` support * * @example * var bool = ns.hasInt32ArraySupport(); * // returns <boolean> */ hasInt32ArraySupport: typeof hasInt32ArraySupport; /** * Tests for native `Symbol.iterator` support. * * @returns boolean indicating if an environment has `Symbol.iterator` support * * @example * var bool = ns.hasIteratorSymbolSupport(); * // returns <boolean> */ hasIteratorSymbolSupport: typeof hasIteratorSymbolSupport; /** * Tests for native `Map` support. * * @returns boolean indicating if an environment has `Map` support * * @example * var bool = ns.hasMapSupport(); * // returns <boolean> */ hasMapSupport: typeof hasMapSupport; /** * Tests for native `Buffer` support. * * @returns boolean indicating if an environment has `Buffer` support * * @example * var bool = ns.hasNodeBufferSupport(); * // returns <boolean> */ hasNodeBufferSupport: typeof hasNodeBufferSupport; /** * Tests if an object has a specified property. * * @param value - value to test * @param property - property to test * @returns boolean indicating if an object has a specified property * * @example * var beep = { * 'boop': true * }; * * var bool = ns.hasOwnProp( beep, 'boop' ); * // returns true * * @example * var beep = { * 'boop': true * }; * * var bool = ns.hasOwnProp( beep, 'bap' ); * // returns false */ hasOwnProp: typeof hasOwnProp; /** * Tests if an object has a specified property, either own or inherited. * * @param value - value to test * @param property - property to test * @returns boolean indicating if an object has a specified property * * @example * var beep = { * 'boop': true * }; * * var bool = ns.hasProp( beep, 'boop' ); * // returns true * * @example * var beep = { * 'boop': true * }; * * var bool = ns.hasProp( beep, 'bap' ); * // returns false */ hasProp: typeof hasProp; /** * Tests for native `Proxy` support. * * @returns boolean indicating if an environment has native `Proxy` support * * @example * var bool = ns.hasProxySupport(); * // returns <boolean> */ hasProxySupport: typeof hasProxySupport; /** * Tests for native `Set` support. * * @returns boolean indicating if an environment has `Set` support * * @example * var bool = ns.hasSetSupport(); * // returns <boolean> */ hasSetSupport: typeof hasSetSupport; /** * Tests for native `SharedArrayBuffer` support. * * @returns boolean indicating if an environment has `SharedArrayBuffer` support * * @example * var bool = ns.hasSharedArrayBufferSupport(); * // returns <boolean> */ hasSharedArrayBufferSupport: typeof hasSharedArrayBufferSupport; /** * Tests for native `Symbol` support. * * @returns boolean indicating if an environment has `Symbol` support * * @example * var bool = ns.hasSymbolSupport(); * // returns <boolean> */ hasSymbolSupport: typeof hasSymbolSupport; /** * Tests for native `toStringTag` support. * * @returns boolean indicating if an environment has `toStringTag` support * * @example * var bool = ns.hasToStringTagSupport(); * // returns <boolean> */ hasToStringTagSupport: typeof hasToStringTagSupport; /** * Tests for native `Uint8Array` support. * * @returns boolean indicating if an environment has `Uint8Array` support * * @example * var bool = ns.hasUint8ArraySupport(); * // returns <boolean> */ hasUint8ArraySupport: typeof hasUint8ArraySupport; /** * Tests for native `Uint8ClampedArray` support. * * @returns boolean indicating if an environment has `Uint8ClampedArray` support * * @example * var bool = ns.hasUint8ClampedArraySupport(); * // returns <boolean> */ hasUint8ClampedArraySupport: typeof hasUint8ClampedArraySupport; /** * Tests for native `Uint16Array` support. * * @returns boolean indicating if an environment has `Uint16Array` support * * @example * var bool = ns.hasUint16ArraySupport(); * // returns <boolean> */ hasUint16ArraySupport: typeof hasUint16ArraySupport; /** * Tests for native `Uint32Array` support. * * @returns boolean indicating if an environment has `Uint32Array` support * * @example * var bool = ns.hasUint32ArraySupport(); * // returns <boolean> */ hasUint32ArraySupport: typeof hasUint32ArraySupport; /** * Tests if a position in a string marks the start of a UTF-16 surrogate pair. * * @param str - input string * @param pos - position * @throws first argument must be a string * @throws second argument must be a nonnegative integer * @throws position must be a valid index in string * @returns boolean indicating if a position in a string marks the start of a UTF-16 surrogate pair * * @example * var bool = ns.hasUTF16SurrogatePairAt( '🌷', 0 ); * // returns true * * @example * var bool = ns.hasUTF16SurrogatePairAt( '🌷', 1 ); * // returns false */ hasUTF16SurrogatePairAt: typeof hasUTF16SurrogatePairAt; /** * Tests for native WebAssembly support. * * @returns boolean indicating if an environment has native WebAssembly support * * @example * var bool = ns.hasWebAssemblySupport(); * // returns <boolean> */ hasWebAssemblySupport: typeof hasWebAssemblySupport; /** * Tests for native `WeakMap` support. * * @returns boolean indicating if an environment has `WeakMap` support * * @example * var bool = ns.hasWeakMapSupport(); * // returns <boolean> */ hasWeakMapSupport: typeof hasWeakMapSupport; /** * Tests for native `WeakSet` support. * * @returns boolean indicating if an environment has `WeakSet` support * * @example * var bool = ns.hasWeakSetSupport(); * // returns <boolean> */ hasWeakSetSupport: typeof hasWeakSetSupport; /** * Tests whether a value has in its prototype chain a specified constructor as a prototype property. * * @param value - value to test * @param constructor - constructor to test against * @throws constructor must be callable * @returns boolean indicating whether a value is an instance of a provided constructor * * @example * var bool = ns.instanceOf( [], Array ); * // returns true * * @example * var bool = ns.instanceOf( {}, Object ); // exception * // returns true * * @example * var bool = ns.instanceOf( 'beep', String ); * // returns false * * @example * var bool = ns.instanceOf( null, Object ); * // returns false * * @example * var bool = ns.instanceOf( 5, Object ); * // returns false */ instanceOf: typeof instanceOf; /** * Tests whether a value is an absolute HTTP(S) URI. * * @param value - value to test * @returns boolean indicating whether a value is an absolute HTTP(S) URI * * @example * var bool = ns.isAbsoluteHttpURI( 'http://example.com/' ); * // returns true * * @example * var bool = ns.isAbsoluteHttpURI( 'https://example.com/docs#heading' ); * // returns true * * @example * var bool = ns.isAbsoluteHttpURI( 'ftp://example.com' ); * // returns false * * @example * var bool = ns.isAbsoluteHttpURI( '/dashboard' ); * // returns false * * @example * var bool = ns.isAbsoluteHttpURI( './png.json' ); * // returns false * * @example * var bool = ns.isAbsoluteHttpURI( null ); * // returns false */ isAbsoluteHttpURI: typeof isAbsoluteHttpURI; /** * Tests if a value is an absolute path. * * ## Notes * * - Function behavior is platform-specific. On Windows platforms, the function is equal to `.win32()`. On POSIX platforms, the function is equal to `.posix()`. * * @param value - value to test * @returns boolean indicating whether value is an absolute path * * @example * var IS_WINDOWS = require( './../../is-windows' ); * var bool; * if ( IS_WINDOWS ) { * bool = ns.isAbsolutePath( 'C:\\foo\\bar\\baz' ); * // returns true * } else { * bool = ns.isAbsolutePath( '/foo/bar/baz' ); * // returns true * } * * @example * var bool = ns.isAbsolutePath.posix( '/foo/bar/baz' ); * // returns true * * @example * var bool = ns.isAbsolutePath.posix( 'foo/bar/baz' ); * // returns false * * @example * var bool = ns.isAbsolutePath.win32( 'C:\\foo\\bar\\baz' ); * // returns true * * @example * var bool = ns.isAbsolutePath.win32( 'foo\\bar\\baz' ); * // returns false */ isAbsolutePath: typeof isAbsolutePath; /** * Tests whether a value is an absolute URI. * * @param value - value to test * @returns boolean indicating whether a value is an absolute URI * * @example * var bool = ns.isAbsoluteURI( 'http://example.com/' ); * // returns true * * @example * var bool = ns.isAbsoluteURI( 'https://example.com/docs#heading' ); * // returns true * * @example * var bool = ns.isAbsoluteURI( '/dashboard' ); * // returns false * * @example * var bool = ns.isAbsoluteURI( './png.json' ); * // returns false * * @example * var bool = ns.isAbsoluteURI( null ); * // returns false */ isAbsoluteURI: typeof isAbsoluteURI; /** * Tests if a value is an array-like object supporting the accessor (get/set) protocol. * * @param value - value to test * @returns boolean indicating whether a value is an accessor array * * @example * var Complex128Array = require( '@stdlib/array/complex128' ); * * var arr = new Complex128Array( 10 ); * var bool = ns.isAccessorArray( arr ); * // returns true * * @example * var bool = ns.isAccessorArray( [] ); * // returns false * * @example * var bool = ns.isAccessorArray( {} ); * // returns false */ isAccessorArray: typeof isAccessorArray; /** * Tests if an object's own property has an accessor descriptor. * * @param value - value to test * @param property - property to test * @returns boolean indicating if an object property has an accessor descriptor * * @example * var defineProperty = require( '@stdlib/utils/define-property' ); * * var obj = { * 'boop': true * }; * * function getter() { * return 'beep'; * } * * defineProperty( obj, 'beep', { * 'configurable': false, * 'enumerable': false, * 'get': getter * }); * * var bool = ns.isAccessorProperty( obj, 'boop' ); * // returns false * * bool = ns.isAccessorProperty( obj, 'beep' ); * // returns true */ isAccessorProperty: typeof isAccessorProperty; /** * Tests if an object's own or inherited property has an accessor descriptor. * * @param value - value to test * @param property - property to test * @returns boolean indicating if an object property has an accessor descriptor * * @example * var defineProperty = require( '@stdlib/utils/define-property' ); * * var obj = { * 'boop': true * }; * * function getter() { * return 'beep'; * } * * defineProperty( obj, 'beep', { * 'configurable': false, * 'enumerable': false, * 'get': getter * }); * * var bool = ns.isAccessorPropertyIn( obj, 'boop' ); * // returns false * * bool = ns.isAccessorPropertyIn( obj, 'beep' ); * // returns true */ isAccessorPropertyIn: typeof isAccessorPropertyIn; /** * Tests if a value is an alphagram (i.e., a sequence of characters arranged in alphabetical order). * * ## Notes * * - The function first checks that an input value is a string before validating that the value is an alphagram. For non-string values, the function returns `false`. * * @param value - value to test * @returns boolean indicating if a value is an alphagram * * @example * var out = ns.isAlphagram( 'beep' ); * // returns true * * @example * var out = ns.isAlphagram( new String( 'beep' ) ); * // returns true * * @example * var out = ns.isAlphagram( 'zba' ); * // returns false * * @example * var out = ns.isAlphagram( '' ); * // returns false * * @example * var out = ns.isAlphagram( 123 ); * // returns false */ isAlphagram: typeof isAlphagram; /** * Tests whether a string contains only alphanumeric characters. * * @param value - value to test * @returns boolean indicating if a string contains only alphanumeric characters * * @example * var out = ns.isAlphaNumeric( 'abc123def456' ); * // returns true * * @example * var out = ns.isAlphaNumeric( '0xffffff' ); * // returns true * * @example * var out = ns.isAlphaNumeric( '123' ); * // returns true * * @example * var out = ns.isAlphaNumeric( '' ); * // returns false * * @example * var out = ns.isAlphaNumeric( 123 ); * // returns false */ isAlphaNumeric: typeof isAlphaNumeric; /** * Tests if a value is an anagram. * * @param str - comparison string * @param x - value to test * @returns boolean indicating if a value is an anagram * * @example * var bool = ns.isAnagram( 'I am a weakish speller', 'William Shakespeare' ); * // returns true * * @example * var bool = ns.isAnagram( 'bat', 'tabba' ); * // returns false */ isAnagram: typeof isAnagram; /** * Tests whether a value is an `arguments` object. * * @param value - value to test * @returns boolean indicating whether a value is an `arguments` object * * @example * function foo() { * return arguments; * } * * var bool = ns.isArguments( foo() ); * // returns true * * @example * var bool = ns.isArguments( [] ); * // returns false */ isArguments: typeof isArguments; /** * Tests if a value is an array. * * @param value - value to test * @returns boolean indicating whether value is an array * * @example * var bool = ns.isArray( [] ); * // returns true * * @example * var bool = ns.isArray( {} ); * // returns false */ isArray: typeof isArray; /** * Tests if a value is an array of arrays. * * @param value - value to test * @returns boolean indicating whether a value is an array of arrays * * @example * var bool = ns.isArrayArray( [ [], [] ] ); * // returns true * * bool = ns.isArrayArray( [ {}, {} ] ); * // returns false * * bool = ns.isArrayArray( [] ); * // returns false */ isArrayArray: typeof isArrayArray; /** * Tests if a value is a valid array length. * * ## Notes * * - A valid length property for an Array instance is any integer value on the interval `[0, 2^32-1]`. * * @param value - value to test * @returns boolean indicating if a value is a valid array length * * @example * var bool = ns.isArrayLength( 3 ); * // returns true * * @example * var bool = ns.isArrayLength( 3.14 ); * // returns false */ isArrayLength: typeof isArrayLength; /** * Tests if a value is array-like. * * ## Notes * * - If provided a string, the function returns `true`. * * @param value - value to test * @returns boolean indicating if a value is array-like * * @example * var bool = ns.isArrayLike( [] ); * // returns true * * @example * var bool = ns.isArrayLike( {'length':10} ); * // returns true */ isArrayLike: typeof isArrayLike; /** * Tests if a value is an array-like object. * * ## Notes * * - If provided a string, the function returns `false`. * * @param value - value to test * @returns boolean indicating if a value is an array-like object * * @example * var bool = ns.isArrayLikeObject( [] ); * // returns true * * @example * var bool = ns.isArrayLikeObject( { 'length':10 } ); * // returns true * * @example * var bool = ns.isArrayLikeObject( 'beep' ); * // returns false */ isArrayLikeObject: typeof isArrayLikeObject; /** * Tests if a value is an ArrayBuffer. * * @param value - value to test * @returns boolean indicating whether value is an ArrayBuffer * * @example * var ArrayBuffer = require( '@stdlib/array/buffer' ); * * var bool = ns.isArrayBuffer( new ArrayBuffer( 10 ) ); * // returns true * * @example * var bool = ns.isArrayBuffer( [] ); * // returns false */ isArrayBuffer: typeof isArrayBuffer; /** * Tests if a value is an `ArrayBuffer` view. * * @param value - value to test * @returns boolean indicating whether value is an `ArrayBuffer` view * * @example * var Int8Array = require( '@stdlib/array/int8' ); * var bool = ns.isArrayBufferView( new Int8Array() ); * // returns true * * @example * var bool = ns.isArrayBufferView( [] ); * // returns false */ isArrayBufferView: typeof isArrayBufferView; /** * Tests if a value is an arrow function. * * @param value - value to test * @returns boolean indicating whether value is an arrow function * * @example * var arrow = () => {}; * var bool = ns.isArrowFunction( arrow ); * // returns true * * @example * function beep() { * return 'beep'; * } * * var bool = ns.isArrowFunction( beep ); * // returns false */ isArrowFunction: typeof isArrowFunction; /** * Tests whether a character belongs to the ASCII character set and whether this is true for all characters in a provided string. * * @param value - value to test * @returns boolean indicating if a string has all ASCII characters * * @example * var out = ns.isASCII( 'beep' ); * // returns true * * @example * var out = ns.isASCII( 'È' ); * // returns false * * @example * var out = ns.isASCII( '' ); * // returns false * * @example * var out = ns.isASCII( 123 ); * // returns false */ isASCII: typeof isASCII; /** * Tests if a value is between two values. * * @param value - value to test * @param a - left comparison value * @param b - right comparison value * @param left - indicates whether the left comparison value is inclusive (default: 'closed') * @param right - indicates whether the right comparison value is inclusive (default: 'closed') * @returns boolean indicating whether a value is between two values * * @example * var bool = ns.isBetween( 3.14, 3.0, 4.0 ); * // returns true * * @example * var bool = ns.isBetween( 4.5, 3.0, 4.0 ); * // returns false * * @example * var bool = ns.isBetween( 3.14, 3.14, 4.0 ); * // returns true * * @example * var bool = ns.isBetween( 3.14, 3.14, 4.0, 'open', 'closed' ); * // returns false * * @example * var bool = ns.isBetween( 3.14, 3.0, 3.14 ); * // returns true * * @example * var bool = ns.isBetween( 3.14, 3.0, 3.14, 'closed', 'open' ); * // returns false */ isBetween: typeof isBetween; /** * Tests if a value is an array-like object where every element is between two values. * * @param value - value to test * @param a - left comparison value * @param b - right comparison value * @param left - indicates whether the left comparison value is inclusive (default: 'closed') * @param right - indicates whether the right comparison value is inclusive (default: 'closed') * @returns boolean indicating whether a value is an array-like object where every element is between two values * * @example * var arr = [ 3.0, 3.14, 4.0 ]; * var bool = ns.isBetweenArray( arr, 3.0, 4.0 ); * // returns true * * @example * var arr = [ 3.0, 3.14, 4.0 ]; * var bool = ns.isBetweenArray( arr, 3.14, 4.0 ); * // returns false * * @example * var arr = [ 3.0, 3.14, 4.0 ]; * var bool = ns.isBetweenArray( arr, 3.0, 3.14 ); * // returns false * * @example * var arr = [ 3.0, 3.14, 4.0 ]; * var bool = ns.isBetweenArray( arr, 3.0, 4.0, 'open', 'closed' ); * // returns false * * @example * var arr = [ 3.0, 3.14, 4.0 ]; * var bool = ns.isBetweenArray( arr, 3.0, 4.0, 'closed', 'open' ); * // returns false */ isBetweenArray: typeof isBetweenArray; /** * Boolean indicating if the environment is big endian. * * @example * var bool = ns.IS_BIG_ENDIAN; * // returns <boolean> */ IS_BIG_ENDIAN: typeof IS_BIG_ENDIAN; /** * Tests if a value is a BigInt. * * @param value - value to test * @returns boolean indicating whether value is a BigInt * * @example * var BigInt = require( '@stdlib/bigint/ctor' ); * * var bool = ns.isBigInt.isPrimitive( BigInt( '1' ) ); * // returns true * * @example * var BigInt = require( '@stdlib/bigint/ctor' ); * * var bool = ns.isBigInt.isPrimitive( Object( BigInt( '1' ) ) ); * // returns false * * @example * var BigInt = require( '@stdlib/bigint/ctor' ); * * var bool = ns.isBigInt.isPrimitive( BigInt( '1' ) ); * // returns true * * @example * var BigInt = re