@stdlib/assert

Standard assertion utilities.

https://github.com/stdlib-js/assert

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (15.4%) to scientific vocabulary

Keywords

assert assertion check expect expectation is isvalid javascript node node-js nodejs stdlib test util utilities utility utils valid validate validation
Last synced: 4 months ago · JSON representation ·

Repository

Standard assertion utilities.

Basic Info
Statistics
  • Stars: 4
  • Watchers: 3
  • Forks: 0
  • Open Issues: 0
  • Releases: 0
Topics
assert assertion check expect expectation is isvalid javascript node node-js nodejs stdlib test util utilities utility utils valid validate validation
Created over 4 years ago · Last pushed 4 months ago
Metadata Files
Readme Changelog Contributing License Code of conduct Citation Security Notice

README.md

About stdlib...

We believe in a future in which the web is a preferred environment for numerical computation. To help realize this future, we've built stdlib. stdlib is a standard library, with an emphasis on numerical and scientific computation, written in JavaScript (and C) for execution in browsers and in Node.js.

The library is fully decomposable, being architected in such a way that you can swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.

When you use stdlib, you can be absolutely certain that you are using the most thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code out there.

To join us in bringing numerical computing to the web, get started by checking us out on GitHub, and please consider financially supporting stdlib. We greatly appreciate your continued support!

Assert

NPM version Build Status Coverage Status <!-- dependencies -->

Assertion utilities.

