8000 GitHub - stdlib-js/array-bool at a6d4f67e354e636571122411fa059b0193a9f9fc
[go: up one dir, main page]

Skip to content

stdlib-js/array-bool

Repository files navigation

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!

BooleanArray

NPM version Build Status Coverage Status

Boolean array.

Installation

npm install @stdlib/array-bool

Alternatively,

  • To load the package in a website via a script tag without installation and bundlers, use the ES Module available on the esm branch (see README).
  • If you are using Deno, visit the deno branch (see README for usage intructions).
  • For use in Observable, or in browser/node environments, use the Universal Module Definition (UMD) build available on the umd branch (see README).

The branches.md 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

var BooleanArray = require( '@stdlib/array-bool' );

BooleanArray()

Creates a boolean array.

var arr = new BooleanArray();
// returns <BooleanArray>

BooleanArray( length )

Creates a boolean array having a specified length.

var arr = new BooleanArray( 10 );
// returns <BooleanArray>

var len = arr.length;
// returns 10

BooleanArray( booleanarray )

Creates a boolean array from another boolean array.

var arr1 = new BooleanArray( [ true, false, false, true ] );
// returns <BooleanArray>

var arr2 = new BooleanArray( arr1 );
// returns <BooleanArray>

var len = arr2.length;
// returns 4

BooleanArray( typedarray )

Creates a boolean array from a typed array.

var Uint8Array = require( '@stdlib/array-uint8' );

var buf = new Uint8Array( [ 1, 0, 0, 1 ] );
// returns <Uint8Array>[ 1, 0, 0, 1 ]

var arr = new BooleanArray( buf );
// returns <BooleanArray>

var len = arr.length;
// returns 4

BooleanArray( obj )

Creates a boolean array from an array-like object or iterable.

// From an array of booleans:
var arr1 = new BooleanArray( [ true, false, false, true ] );
// returns <BooleanArray>

var len = arr1.length;
// returns 4

// From an array containing non-booleans:
var arr2 = new BooleanArray( [ {}, null, '', 4 ] );

len = arr2.length;
// returns 4

BooleanArray( buffer[, byteOffset[, length]] )

Returns a boolean array view of an ArrayBuffer.

var ArrayBuffer = require( '@stdlib/array-buffer' );
var buf = new ArrayBuffer( 240 );

var arr1 = new BooleanArray( buf );
// returns <BooleanArray>

var len = arr1.length;
// returns 240

var arr2 = new BooleanArray( buf, 8 );
// returns <BooleanArray>

len = arr2.length;
// returns 232

var arr3 = new BooleanArray( buf, 8, 20 );
// returns <BooleanArray>

len = arr3.length;
// returns 20

Properties

BooleanArray.BYTES_PER_ELEMENT