validate.io-typed-array

1.0.0 • Public • Published

typed array

NPM version Build Status Coverage Status Dependencies

Validates if a value is a typed array.

Installation

$ npm install validate.io-typed-array

For use in the browser, use browserify.

Usage

var isTypedArray = require( 'validate.io-typed-array' );

isTypedArray( value )

Validates if a value is a typed array.

var bool = isTypedArray( new Int8Array( 10 ) );
// returns true

Examples

var isTypedArray = require( 'validate.io-typed-array' );
 
var arr = new Int8Array( 10 );
console.log( isTypedArray( arr ) );
// returns true
 
arr = new Uint8Array( 10 );
console.log( isTypedArray( arr ) );
// returns true
 
arr = new Uint8ClampedArray( 10 );
console.log( isTypedArray( arr ) );
// returns true
 
arr = new Int16Array( 10 );
console.log( isTypedArray( arr ) );
// returns true
 
arr = new Uint16Array( 10 );
console.log( isTypedArray( arr ) );
// returns true
 
arr = new Int32Array( 10 );
console.log( isTypedArray( arr ) );
// returns true
 
arr = new Uint32Array( 10 );
console.log( isTypedArray( arr ) );
// returns true
 
arr = new Float32Array( 10 );
console.log( isTypedArray( arr ) );
// returns true
 
arr = new Float64Array( 10 );
console.log( isTypedArray( arr ) );
// returns true
 
console.log( isTypedArray( [] ) );
// returns false
 
console.log( isTypedArray( {} ) );
// returns false
 
console.log( isTypedArray( null ) );
// returns false
 
console.log( isTypedArray( new Buffer( 10 ) ) );
// returns false

To run the example code from the top-level application directory,

$ node ./examples/index.js

Tests

Unit

Unit tests use the Mocha test framework with Chai assertions. To run the tests, execute the following command in the top-level application directory:

$ make test

All new feature development should have corresponding unit tests to validate correct functionality.

Test Coverage

This repository uses Istanbul as its code coverage tool. To generate a test coverage report, execute the following command in the top-level application directory:

$ make test-cov

Istanbul creates a ./reports/coverage directory. To access an HTML version of the report,

$ make view-cov

License

MIT license.

Copyright

Copyright © 2015. Athan Reines.

Package Sidebar

Install

npm i validate.io-typed-array

Weekly Downloads

2

Version

1.0.0

License

MIT

Last publish

Collaborators

  • kgryte