## Installation ```bash npm install @stdlib/assert ``` Alternatively, - To load the package in a website via a `script` tag without installation and bundlers, use the [ES Module][es-module] available on the [`esm`][esm-url] branch (see [README][esm-readme]). - If you are using Deno, visit the [`deno`][deno-url] branch (see [README][deno-readme] for usage intructions). - For use in Observable, or in browser/node environments, use the [Universal Module Definition (UMD)][umd] build available on the [`umd`][umd-url] branch (see [README][umd-readme]). The [branches.md][branches-url] file summarizes the available branches and displays a diagram illustrating their relationships. To view installation and usage instructions specific to each branch build, be sure to explicitly navigate to the respective README files on each branch, as linked to above.
## Usage ```javascript var assert = require( '@stdlib/assert' ); ``` #### assert Namespace providing utilities for data type testing and feature detection. ```javascript var o = assert; // returns {...} ``` To validate the built-in JavaScript data types, the namespace includes the following assertion utilities:
- [`isArray( value )`][@stdlib/assert/is-array]: test if a value is an array. - [`isBoolean( value )`][@stdlib/assert/is-boolean]: test if a value is a boolean. - [`isDateObject( value )`][@stdlib/assert/is-date-object]: test if a value is a Date object. - [`isFunction( value )`][@stdlib/assert/is-function]: test if a value is a function. - [`isnan( value )`][@stdlib/assert/is-nan]: test if a value is NaN. - [`isNull( value )`][@stdlib/assert/is-null]: test if a value is null. - [`isNumber( value )`][@stdlib/assert/is-number]: test if a value is a number. - [`isObject( value )`][@stdlib/assert/is-object]: test if a value is an object. - [`isRegExp( value )`][@stdlib/assert/is-regexp]: test if a value is a regular expression. - [`isString( value )`][@stdlib/assert/is-string]: test if a value is a string. - [`isSymbol( value )`][@stdlib/assert/is-symbol]: test if a value is a symbol. - [`isUndefined( value )`][@stdlib/assert/is-undefined]: test if a value is undefined.
For primitive types having corresponding object wrappers, assertion utilities provide `isObject` and `isPrimitive` methods to test for either objects or primitives, respectively. ```javascript var Boolean = require( '@stdlib/boolean/ctor' ); var isBoolean = require( '@stdlib/assert/is-boolean' ); var bool = isBoolean.isObject( new Boolean( false ) ); // returns true bool = isBoolean.isObject( false ); // returns false bool = isBoolean.isPrimitive( false ); // returns true ``` Many of the assertion utilities have corresponding packages that test whether array elements are of the given data type:
- [`isArrayArray( value )`][@stdlib/assert/is-array-array]: test if a value is an array of arrays. - [`isBooleanArray( value )`][@stdlib/assert/is-boolean-array]: test if a value is an array-like object of booleans. - [`isDateObjectArray( value )`][@stdlib/assert/is-date-object-array]: test if a value is an array-like object containing only Date objects. - [`isFunctionArray( value )`][@stdlib/assert/is-function-array]: test if a value is an array-like object containing only functions. - [`isNaNArray( value )`][@stdlib/assert/is-nan-array]: test if a value is an array-like object containing only NaN values. - [`isNullArray( value )`][@stdlib/assert/is-null-array]: test if a value is an array-like object containing only null values. - [`isNumberArray( value )`][@stdlib/assert/is-number-array]: test if a value is an array-like object of numbers. - [`isObjectArray( value )`][@stdlib/assert/is-object-array]: test if a value is an array-like object containing only objects. - [`isStringArray( value )`][@stdlib/assert/is-string-array]: test if a value is an array of strings. - [`isSymbolArray( value )`][@stdlib/assert/is-symbol-array]: test if a value is an array-like object containing only symbols.
Where applicable, similar to the assertion utilities for built-in data types, array assertion utilities provides methods for testing for an array of primitives or objects. ```javascript var isStringArray = require( '@stdlib/assert/is-string-array' ); var bool = isStringArray( [ 'hello', 'world' ] ); // returns true bool = isStringArray.primitives( [ 'hello', 'world' ] ); // returns true bool = isStringArray.objects( [ 'hello', 'world' ] ); // returns false bool = isStringArray.objects( [ new String( 'hello' ), new String( 'world' ) ] ); // returns true ``` The namespace also contains utilities to test for numbers within a certain range or for numbers satisfying a particular "type":
- [`isCubeNumber( value )`][@stdlib/assert/is-cube-number]: test if a value is a cube number. - [`isIntegerArray( value )`][@stdlib/assert/is-integer-array]: test if a value is an array-like object containing only integers. - [`isInteger( value )`][@stdlib/assert/is-integer]: test if a value is a number having an integer value. - [`isNegativeIntegerArray( value )`][@stdlib/assert/is-negative-integer-array]: test if a value is an array-like object containing only negative integers. - [`isNegativeInteger( value )`][@stdlib/assert/is-negative-integer]: test if a value is a number having a negative integer value. - [`isNegativeNumberArray( value )`][@stdlib/assert/is-negative-number-array]: test if a value is an array-like object containing only negative numbers. - [`isNegativeNumber( value )`][@stdlib/assert/is-negative-number]: test if a value is a number having a negative value. - [`isNonNegativeIntegerArray( value )`][@stdlib/assert/is-nonnegative-integer-array]: test if a value is an array-like object containing only nonnegative integers. - [`isNonNegativeInteger( value )`][@stdlib/assert/is-nonnegative-integer]: test if a value is a number having a nonnegative integer value. - [`isNonNegativeNumberArray( value )`][@stdlib/assert/is-nonnegative-number-array]: test if a value is an array-like object containing only nonnegative numbers. - [`isNonNegativeNumber( value )`][@stdlib/assert/is-nonnegative-number]: test if a value is a number having a nonnegative value. - [`isNonPositiveIntegerArray( value )`][@stdlib/assert/is-nonpositive-integer-array]: test if a value is an array-like object containing only nonpositive integers. - [`isNonPositiveInteger( value )`][@stdlib/assert/is-nonpositive-integer]: test if a value is a number having a nonpositive integer value. - [`isNonPositiveNumberArray( value )`][@stdlib/assert/is-nonpositive-number-array]: test if a value is an array-like object containing only nonpositive numbers. - [`isNonPositiveNumber( value )`][@stdlib/assert/is-nonpositive-number]: test if a value is a number having a nonpositive value. - [`isPositiveIntegerArray( value )`][@stdlib/assert/is-positive-integer-array]: test if a value is an array-like object containing only positive integers. - [`isPositiveInteger( value )`][@stdlib/assert/is-positive-integer]: test if a value is a number having a positive integer value. - [`isPositiveNumberArray( value )`][@stdlib/assert/is-positive-number-array]: test if a value is an array-like object containing only positive numbers. - [`isPositiveNumber( value )`][@stdlib/assert/is-positive-number]: test if a value is a number having a positive value. - [`isSafeIntegerArray( value )`][@stdlib/assert/is-safe-integer-array]: test if a value is an array-like object containing only safe integers. - [`isSafeInteger( value )`][@stdlib/assert/is-safe-integer]: test if a value is a number having a safe integer value. - [`isSquareNumber( value )`][@stdlib/assert/is-square-number]: test if a value is a square number. - [`isSquareTriangularNumber( value )`][@stdlib/assert/is-square-triangular-number]: test if a value is a square triangular number. - [`isTriangularNumber( value )`][@stdlib/assert/is-triangular-number]: test if a value is a triangular number.
The namespace provides utilities for validating typed arrays:
- [`isFloat32Array( value )`][@stdlib/assert/is-float32array]: test if a value is a Float32Array. - [`isFloat64Array( value )`][@stdlib/assert/is-float64array]: test if a value is a Float64Array. - [`isInt16Array( value )`][@stdlib/assert/is-int16array]: test if a value is an Int16Array. - [`isInt32Array( value )`][@stdlib/assert/is-int32array]: test if a value is an Int32Array. - [`isInt8Array( value )`][@stdlib/assert/is-int8array]: test if a value is an Int8Array. - [`isUint16Array( value )`][@stdlib/assert/is-uint16array]: test if a value is a Uint16Array. - [`isUint32Array( value )`][@stdlib/assert/is-uint32array]: test if a value is a Uint32Array. - [`isUint8Array( value )`][@stdlib/assert/is-uint8array]: test if a value is a Uint8Array. - [`isUint8ClampedArray( value )`][@stdlib/assert/is-uint8clampedarray]: test if a value is a Uint8ClampedArray.
The namespace includes utilities for validating `ndarray`s (n-dimensional arrays).
- [`isCentrosymmetricMatrix( value )`][@stdlib/assert/is-centrosymmetric-matrix]: test if a value is a centrosymmetric matrix. - [`isComplex128MatrixLike( value )`][@stdlib/assert/is-complex128matrix-like]: test if a value is a 2-dimensional ndarray-like object containing double-precision complex floating-point numbers. - [`isComplex128ndarrayLike( value )`][@stdlib/assert/is-complex128ndarray-like]: test if a value is an ndarray-like object containing double-precision complex floating-point numbers. - [`isComplex128VectorLike( value )`][@stdlib/assert/is-complex128vector-like]: test if a value is a 1-dimensional ndarray-like object containing double-precision complex floating-point numbers. - [`isComplex64MatrixLike( value )`][@stdlib/assert/is-complex64matrix-like]: test if a value is a 2-dimensional ndarray-like object containing single-precision complex floating-point numbers. - [`isComplex64ndarrayLike( value )`][@stdlib/assert/is-complex64ndarray-like]: test if a value is an ndarray-like object containing single-precision complex floating-point numbers. - [`isComplex64VectorLike( value )`][@stdlib/assert/is-complex64vector-like]: test if a value is a 1-dimensional ndarray-like object containing single-precision complex floating-point numbers. - [`isFloat32MatrixLike( value )`][@stdlib/assert/is-float32matrix-like]: test if a value is a 2-dimensional ndarray-like object containing single-precision floating-point numbers. - [`isFloat32ndarrayLike( value )`][@stdlib/assert/is-float32ndarray-like]: test if a value is an ndarray-like object containing single-precision floating-point numbers. - [`isFloat32VectorLike( value )`][@stdlib/assert/is-float32vector-like]: test if a value is a 1-dimensional ndarray-like object containing single-precision floating-point numbers. - [`isFloat64MatrixLike( value )`][@stdlib/assert/is-float64matrix-like]: test if a value is a 2-dimensional ndarray-like object containing double-precision floating-point numbers. - [`isFloat64ndarrayLike( value )`][@stdlib/assert/is-float64ndarray-like]: test if a value is an ndarray-like object containing double-precision floating-point numbers. - [`isFloat64VectorLike( value )`][@stdlib/assert/is-float64vector-like]: test if a value is a 1-dimensional ndarray-like object containing double-precision floating-point numbers. - [`isMatrixLike( value )`][@stdlib/assert/is-matrix-like]: test if a value is 2-dimensional ndarray-like object. - [`isndarrayLikeWithDataType( value, dtype )`][@stdlib/assert/is-ndarray-like-with-data-type]: test if a value is an ndarray-like object having a specified data type. - [`isndarrayLike( value )`][@stdlib/assert/is-ndarray-like]: test if a value is ndarray-like. - [`isNonSymmetricMatrix( value )`][@stdlib/assert/is-nonsymmetric-matrix]: test if a value is a non-symmetric matrix. - [`isPersymmetricMatrix( value )`][@stdlib/assert/is-persymmetric-matrix]: test if a value is a persymmetric matrix. - [`isSkewCentrosymmetricMatrix( value )`][@stdlib/assert/is-skew-centrosymmetric-matrix]: test if a value is a skew-centrosymmetric matrix. - [`isSkewPersymmetricMatrix( value )`][@stdlib/assert/is-skew-persymmetric-matrix]: test if a value is a skew-persymmetric matrix. - [`isSkewSymmetricMatrix( value )`][@stdlib/assert/is-skew-symmetric-matrix]: test if a value is a skew-symmetric matrix. - [`isSquareMatrix( value )`][@stdlib/assert/is-square-matrix]: test if a value is a 2-dimensional ndarray-like object having equal dimensions. - [`isSymmetricMatrix( value )`][@stdlib/assert/is-symmetric-matrix]: test if a value is a symmetric matrix. - [`isVectorLike( value )`][@stdlib/assert/is-vector-like]: test if a value is a 1-dimensional ndarray-like object.
The namespace includes utilities for validating complex numbers and arrays of complex numbers:
- [`isComplexLike( value )`][@stdlib/assert/is-complex-like]: test if a value is a complex number-like object. - [`isComplexTypedArrayLike( value )`][@stdlib/assert/is-complex-typed-array-like]: test if a value is complex-typed-array-like. - [`isComplexTypedArray( value )`][@stdlib/assert/is-complex-typed-array]: test if a value is a complex typed array. - [`isComplex( value )`][@stdlib/assert/is-complex]: test if a value is a 64-bit or 128-bit complex number. - [`isComplex128( value )`][@stdlib/assert/is-complex128]: test if a value is a 128-bit complex number. - [`isComplex128Array( value )`][@stdlib/assert/is-complex128array]: test if a value is a Complex128Array. - [`isComplex64( value )`][@stdlib/assert/is-complex64]: test if a value is a 64-bit complex number. - [`isComplex64Array( value )`][@stdlib/assert/is-complex64array]: test if a value is a Complex64Array.
The namespace includes utilities for validating other special arrays or buffers:
- [`isAccessorArray( value )`][@stdlib/assert/is-accessor-array]: test if a value is an array-like object supporting the accessor (get/set) protocol. - [`isArrayLength( value )`][@stdlib/assert/is-array-length]: test if a value is a valid array length. - [`isArrayLikeObject( value )`][@stdlib/assert/is-array-like-object]: test if a value is an array-like object. - [`isArrayLike( value )`][@stdlib/assert/is-array-like]: test if a value is array-like. - [`isArrayBufferView( value )`][@stdlib/assert/is-arraybuffer-view]: test if a value is an ArrayBuffer view. - [`isArrayBuffer( value )`][@stdlib/assert/is-arraybuffer]: test if a value is an ArrayBuffer. - [`isBetweenArray( value, a, b[, left, right] )`][@stdlib/assert/is-between-array]: test if a value is an array-like object where every element is between two values. - [`isBigInt64Array( value )`][@stdlib/assert/is-bigint64array]: test if a value is a BigInt64Array. - [`isBigUint64Array( value )`][@stdlib/assert/is-biguint64array]: test if a value is a BigUint64Array. - [`isCircularArray( value )`][@stdlib/assert/is-circular-array]: test if a value is an array containing a circular reference. - [`isEmptyArrayLikeObject( value )`][@stdlib/assert/is-empty-array-like-object]: test if a value is an empty array-like object. - [`isEmptyArray( value )`][@stdlib/assert/is-empty-array]: test if a value is an empty array. - [`isEqualArray( v1, v2 )`][@stdlib/assert/is-equal-array]: test if two arguments are both generic arrays and have equal values. - [`isEqualBooleanArray( v1, v2 )`][@stdlib/assert/is-equal-booleanarray]: test if two arguments are both BooleanArrays and have equal values. - [`isEqualInt16Array( v1, v2 )`][@stdlib/assert/is-equal-int16array]: test if two arguments are both Int16Arrays and have equal values. - [`isEqualInt32Array( v1, v2 )`][@stdlib/assert/is-equal-int32array]: test if two arguments are both Int32Arrays and have equal values. - [`isEqualInt8Array( v1, v2 )`][@stdlib/assert/is-equal-int8array]: test if two arguments are both Int8Arrays and have equal values. - [`isEqualUint16Array( v1, v2 )`][@stdlib/assert/is-equal-uint16array]: test if two arguments are both Uint16Arrays and have equal values. - [`isEqualUint32Array( v1, v2 )`][@stdlib/assert/is-equal-uint32array]: test if two arguments are both Uint32Arrays and have equal values. - [`isEqualUint8Array( v1, v2 )`][@stdlib/assert/is-equal-uint8array]: test if two arguments are both Uint8Arrays and have equal values. - [`isEqualUint8ClampedArray( v1, v2 )`][@stdlib/assert/is-equal-uint8clampedarray]: test if two arguments are both Uint8ClampedArrays and have equal values. - [`isFalsyArray( value )`][@stdlib/assert/is-falsy-array]: test if a value is an array-like object containing only falsy values. - [`isFiniteArray( value )`][@stdlib/assert/is-finite-array]: test if a value is an array-like object containing only finite numbers. - [`isNumericArray( value )`][@stdlib/assert/is-numeric-array]: test if a value is a numeric array. - [`isPlainObjectArray( value )`][@stdlib/assert/is-plain-object-array]: test if a value is an array-like object containing only plain objects. - [`isProbabilityArray( value )`][@stdlib/assert/is-probability-array]: test if a value is an array-like object containing only probabilities. - [`isSameAccessorArray( v1, v2 )`][@stdlib/assert/is-same-accessor-array]: test if two arguments are both accessor arrays and have the same values. - [`isSameArrayLikeObject( v1, v2 )`][@stdlib/assert/is-same-array-like-object]: test if two arguments are both array-like objects and have the same values. - [`isSameArrayLike( v1, v2 )`][@stdlib/assert/is-same-array-like]: test if two arguments are both array-like and have the same values. - [`isSameArray( v1, v2 )`][@stdlib/assert/is-same-array]: test if two arguments are both generic arrays and have the same values. - [`isSameComplex128Array( v1, v2 )`][@stdlib/assert/is-same-complex128array]: test if two arguments are both Complex128Arrays and have the same values. - [`isSameComplex64Array( v1, v2 )`][@stdlib/assert/is-same-complex64array]: test if two arguments are both Complex64Arrays and have the same values. - [`isSameFloat32Array( v1, v2 )`][@stdlib/assert/is-same-float32array]: test if two arguments are both Float32Arrays and have the same values. - [`isSameFloat64Array( v1, v2 )`][@stdlib/assert/is-same-float64array]: test if two arguments are both Float64Arrays and have the same values. - [`isSameTypedArrayLike( v1, v2 )`][@stdlib/assert/is-same-typed-array-like]: test if two arguments are both typed-array-like objects and have the same values. - [`isSharedArrayBuffer( value )`][@stdlib/assert/is-sharedarraybuffer]: test if a value is a SharedArrayBuffer. - [`isTruthyArray( value )`][@stdlib/assert/is-truthy-array]: test if a value is an array-like object containing only truthy values. - [`isTypedArrayLength( value )`][@stdlib/assert/is-typed-array-length]: test if a value is a valid typed array length. - [`isTypedArrayLike( value )`][@stdlib/assert/is-typed-array-like]: test if a value is typed-array-like. - [`isTypedArray( value )`][@stdlib/assert/is-typed-array]: test if a value is a typed array. - [`isUnityProbabilityArray( value )`][@stdlib/assert/is-unity-probability-array]: test if a value is an array of probabilities that sum to one.
To test for error objects, the namespace includes the following utilities:
- [`isError( value )`][@stdlib/assert/is-error]: test if a value is an Error object. - [`isEvalError( value )`][@stdlib/assert/is-eval-error]: test if a value is an EvalError object. - [`isRangeError( value )`][@stdlib/assert/is-range-error]: test if a value is a RangeError object. - [`isReferenceError( value )`][@stdlib/assert/is-reference-error]: test if a value is a ReferenceError object. - [`isSyntaxError( value )`][@stdlib/assert/is-syntax-error]: test if a value is a SyntaxError object. - [`isTypeError( value )`][@stdlib/assert/is-type-error]: test if a value is a TypeError object. - [`isURIError( value )`][@stdlib/assert/is-uri-error]: test if a value is a URIError object.
The namespace exposes the following constants concerning the current running process:
- [`IS_BIG_ENDIAN`][@stdlib/assert/is-big-endian]: check if an environment is big endian. - [`IS_BROWSER`][@stdlib/assert/is-browser]: check if the runtime is a web browser. - [`IS_DARWIN`][@stdlib/assert/is-darwin]: boolean indicating if the current process is running on Darwin. - [`IS_DOCKER`][@stdlib/assert/is-docker]: check if the process is running in a Docker container. - [`IS_ELECTRON_MAIN`][@stdlib/assert/is-electron-main]: check if the runtime is the main Electron process. - [`IS_ELECTRON_RENDERER`][@stdlib/assert/is-electron-renderer]: check if the runtime is the Electron renderer process. - [`IS_ELECTRON`][@stdlib/assert/is-electron]: check if the runtime is Electron. - [`IS_LITTLE_ENDIAN`][@stdlib/assert/is-little-endian]: check if an environment is little endian. - [`IS_MOBILE`][@stdlib/assert/is-mobile]: check if the current environment is a mobile device. - [`IS_NODE`][@stdlib/assert/is-node]: check if the runtime is Node.js. - [`IS_TOUCH_DEVICE`][@stdlib/assert/is-touch-device]: check if the current environment is a touch device. - [`IS_WEB_WORKER`][@stdlib/assert/is-web-worker]: check if the runtime is a web worker. - [`IS_WINDOWS`][@stdlib/assert/is-windows]: boolean indicating if the current process is running on Windows.
To test whether a runtime environment supports certain features, the namespace includes the following utilities:
- [`hasArrayBufferSupport()`][@stdlib/assert/has-arraybuffer-support]: detect native `ArrayBuffer` support. - [`hasArrowFunctionSupport()`][@stdlib/assert/has-arrow-function-support]: detect native `arrow function` support. - [`hasAsyncAwaitSupport()`][@stdlib/assert/has-async-await-support]: detect native `async`/`await` support. - [`hasAsyncIteratorSymbolSupport()`][@stdlib/assert/has-async-iterator-symbol-support]: detect native `Symbol.asyncIterator` support. - [`hasAtobSupport()`][@stdlib/assert/has-atob-support]: detect native `atob` support. - [`hasBigIntSupport()`][@stdlib/assert/has-bigint-support]: detect native `BigInt` support. - [`hasBigInt64ArraySupport()`][@stdlib/assert/has-bigint64array-support]: detect native `BigInt64Array` support. - [`hasBigUint64ArraySupport()`][@stdlib/assert/has-biguint64array-support]: detect native `BigUint64Array` support. - [`hasBtoaSupport()`][@stdlib/assert/has-btoa-support]: detect native `btoa` support. - [`hasClassSupport()`][@stdlib/assert/has-class-support]: detect native `class` support. - [`hasDataViewSupport()`][@stdlib/assert/has-dataview-support]: detect native `DataView` support. - [`hasDefinePropertiesSupport()`][@stdlib/assert/has-define-properties-support]: detect `Object.defineProperties` support. - [`hasDefinePropertySupport()`][@stdlib/assert/has-define-property-support]: detect `Object.defineProperty` support. - [`hasFloat32ArraySupport()`][@stdlib/assert/has-float32array-support]: detect native `Float32Array` support. - [`hasFloat64ArraySupport()`][@stdlib/assert/has-float64array-support]: detect native `Float64Array` support. - [`hasFunctionNameSupport()`][@stdlib/assert/has-function-name-support]: detect native function `name` support. - [`hasGeneratorSupport()`][@stdlib/assert/has-generator-support]: detect native `generator function` support. - [`hasGlobalThisSupport()`][@stdlib/assert/has-globalthis-support]: detect `globalThis` support. - [`hasInt16ArraySupport()`][@stdlib/assert/has-int16array-support]: detect native `Int16Array` support. - [`hasInt32ArraySupport()`][@stdlib/assert/has-int32array-support]: detect native `Int32Array` support. - [`hasInt8ArraySupport()`][@stdlib/assert/has-int8array-support]: detect native `Int8Array` support. - [`hasIteratorSymbolSupport()`][@stdlib/assert/has-iterator-symbol-support]: detect native `Symbol.iterator` support. - [`hasMapSupport()`][@stdlib/assert/has-map-support]: detect native `Map` support. - [`hasNodeBufferSupport()`][@stdlib/assert/has-node-buffer-support]: detect native `Buffer` support. - [`hasProxySupport()`][@stdlib/assert/has-proxy-support]: detect native `Proxy` support. - [`hasSetSupport()`][@stdlib/assert/has-set-support]: detect native `Set` support. - [`hasSharedArrayBufferSupport()`][@stdlib/assert/has-sharedarraybuffer-support]: detect native `SharedArrayBuffer` support. - [`hasSymbolSupport()`][@stdlib/assert/has-symbol-support]: detect native `Symbol` support. - [`hasToStringTagSupport()`][@stdlib/assert/has-tostringtag-support]: detect native `Symbol.toStringTag` support. - [`hasUint16ArraySupport()`][@stdlib/assert/has-uint16array-support]: detect native `Uint16Array` support. - [`hasUint32ArraySupport()`][@stdlib/assert/has-uint32array-support]: detect native `Uint32Array` support. - [`hasUint8ArraySupport()`][@stdlib/assert/has-uint8array-support]: detect native `Uint8Array` support. - [`hasUint8ClampedArraySupport()`][@stdlib/assert/has-uint8clampedarray-support]: detect native `Uint8ClampedArray` support. - [`hasWebAssemblySupport()`][@stdlib/assert/has-wasm-support]: detect native WebAssembly support. - [`hasWeakMapSupport()`][@stdlib/assert/has-weakmap-support]: detect native `WeakMap` support. - [`hasWeakSetSupport()`][@stdlib/assert/has-weakset-support]: detect native `WeakSet` support.
The remaining namespace utilities are as follows:
- [`contains( value, searchValue[, position] )`][@stdlib/assert/contains]: test if an array-like value contains a search value. - [`deepEqual( a, b )`][@stdlib/assert/deep-equal]: test for deep equality between two values. - [`deepHasOwnProp( value, path[, options] )`][@stdlib/assert/deep-has-own-property]: test whether an object contains a nested key path. - [`deepHasProp( value, path[, options] )`][@stdlib/assert/deep-has-property]: test whether an object contains a nested key path, either own or inherited. - [`hasOwnProp( value, property )`][@stdlib/assert/has-own-property]: test if an object has a specified property. - [`hasProp( value, property )`][@stdlib/assert/has-property]: test if an object has a specified property, either own or inherited. - [`hasUTF16SurrogatePairAt( string, position )`][@stdlib/assert/has-utf16-surrogate-pair-at]: test if a position in a string marks the start of a UTF-16 surrogate pair. - [`instanceOf( value, constructor )`][@stdlib/assert/instance-of]: test whether a value has in its prototype chain a specified constructor as a prototype property. - [`isAbsoluteHttpURI( value )`][@stdlib/assert/is-absolute-http-uri]: test whether a value is an absolute HTTP(S) URI. - [`isAbsolutePath( value )`][@stdlib/assert/is-absolute-path]: test if a value is an absolute path. - [`isAbsoluteURI( value )`][@stdlib/assert/is-absolute-uri]: test whether a value is an absolute URI. - [`isAccessorPropertyIn( value, property )`][@stdlib/assert/is-accessor-property-in]: test if an object's own or inherited property has an accessor descriptor. - [`isAccessorProperty( value, property )`][@stdlib/assert/is-accessor-property]: test if an object's own property has an accessor descriptor. - [`isAlphagram( value )`][@stdlib/assert/is-alphagram]: test if a value is an alphagram. - [`isAlphaNumeric( value )`][@stdlib/assert/is-alphanumeric]: test whether a string contains only alphanumeric characters. - [`isAnagram( str, value )`][@stdlib/assert/is-anagram]: test if a value is an anagram. - [`isArguments( value )`][@stdlib/assert/is-arguments]: test if a value is an arguments object. - [`isArrowFunction( value )`][@stdlib/assert/is-arrow-function]: test if a value is an `arrow function`. - [`isASCII( value )`][@stdlib/assert/is-ascii]: test whether a character belongs to the ASCII character set and whether this is true for all characters in a provided string. - [`isBetween( value, a, b[, left, right] )`][@stdlib/assert/is-between]: test if a value is between two values. - [`isBigInt( value )`][@stdlib/assert/is-bigint]: test if a value is a BigInt. - [`isBinaryString( value )`][@stdlib/assert/is-binary-string]: test if a value is a binary string. - [`isBlankString( value )`][@stdlib/assert/is-blank-string]: test if a value is a blank string. - [`isBoxedPrimitive( value )`][@stdlib/assert/is-boxed-primitive]: test if a value is a JavaScript boxed primitive. - [`isBuffer( value )`][@stdlib/assert/is-buffer]: test if a value is a Buffer object. - [`isCamelcase( value )`][@stdlib/assert/is-camelcase]: test if a value is a camelcase string. - [`isCapitalized( value )`][@stdlib/assert/is-capitalized]: test if a value is a string having an uppercase first character. - [`isCircular( value )`][@stdlib/assert/is-circular]: test if a value is a plain object containing a circular reference. - [`isCircular( value )`][@stdlib/assert/is-circular]: test if an object-like value contains a circular reference. - [`isClass( value )`][@stdlib/assert/is-class]: test if a value is a class. - [`isCollection( value )`][@stdlib/assert/is-collection]: test if a value is a collection. - [`isComposite( value )`][@stdlib/assert/is-composite]: test if a value is a composite number. - [`isConfigurablePropertyIn( value, property )`][@stdlib/assert/is-configurable-property-in]: test if an object's own or inherited property is configurable. - [`isConfigurableProperty( value, property )`][@stdlib/assert/is-configurable-property]: test if an object's own property is configurable. - [`isConstantcase( value )`][@stdlib/assert/is-constantcase]: test if a value is a constantcase string. - [`isCurrentYear( value )`][@stdlib/assert/is-current-year]: test if a value is the current year. - [`isDataPropertyIn( value, property )`][@stdlib/assert/is-data-property-in]: test if an object's own or inherited property has a data descriptor. - [`isDataProperty( value, property )`][@stdlib/assert/is-data-property]: test if an object's own property has a data descriptor. - [`isDataView( value )`][@stdlib/assert/is-dataview]: test if a value is a DataView. - [`isDigitString( value )`][@stdlib/assert/is-digit-string]: test whether a string contains only numeric digits. - [`isDomainName( value )`][@stdlib/assert/is-domain-name]: test if a value is a domain name. - [`isDurationString( value )`][@stdlib/assert/is-duration-string]: test if a value is a duration string. - [`isEmailAddress( value )`][@stdlib/assert/is-email-address]: test if a value is an email address. - [`isEmptyCollection( value )`][@stdlib/assert/is-empty-collection]: test if a value is an empty collection. - [`isEmptyObject( value )`][@stdlib/assert/is-empty-object]: test if a value is an empty object. - [`isEmptyString( value )`][@stdlib/assert/is-empty-string]: test if a value is an empty string. - [`isEnumerablePropertyIn( value, property )`][@stdlib/assert/is-enumerable-property-in]: test if an object's own or inherited property is enumerable. - [`isEnumerableProperty( value, property )`][@stdlib/assert/is-enumerable-property]: test if an object's own property is enumerable. - [`isEqualDateObject( d1, d2 )`][@stdlib/assert/is-equal-date-object]: test if two values are [Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) objects corresponding to the same date and time. - [`isEven( value )`][@stdlib/assert/is-even]: test if a value is an even number. - [`isFalsy( value )`][@stdlib/assert/is-falsy]: test if a value is falsy. - [`isFinite( value )`][@stdlib/assert/is-finite]: test if a value is a finite number. - [`isGeneratorObjectLike( value )`][@stdlib/assert/is-generator-object-like]: test if a value is `generator` object-like. - [`isGeneratorObject( value )`][@stdlib/assert/is-generator-object]: test if a value is a `generator` object. - [`isgzipBuffer( value )`][@stdlib/assert/is-gzip-buffer]: test if a value is a gzip buffer. - [`isHexString( value )`][@stdlib/assert/is-hex-string]: test whether a string contains only hexadecimal digits. - [`isInfinite( value )`][@stdlib/assert/is-infinite]: test if a value is an infinite number. - [`isInheritedProperty( value, property )`][@stdlib/assert/is-inherited-property]: test if an object has an inherited property. - [`isIterableLike( value )`][@stdlib/assert/is-iterable-like]: test if a value is `iterable`-like. - [`isIteratorLike( value )`][@stdlib/assert/is-iterator-like]: test if a value is `iterator`-like. - [`isJSON( value )`][@stdlib/assert/is-json]: test if a value is a parseable JSON string. - [`isKebabcase( value )`][@stdlib/assert/is-kebabcase]: test if a value is a string in kebab case. - [`isLeapYear( [value] )`][@stdlib/assert/is-leap-year]: test if a value corresponds to a leap year in the Gregorian calendar. - [`isLocalhost( value )`][@stdlib/assert/is-localhost]: test whether a value is a localhost hostname. - [`isLowercase( value )`][@stdlib/assert/is-lowercase]: test if a value is a lowercase string. - [`isMethodIn( value, property )`][@stdlib/assert/is-method-in]: test if an object has a specified method name, either own or inherited. - [`isMethod( value, property )`][@stdlib/assert/is-method]: test if an object has a specified method name. - [`isMultiSlice( value )`][@stdlib/assert/is-multi-slice]: test if a value is a `MultiSlice`. - [`isNamedTypedTupleLike( value )`][@stdlib/assert/is-named-typed-tuple-like]: test if a value is named typed tuple-like. - [`isNativeFunction( value )`][@stdlib/assert/is-native-function]: test if a value is a native function. - [`isNegativeZero( value )`][@stdlib/assert/is-negative-zero]: test if a value is a number equal to negative zero. - [`isNodeBuiltin( value )`][@stdlib/assert/is-node-builtin]: test whether a string matches a Node.js built-in module name. - [`isNodeDuplexStreamLike( value )`][@stdlib/assert/is-node-duplex-stream-like]: test if a value is Node duplex stream-like. - [`isNodeReadableStreamLike( value )`][@stdlib/assert/is-node-readable-stream-like]: test if a value is Node readable stream-like. - [`isNodeREPL()`][@stdlib/assert/is-node-repl]: check if running in a Node.js REPL environment. - [`isNodeStreamLike( value )`][@stdlib/assert/is-node-stream-like]: test if a value is Node stream-like. - [`isNodeTransformStreamLike( value )`][@stdlib/assert/is-node-transform-stream-like]: test if a value is Node transform stream-like. - [`isNodeWritableStreamLike( value )`][@stdlib/assert/is-node-writable-stream-like]: test if a value is Node writable stream-like. - [`isNonConfigurablePropertyIn( value, property )`][@stdlib/assert/is-nonconfigurable-property-in]: test if an object's own or inherited property is non-configurable. - [`isNonConfigurableProperty( value, property )`][@stdlib/assert/is-nonconfigurable-property]: test if an object's own property is non-configurable. - [`isNonEnumerablePropertyIn( value, property )`][@stdlib/assert/is-nonenumerable-property-in]: test if an object's own or inherited property is non-enumerable. - [`isNonEnumerableProperty( value, property )`][@stdlib/assert/is-nonenumerable-property]: test if an object's own property is non-enumerable. - [`isNonNegativeFinite( value )`][@stdlib/assert/is-nonnegative-finite]: test if a value is a number having a nonnegative finite value. - [`isObjectLike( value )`][@stdlib/assert/is-object-like]: test if a value is object-like. - [`isOdd( value )`][@stdlib/assert/is-odd]: test if a value is an odd number. - [`isPascalcase( value )`][@stdlib/assert/is-pascalcase]: test if a value is a string in Pascal case. - [`isPlainObject( value )`][@stdlib/assert/is-plain-object]: test if a value is a plain object. - [`isPositiveZero( value )`][@stdlib/assert/is-positive-zero]: test if a value is a number equal to positive zero. - [`isPrime( value )`][@stdlib/assert/is-prime]: test if a value is a prime number. - [`isPrimitive( value )`][@stdlib/assert/is-primitive]: test if a value is a JavaScript primitive. - [`isPRNGLike( value )`][@stdlib/assert/is-prng-like]: test if a value is PRNG-like. - [`isProbability( value )`][@stdlib/assert/is-probability]: test if a value is a probability. - [`isPropertyKey( value )`][@stdlib/assert/is-property-key]: test whether a value is a property key. - [`isPrototypeOf( obj, prototype )`][@stdlib/assert/is-prototype-of]: test if an object's prototype chain contains a provided prototype. - [`isReadOnlyPropertyIn( value, property )`][@stdlib/assert/is-read-only-property-in]: test if an object's own or inherited property is read-only. - [`isReadOnlyProperty( value, property )`][@stdlib/assert/is-read-only-property]: test if an object's own property is read-only. - [`isReadWritePropertyIn( value, property )`][@stdlib/assert/is-read-write-property-in]: test if an object's own or inherited property is readable and writable. - [`isReadWriteProperty( value, property )`][@stdlib/assert/is-read-write-property]: test if an object's own property is readable and writable. - [`isReadablePropertyIn( value, property )`][@stdlib/assert/is-readable-property-in]: test if an object's own or inherited property is readable. - [`isReadableProperty( value, property )`][@stdlib/assert/is-readable-property]: test if an object's own property is readable. - [`isRegExpString( value )`][@stdlib/assert/is-regexp-string]: test if a value is a regular expression string. - [`isRelativePath( value )`][@stdlib/assert/is-relative-path]: test if a value is a relative path. - [`isRelativeURI( value )`][@stdlib/assert/is-relative-uri]: test whether a value is a relative URI. - [`isSameComplex128( v1, v2 )`][@stdlib/assert/is-same-complex128]: test if two arguments are both double-precision complex floating-point numbers and have the same value. - [`isSameComplex64( v1, v2 )`][@stdlib/assert/is-same-complex64]: test if two arguments are both single-precision complex floating-point numbers and have the same value. - [`isSameNativeClass( a, b )`][@stdlib/assert/is-same-native-class]: test if two arguments have the same native class. - [`isSameType( a, b )`][@stdlib/assert/is-same-type]: test if two arguments have the same type. - [`isSameValueZero( a, b )`][@stdlib/assert/is-same-value-zero]: test if two arguments are the same value. - [`isSameValue( a, b )`][@stdlib/assert/is-same-value]: test if two arguments are the same value. - [`isSemVer( value )`][@stdlib/assert/is-semver]: test if a value is a semantic version string. - [`isSlice( value )`][@stdlib/assert/is-slice]: test if a value is a `Slice`. - [`isSnakecase( value )`][@stdlib/assert/is-snakecase]: test if a value is a string in snake case. - [`isStartcase( value )`][@stdlib/assert/is-startcase]: test if a value is a startcase string. - [`isStrictEqual( a, b )`][@stdlib/assert/is-strict-equal]: test if two arguments are strictly equal. - [`isStructConstructorLike( value )`][@stdlib/assert/is-struct-constructor-like]: test if a value is struct constructor-like. - [`isStruct( value )`][@stdlib/assert/is-struct]: test if a value is a `struct` instance. - [`isTruthy( value )`][@stdlib/assert/is-truthy]: test if a value is truthy. - [`isUNCPath( value )`][@stdlib/assert/is-unc-path]: test if a value is a UNC path. - [`isUndefinedOrNull( value )`][@stdlib/assert/is-undefined-or-null]: test if a value is undefined or null. - [`isUppercase( value )`][@stdlib/assert/is-uppercase]: test if a value is an uppercase string. - [`isURI( value )`][@stdlib/assert/is-uri]: test if a value is a URI. - [`isWebAssemblyMemory( value )`][@stdlib/assert/is-wasm-memory]: test if a value is a WebAssembly memory instance. - [`isWhitespace( value )`][@stdlib/assert/is-whitespace]: test whether a string contains only white space characters. - [`isWritablePropertyIn( value, property )`][@stdlib/assert/is-writable-property-in]: test if an object's own or inherited property is writable. - [`isWritableProperty( value, property )`][@stdlib/assert/is-writable-property]: test if an object's own property is writable. - [`isWriteOnlyPropertyIn( value, property )`][@stdlib/assert/is-write-only-property-in]: test if an object's own or inherited property is write-only. - [`isWriteOnlyProperty( value, property )`][@stdlib/assert/is-write-only-property]: test if an object's own property is write-only. - [`tools`][@stdlib/assert/tools]: assertion utility tools.
## Examples ```javascript var objectKeys = require( '@stdlib/utils/keys' ); var assert = require( '@stdlib/assert' ); console.log( objectKeys( assert ) ); ```
* * * ## Notice This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. #### Community [![Chat][chat-image]][chat-url] --- ## License See [LICENSE][stdlib-license]. ## Copyright Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors].

