0.2.2 • Published 5 months ago

@stdlib/assert-is-collection v0.2.2

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
5 months ago

isCollection

NPM version Build Status Coverage Status

Test if a value is a collection.

A collection is defined as either an Array, Typed Array, or an array-like Object (excluding strings and functions).

Installation

npm install @stdlib/assert-is-collection

Usage

var isCollection = require( '@stdlib/assert-is-collection' );

isCollection( value )

Tests if a value is a collection.

var bool = isCollection( [] );
// returns true

Examples

var Int8Array = require( '@stdlib/array-int8' );
var Uint8Array = require( '@stdlib/array-uint8' );
var Uint8ClampedArray = require( '@stdlib/array-uint8c' );
var Int16Array = require( '@stdlib/array-int16' );
var Uint16Array = require( '@stdlib/array-uint16' );
var Int32Array = require( '@stdlib/array-int32' );
var Uint32Array = require( '@stdlib/array-uint32' );
var Float32Array = require( '@stdlib/array-float32' );
var Float64Array = require( '@stdlib/array-float64' );
var isCollection = require( '@stdlib/assert-is-collection' );

var bool = isCollection( [] );
// returns true

bool = isCollection( new Float64Array( 10 ) );
// returns true

bool = isCollection( new Float32Array( 10 ) );
// returns true

bool = isCollection( new Int32Array( 10 ) );
// returns true

bool = isCollection( new Uint32Array( 10 ) );
// returns true

bool = isCollection( new Int16Array( 10 ) );
// returns true

bool = isCollection( new Uint16Array( 10 ) );
// returns true

bool = isCollection( new Int8Array( 10 ) );
// returns true

bool = isCollection( new Uint8Array( 10 ) );
// returns true

bool = isCollection( new Uint8ClampedArray( 10 ) );
// returns true

bool = isCollection( { 'length': 0 } );
// returns true

bool = isCollection( {} );
// returns false

bool = isCollection( 'beep' );
// returns false

bool = isCollection( isCollection );
// returns false

bool = isCollection( null );
// returns false

bool = isCollection( void 0 );
// returns false

bool = isCollection( 3.14 );
// returns false

See Also


Notice

This package is part of 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, see the main project repository.

Community

Chat


License

See LICENSE.

Copyright

Copyright © 2016-2024. The Stdlib Authors.

@infinitebrahmanuniverse/nolb-_stdlib_a@everything-registry/sub-chunk-867@stdlib/array-base-accessor@stdlib/array-base-assert-contains@stdlib/array-from-iterator@stdlib/array-index@stdlib/array-linspace@stdlib/array-complex64@stdlib/array-convert@stdlib/array-filled@stdlib/array-filled-by@stdlib/array-bool@stdlib/array-cartesian-power@stdlib/array-cartesian-product@stdlib/array-cartesian-square@stdlib/array-complex128@stdlib/array-slice@stdlib/array-take@stdlib/array-to-circular-iterator@stdlib/array-to-fancy@stdlib/array-to-iterator@stdlib/array-to-iterator-right@stdlib/array-to-sparse-iterator@stdlib/array-to-sparse-iterator-right@stdlib/array-to-strided-iterator@stdlib/array-to-view-iterator@stdlib/array-mskfilter@stdlib/array-mskput@stdlib/array-mskreject@stdlib/array-place@stdlib/array-pool@stdlib/array-put@stdlib/assert-contains@stdlib/array-to-view-iterator-right@stdlib/utils-mask-arguments@stdlib/utils-named-typed-tuple@stdlib/utils-some@stdlib/utils-some-by@stdlib/utils-some-by-right@stdlib/utils-tabulate@stdlib/utils-tabulate-by@stdlib/utils-key-by-right@stdlib/utils-none@stdlib/utils-none-by@stdlib/utils-none-by-right@stdlib/utils-pick-arguments@stdlib/utils-prepend@stdlib/utils-inmap@stdlib/utils-inmap-right@stdlib/utils-key-by@stdlib/utils-reduce2d@stdlib/streams-node-from-strided-array@stdlib/streams-node-from-array@stdlib/streams-node-from-circular-array@stdlib/stats-ranks@stdlib/strided-dispatch@stdlib/strided-dispatch-by@stdlib/stats-kruskal-test@stdlib/ndarray-iter-indices@stdlib/ndarray-stride@stdlib/ndarray-strides@stdlib/ndarray-broadcast-array@stdlib/ndarray-ctor@stdlib/ndarray-data-buffer@stdlib/ndarray-dispatch@stdlib/ndarray-dispatch-by@stdlib/ndarray-ndims@stdlib/ndarray-numel@stdlib/ndarray-offset@stdlib/ndarray-shape@stdlib/ndarray-maybe-broadcast-array@stdlib/stats-chi2gof@stdlib/stats-chi2test@stdlib/stats-fligner-test@stdlib/stats-bartlett-test@stdlib/assert-is-accessor-array@stdlib/assert-is-between-array@stdlib/blas-gdot@stdlib/blas-gswap@stdlib/buffer-from-array@stdlib/random-base-minstd@stdlib/random-base-minstd-shuffle@stdlib/random-base-mt19937@stdlib/random-array-tools-ternary@stdlib/random-array-tools-unary@stdlib/random-array-tools-binary@stdlib/random-array-tools-nullary@stdlib/utils-async-inmap@stdlib/utils-async-inmap-right@stdlib/utils-async-none-by@stdlib/utils-async-none-by-right@stdlib/utils-async-reduce@stdlib/utils-async-reduce-right@stdlib/utils-do-until-each@stdlib/utils-do-until-each-right@stdlib/utils-do-while-each@stdlib/utils-do-while-each-right@stdlib/utils-async-some-by@stdlib/utils-async-some-by-right@stdlib/utils-async-tabulate-by
0.2.2

5 months ago

0.2.1

10 months ago

0.2.0

10 months ago

0.1.0

1 year ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago