diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e874cf2..5460841d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1049,6 +1049,7 @@ This release closes the following issue: ##### Features +- [`de50d0a`](https://github.com/stdlib-js/stdlib/commit/de50d0af5f4b9a466a87be81da737fdbed48dbf3) - add `reverse` and `toReversed` methods to `array/bool` [(#2390)](https://github.com/stdlib-js/stdlib/pull/2390) - [`5cd4a70`](https://github.com/stdlib-js/stdlib/commit/5cd4a70beaa7663d2a822b0922b3fb3cc6ec539f) - add `findIndex` and `findLastIndex` methods to `array/bool` [(#2384)](https://github.com/stdlib-js/stdlib/pull/2384) - [`cba0d92`](https://github.com/stdlib-js/stdlib/commit/cba0d9249a25664a0b52f3ea2fe65eeddedd1e59) - add `find` and `findLast` methods to `array/bool` [(#2376)](https://github.com/stdlib-js/stdlib/pull/2376) - [`d71d044`](https://github.com/stdlib-js/stdlib/commit/d71d04433120ab3096fb01c546d96c60c7684681) - add `sort` method to `array/bool` [(#2363)](https://github.com/stdlib-js/stdlib/pull/2363) @@ -1939,6 +1940,7 @@ A total of 13 people contributed to this release. Thank you to the following con
+- [`de50d0a`](https://github.com/stdlib-js/stdlib/commit/de50d0af5f4b9a466a87be81da737fdbed48dbf3) - **feat:** add `reverse` and `toReversed` methods to `array/bool` [(#2390)](https://github.com/stdlib-js/stdlib/pull/2390) _(by Jaysukh Makvana, Athan Reines)_ - [`95c263b`](https://github.com/stdlib-js/stdlib/commit/95c263b85149d1b663852066e1e2e33d9dc718dd) - **docs:** update namespace table of contents [(#2400)](https://github.com/stdlib-js/stdlib/pull/2400) _(by stdlib-bot, Philipp Burckhardt)_ - [`074cbef`](https://github.com/stdlib-js/stdlib/commit/074cbef3f9d616c37c2be856a949e257481ff2fc) - **docs:** add note concerning broadcasting of nested array elements _(by Athan Reines)_ - [`b079d65`](https://github.com/stdlib-js/stdlib/commit/b079d653226019925581555fdaf9aa927ec69c0e) - **feat:** add support for integer array indexing assignment _(by Athan Reines)_ diff --git a/bool/README.md b/bool/README.md index e64ad463..5801221a 100644 --- a/bool/README.md +++ b/bool/README.md @@ -629,6 +629,32 @@ var count = context.count; // returns 3; ``` + + +#### BooleanArray.prototype.reverse() + +Reverses an array in-place. + +```javascript +var arr = new BooleanArray( 3 ); + +arr.set( true, 0 ); +arr.set( false, 1 ); +arr.set( false, 2 ); + +var out = arr.reverse(); +// returns + +var v = out.get( 0 ); +// returns false + +v = out.get( 1 ); +// returns false + +v = out.get( 2 ); +// returns true +``` + #### BooleanArray.prototype.set( v\[, i] ) @@ -738,6 +764,32 @@ The function should return a number where: - a positive value indicates that `a` should come after `b`. - zero or `NaN` indicates that `a` and `b` are considered equal. + + +#### BooleanArray.prototype.toReversed() + +Returns a new typed array containing the elements in reversed order. + +```javascript +var arr = new BooleanArray( 3 ); + +arr.set( true, 0 ); +arr.set( false, 1 ); +arr.set( false, 2 ); + +var out = arr.toReversed(); +// returns + +var v = out.get( 0 ); +// returns false + +v = out.get( 1 ); +// returns false + +v = out.get( 2 ); +// returns true +``` + diff --git a/bool/benchmark/benchmark.reverse.js b/bool/benchmark/benchmark.reverse.js new file mode 100644 index 00000000..722b0b80 --- /dev/null +++ b/bool/benchmark/benchmark.reverse.js @@ -0,0 +1,51 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var isBooleanArray = require( '@stdlib/assert/is-booleanarray' ); +var pkg = require( './../package.json' ).name; +var BooleanArray = require( './../lib' ); + + +// MAIN // + +bench( pkg+':reverse', function benchmark( b ) { + var out; + var arr; + var i; + + arr = new BooleanArray( [ true, false, false, true ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.reverse(); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isBooleanArray( out ) ) { + b.fail( 'should return a BooleanArray' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/bool/benchmark/benchmark.reverse.length.js b/bool/benchmark/benchmark.reverse.length.js new file mode 100644 index 00000000..b3e3b7c5 --- /dev/null +++ b/bool/benchmark/benchmark.reverse.length.js @@ -0,0 +1,103 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var isBooleanArray = require( '@stdlib/assert/is-booleanarray' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var Boolean = require( '@stdlib/boolean/ctor' ); +var pkg = require( './../package.json' ).name; +var BooleanArray = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var arr; + var i; + + arr = []; + for ( i = 0; i < len; i++ ) { + arr.push( Boolean( i%2 ) ); + } + arr = new BooleanArray( arr ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var out; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.reverse(); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isBooleanArray( out ) ) { + b.fail( 'should return a BooleanArray' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( pkg+':reverse:len='+len, f ); + } +} + +main(); diff --git a/bool/benchmark/benchmark.to_reversed.js b/bool/benchmark/benchmark.to_reversed.js new file mode 100644 index 00000000..f8f840da --- /dev/null +++ b/bool/benchmark/benchmark.to_reversed.js @@ -0,0 +1,51 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var isBooleanArray = require( '@stdlib/assert/is-booleanarray' ); +var pkg = require( './../package.json' ).name; +var BooleanArray = require( './../lib' ); + + +// MAIN // + +bench( pkg+':toReversed', function benchmark( b ) { + var out; + var arr; + var i; + + arr = new BooleanArray( [ true, false, false, true ] ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.toReversed(); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isBooleanArray( out ) ) { + b.fail( 'should return a BooleanArray' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/bool/benchmark/benchmark.to_reversed.length.js b/bool/benchmark/benchmark.to_reversed.length.js new file mode 100644 index 00000000..da5511f6 --- /dev/null +++ b/bool/benchmark/benchmark.to_reversed.length.js @@ -0,0 +1,103 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var isBooleanArray = require( '@stdlib/assert/is-booleanarray' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var Boolean = require( '@stdlib/boolean/ctor' ); +var pkg = require( './../package.json' ).name; +var BooleanArray = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var arr; + var i; + + arr = []; + for ( i = 0; i < len; i++ ) { + arr.push( Boolean( i%2 ) ); + } + arr = new BooleanArray( arr ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var out; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = arr.toReversed(); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isBooleanArray( out ) ) { + b.fail( 'should return a BooleanArray' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( pkg+':toReversed:len='+len, f ); + } +} + +main(); diff --git a/bool/docs/repl.txt b/bool/docs/repl.txt index f9205402..b80f9d70 100644 --- a/bool/docs/repl.txt +++ b/bool/docs/repl.txt @@ -491,6 +491,29 @@ false +{{alias}}.prototype.reverse() + Reverses the array *in-place*. + + This method mutates the array on which the method is invoked. + + Returns + ------- + out: BooleanArray + Modified array. + + Examples + -------- + > var arr = new {{alias}}( [ true, false, false ] ) + + > arr.reverse(); + > var v = arr.get( 0 ) + false + > v = arr.get( 1 ) + false + > v = arr.get( 2 ) + true + + {{alias}}.prototype.set( v[, i] ) Sets one or more array elements. @@ -558,5 +581,27 @@ false +{{alias}}.prototype.toReversed() + Returns a new typed array containing the elements in reversed order. + + Returns + ------- + out: BooleanArray + New typed array. + + Examples + -------- + > var arr = new {{alias}}( [ true, false, false ] ) + + > var out = arr.toReversed() + + > var v = out.get( 0 ) + false + > v = out.get( 1 ) + false + > v = out.get( 2 ) + true + + See Also -------- diff --git a/bool/docs/types/index.d.ts b/bool/docs/types/index.d.ts index 5120c684..154bbc13 100644 --- a/bool/docs/types/index.d.ts +++ b/bool/docs/types/index.d.ts @@ -415,6 +415,32 @@ declare class BooleanArray implements BooleanArrayInterface { */ map( fcn: MapFcn, thisArg?: ThisParameterType> ): BooleanArray; + /** + * Reverses an array in-place. + * + * @returns reversed array + * + * @example + * var arr = new BooleanArray( 3 ); + * + * arr.set( true, 0 ); + * arr.set( false, 1 ); + * arr.set( false, 2 ); + * + * var out = arr.reverse(); + * // returns + * + * var v = out.get( 0 ); + * // returns false + * + * v = out.get( 1 ); + * // returns false + * + * v = out.get( 2 ); + * // returns true + */ + reverse(): BooleanArray; + /** * Sets an array element. * @@ -496,6 +522,32 @@ declare class BooleanArray implements BooleanArrayInterface { * // returns false */ sort( compareFcn: CompareFcn ): BooleanArray; + + /** + * Returns a new typed array containing the elements in reversed order. + * + * @returns reversed array + * + * @example + * var arr = new BooleanArray( 3 ); + * + * arr.set( true, 0 ); + * arr.set( false, 1 ); + * arr.set( false, 2 ); + * + * var out = arr.toReversed(); + * // returns + * + * var v = out.get( 0 ); + * // returns false + * + * v = out.get( 1 ); + * // returns false + * + * v = out.get( 2 ); + * // returns true + */ + toReversed(): BooleanArray; } /** diff --git a/bool/lib/main.js b/bool/lib/main.js index e6fa9928..550d79f8 100644 --- a/bool/lib/main.js +++ b/bool/lib/main.js @@ -34,6 +34,7 @@ var setReadOnlyAccessor = require( '@stdlib/utils/define-nonenumerable-read-only var Uint8Array = require( './../../uint8' ); var Boolean = require( '@stdlib/boolean/ctor' ); var getter = require( './../../base/getter' ); +var floor = require( '@stdlib/math/base/special/floor' ); var accessorGetter = require( './../../base/accessor-getter' ); var format = require( '@stdlib/string/format' ); var fromIterator = require( './from_iterator.js' ); @@ -745,6 +746,57 @@ setReadOnly( BooleanArray.prototype, 'map', function map( fcn, thisArg ) { return out; }); +/** +* Reverses an array in-place. +* +* @name reverse +* @memberof BooleanArray.prototype +* @type {Function} +* @throws {TypeError} `this` must be a boolean array +* @returns {BooleanArray} reversed array +* +* @example +* var arr = new BooleanArray( 3 ); +* +* arr.set( true, 0 ); +* arr.set( false, 1 ); +* arr.set( false, 2 ); +* +* var out = arr.reverse(); +* // returns +* +* var v = out.get( 0 ); +* // returns false +* +* v = out.get( 1 ); +* // returns false +* +* v = out.get( 2 ); +* // returns true +*/ +setReadOnly( BooleanArray.prototype, 'reverse', function reverse() { + var buf; + var tmp; + var len; + var N; + var i; + var j; + + if ( !isBooleanArray( this ) ) { + throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); + } + buf = this._buffer; + len = this._length; + N = floor( len / 2 ); + for ( i = 0; i < N; i++ ) { + j = len - i - 1; + tmp = buf[ i ]; + buf[ i ] = buf[ j ]; + buf[ j ] = tmp; + } + return this; +}); + /** * Sets an array element. * @@ -920,6 +972,54 @@ setReadOnly( BooleanArray.prototype, 'sort', function sort( compareFcn ) { } }); +/** +* Returns a new typed array containing the elements in reversed order. +* +* @name toReversed +* @memberof BooleanArray.prototype +* @type {Function} +* @throws {TypeError} `this` must be a boolean array +* @returns {BooleanArray} reversed array +* +* @example +* var arr = new BooleanArray( 3 ); +* +* arr.set( true, 0 ); +* arr.set( false, 1 ); +* arr.set( false, 2 ); +* +* var out = arr.toReversed(); +* // returns +* +* var v = out.get( 0 ); +* // returns false +* +* v = out.get( 1 ); +* // returns false +* +* v = out.get( 2 ); +* // returns true +*/ +setReadOnly( BooleanArray.prototype, 'toReversed', function toReversed() { + var outbuf; + var out; + var len; + var buf; + var i; + + if ( !isBooleanArray( this ) ) { + throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); + } + len = this._length; + out = new this.constructor( len ); + buf = this._buffer; + outbuf = out._buffer; // eslint-disable-line no-underscore-dangle + for ( i = 0; i < len; i++ ) { + outbuf[ i ] = buf[ len - i - 1 ]; + } + return out; +}); + // EXPORTS // diff --git a/bool/test/test.reverse.js b/bool/test/test.reverse.js new file mode 100644 index 00000000..799a95a2 --- /dev/null +++ b/bool/test/test.reverse.js @@ -0,0 +1,114 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var reinterpretBoolean = require( '@stdlib/strided/base/reinterpret-boolean' ); +var instanceOf = require( '@stdlib/assert/instance-of' ); +var Uint8Array = require( './../../uint8' ); +var BooleanArray = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the main export is a `reverse` method', function test( t ) { + t.strictEqual( hasOwnProp( BooleanArray.prototype, 'reverse' ), true, 'has property' ); + t.strictEqual( isFunction( BooleanArray.prototype.reverse ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { + var values; + var arr; + var i; + + arr = new BooleanArray( 5 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.reverse.call( value ); + }; + } +}); + +tape( 'the method returns an empty array if operating on an empty boolean array', function test( t ) { + var arr; + var out; + + arr = new BooleanArray(); + out = arr.reverse(); + + t.strictEqual( out.buffer, arr.buffer, 'returns expected value' ); + t.strictEqual( out.length, 0, 'returns expected value' ); + t.end(); +}); + +tape( 'the method reverses elements of a boolean array in-place', function test( t ) { + var expected; + var arr; + var out; + + arr = new BooleanArray( [ true, false, false, true, true, false ] ); + expected = new Uint8Array( [ 0, 1, 1, 0, 0, 1 ] ); + out = arr.reverse(); + + t.strictEqual( instanceOf( arr, BooleanArray ), true, 'returns expected value' ); + t.strictEqual( out, arr, 'returns expected value' ); + t.strictEqual( arr.length, expected.length, 'returns expected value' ); + t.deepEqual( reinterpretBoolean( arr, 0 ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the method does not change the array length', function test( t ) { + var arr; + var out; + + arr = new BooleanArray( 10 ); + out = arr.reverse(); + + t.strictEqual( out.length, 10, 'returns expected value' ); + t.end(); +}); diff --git a/bool/test/test.to_reversed.js b/bool/test/test.to_reversed.js new file mode 100644 index 00000000..33148545 --- /dev/null +++ b/bool/test/test.to_reversed.js @@ -0,0 +1,113 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var reinterpretBoolean = require( '@stdlib/strided/base/reinterpret-boolean' ); +var instanceOf = require( '@stdlib/assert/instance-of' ); +var Uint8Array = require( './../../uint8' ); +var BooleanArray = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the prototype of the main export is a `toReversed` method', function test( t ) { + t.strictEqual( hasOwnProp( BooleanArray.prototype, 'toReversed' ), true, 'has property' ); + t.strictEqual( isFunction( BooleanArray.prototype.toReversed ), true, 'has method' ); + t.end(); +}); + +tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { + var values; + var arr; + var i; + + arr = new BooleanArray( 5 ); + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [], + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return arr.toReversed.call( value ); + }; + } +}); + +tape( 'the method returns an empty array if operating on an empty boolean array', function test( t ) { + var arr; + var out; + + arr = new BooleanArray(); + out = arr.toReversed(); + + t.strictEqual( out.length, 0, 'returns expected value' ); + t.end(); +}); + +tape( 'the method returns a new typed array containing elements in reverse order', function test( t ) { + var expected; + var arr; + var out; + + arr = new BooleanArray( [ true, false, false, true, true, false ] ); + expected = new Uint8Array( [ 0, 1, 1, 0, 0, 1 ] ); + out = arr.toReversed(); + + t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); + t.notEqual( out, arr, 'returns a new instance' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( reinterpretBoolean( out, 0 ), expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the method does not change the array length', function test( t ) { + var arr; + var out; + + arr = new BooleanArray( 10 ); + out = arr.toReversed(); + + t.strictEqual( out.length, 10, 'returns expected value' ); + t.end(); +});