Owner

  • Name: stdlib
  • Login: stdlib-js
  • Kind: organization

Standard library for JavaScript.

Citation (CITATION.cff)

cff-version: 1.2.0
title: stdlib
message: >-
  If you use this software, please cite it using the
  metadata from this file.

type: software

authors:
  - name: The Stdlib Authors
    url: https://github.com/stdlib-js/stdlib/graphs/contributors

repository-code: https://github.com/stdlib-js/stdlib
url: https://stdlib.io

abstract: |
  Standard library for JavaScript and Node.js.

keywords:
  - JavaScript
  - Node.js
  - TypeScript
  - standard library
  - scientific computing
  - numerical computing
  - statistical computing

license: Apache-2.0 AND BSL-1.0

date-released: 2016

GitHub Events

Total
  • Push event: 207
  • Create event: 7
Last Year
  • Push event: 207
  • Create event: 7

Committers

Last synced: almost 2 years ago

All Time
  • Total Commits: 226
  • Total Committers: 1
  • Avg Commits per committer: 226.0
  • Development Distribution Score (DDS): 0.0
Past Year
  • Commits: 70
  • Committers: 1
  • Avg Commits per committer: 70.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
stdlib-bot n****y@s****o 226
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: about 1 year ago

All Time
  • Total issues: 0
  • Total pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Total issue authors: 0
  • Total pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • npm 88,264 last-month
  • Total docker downloads: 481,210,190
  • Total dependent packages: 44
  • Total dependent repositories: 292
  • Total versions: 20
  • Total maintainers: 4
