validate.io-square-matrix v1.0.0
Square Matrix
Validates if a value is an array of arrays and has equal dimensions.
Installation
$ npm install validate.io-square-matrixFor use in the browser, use browserify.
Usage
var isSquareMatrix = require( 'validate.io-square-matrix' );isSquareMatrix( value )
Validates if a value is an array of arrays and has equal dimensions.
var value = [[1,2],[1,2]];
var bool = isSquareMatrix( value );
// returns trueNote: the method first validates that an input value is an array of arrays. For any other input, the method returns false.
Examples
var isSquareMatrix = require( 'validate.io-square-matrix' );
console.log( isSquareMatrix( [[1,2],[1,2]] ) );
// returns true
console.log( isSquareMatrix( [] ) );
// returns false
console.log( isSquareMatrix( [[]] ) );
// returns false
console.log( isSquareMatrix( [[1,2]] ) );
// returns false
console.log( isSquareMatrix( [[1,2],[1]] ) );
// returns false
console.log( isSquareMatrix( [[1],[2]] ) );
// returns falseTo run the example code from the top-level application directory,
$ node ./examples/index.jsTests
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 testAll 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-covIstanbul creates a ./reports/coverage directory. To access an HTML version of the report,
$ make view-covLicense
Copyright
Copyright © 2015. Athan Reines.