npmjs.org: @stdlib/assert

Standard assertion utilities.

  • Homepage: https://stdlib.io
  • License: Apache-2.0
  • Latest release: 0.3.3
    published about 1 year ago
  • Versions: 20
  • Dependent Packages: 44
  • Dependent Repositories: 292
  • Downloads: 88,264 Last month
  • Docker Downloads: 481,210,190
Rankings
Docker downloads count: 0.1%
Downloads: 0.6%
Dependent packages count: 0.7%
Dependent repos count: 0.9%
Average: 5.1%
Stargazers count: 13.1%
Forks count: 15.4%
Funding
  • type: opencollective
  • url: https://opencollective.com/stdlib
Last synced: 4 months ago

Dependencies

package.json npm
  • @stdlib/bench github:stdlib-js/bench development
  • @stdlib/bigint github:stdlib-js/bigint development
  • @stdlib/buffer github:stdlib-js/buffer development
  • @stdlib/datasets github:stdlib-js/datasets development
  • @stdlib/object github:stdlib-js/object development
  • @stdlib/random github:stdlib-js/random development
  • istanbul ^0.4.1 development
  • proxyquire ^2.0.0 development
  • tap-spec 5.x.x development
  • tape git+https://github.com/kgryte/tape.git#fix/globby development
  • @stdlib/array github:stdlib-js/array#main
  • @stdlib/boolean github:stdlib-js/boolean#main
  • @stdlib/cli github:stdlib-js/cli#main
  • @stdlib/complex github:stdlib-js/complex#main
  • @stdlib/constants github:stdlib-js/constants#main
  • @stdlib/fs github:stdlib-js/fs#main
  • @stdlib/function github:stdlib-js/function#main
  • @stdlib/math github:stdlib-js/math#main
  • @stdlib/ndarray github:stdlib-js/ndarray#main
  • @stdlib/number github:stdlib-js/number#main
  • @stdlib/os github:stdlib-js/os#main
  • @stdlib/process github:stdlib-js/process#main
  • @stdlib/regexp github:stdlib-js/regexp#main
  • @stdlib/streams github:stdlib-js/streams#main
  • @stdlib/string github:stdlib-js/string#main
  • @stdlib/symbol github:stdlib-js/symbol#main
  • @stdlib/types github:stdlib-js/types#main
  • @stdlib/utils github:stdlib-js/utils#main
.github/workflows/benchmark.yml actions
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
.github/workflows/cancel.yml actions
  • styfle/cancel-workflow-action 0.11.0 composite
.github/workflows/close_pull_requests.yml actions
  • superbrothers/close-pull-request v3 composite
.github/workflows/examples.yml actions
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
.github/workflows/npm_downloads.yml actions
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
  • actions/upload-artifact v3 composite
  • distributhor/workflow-webhook v3 composite
.github/workflows/productionize.yml actions
  • act10ns/slack v1 composite
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
  • stdlib-js/bundle-action main composite
  • stdlib-js/transform-errors-action main composite
.github/workflows/publish.yml actions
  • JS-DevTools/npm-publish v1 composite
  • act10ns/slack v1 composite
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
  • styfle/cancel-workflow-action 0.11.0 composite
.github/workflows/test.yml actions
  • act10ns/slack v1 composite
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
.github/workflows/test_bundles.yml actions
  • act10ns/slack v1 composite
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
  • denoland/setup-deno v1 composite
.github/workflows/test_coverage.yml actions
  • act10ns/slack v1 composite
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
  • codecov/codecov-action v3 composite
  • distributhor/workflow-webhook v3 composite
.github/workflows/test_install.yml actions
  • act10ns/slack v1 composite
  • actions/checkout v3 composite
  • actions/setup-node v3 composite