From 512502441d98d45ea6ceb85b0dc632a99720d0cc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 9 May 2026 20:56:49 +0000 Subject: [PATCH 01/14] Transform error messages --- lib/polyfill/index.js | 102 +++++++++++++++++++++--------------------- package.json | 2 +- 2 files changed, 52 insertions(+), 52 deletions(-) diff --git a/lib/polyfill/index.js b/lib/polyfill/index.js index 5073dcb..063db06 100644 --- a/lib/polyfill/index.js +++ b/lib/polyfill/index.js @@ -38,7 +38,7 @@ var setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); var setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' ); var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var Uint16Array = require( '@stdlib/array-uint16' ); var f16 = require( '@stdlib/number-float64-base-to-float16' ); var toWord = require( '@stdlib/number-float16-base-to-word' ); @@ -234,49 +234,49 @@ function Float16Array() { } } else if ( isArrayBuffer( arg ) ) { if ( !isInteger( arg.byteLength/BYTES_PER_ELEMENT ) ) { - throw new RangeError( format( 'invalid argument. ArrayBuffer byte length must be a multiple of %u. Byte length: `%u`.', BYTES_PER_ELEMENT, arg.byteLength ) ); + throw new RangeError( format( 'nullE9', BYTES_PER_ELEMENT, arg.byteLength ) ); } buf = new Uint16Array( arg ); } else if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, ArrayBuffer, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( 'null29', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( 'null2A', arg ) ); } buf = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( buf.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( 'null2A', arg ) ); } buf = new Uint16Array( fromIterator( buf ) ); } else { - throw new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( 'null2A', arg ) ); } } else { buf = arguments[ 0 ]; if ( !isArrayBuffer( buf ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', buf ) ); + throw new TypeError( format( 'null2B', buf ) ); } byteOffset = arguments[ 1 ]; if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) ); + throw new TypeError( format( 'null2C', byteOffset ) ); } if ( !isInteger( byteOffset/BYTES_PER_ELEMENT ) ) { - throw new RangeError( format( 'invalid argument. Byte offset must be a multiple of %u. Value: `%u`.', BYTES_PER_ELEMENT, byteOffset ) ); + throw new RangeError( format( 'nullEA', BYTES_PER_ELEMENT, byteOffset ) ); } if ( nargs === 2 ) { len = buf.byteLength - byteOffset; if ( !isInteger( len/BYTES_PER_ELEMENT ) ) { - throw new RangeError( format( 'invalid arguments. ArrayBuffer view byte length must be a multiple of %u. View byte length: `%u`.', BYTES_PER_ELEMENT, len ) ); + throw new RangeError( format( 'null2E', BYTES_PER_ELEMENT, len ) ); } buf = new Uint16Array( buf, byteOffset ); } else { len = arguments[ 2 ]; if ( !isNonNegativeInteger( len ) ) { - throw new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', len ) ); + throw new TypeError( format( 'null2F', len ) ); } if ( (len*BYTES_PER_ELEMENT) > (buf.byteLength-byteOffset) ) { - throw new RangeError( format( 'invalid arguments. ArrayBuffer has insufficient capacity. Either decrease the array length or provide a bigger buffer. Minimum capacity: `%u`.', len*BYTES_PER_ELEMENT ) ); + throw new RangeError( format( 'null2G', len*BYTES_PER_ELEMENT ) ); } buf = new Uint16Array( buf, byteOffset, len ); } @@ -362,7 +362,7 @@ setReadOnly( Float16Array, 'from', function from( src ) { var len; var i; if ( !isFunction( this ) ) { - throw new TypeError( 'invalid invocation. `this` context must be a constructor.' ); + throw new TypeError( format('null01') ); } if ( !isFloatingPointArrayConstructor( this ) ) { throw new TypeError( 'invalid invocation. `this` is not a floating-point array.' ); @@ -371,7 +371,7 @@ setReadOnly( Float16Array, 'from', function from( src ) { if ( nargs > 1 ) { clbk = arguments[ 1 ]; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( 'null2H', clbk ) ); } if ( nargs > 2 ) { thisArg = arguments[ 2 ]; @@ -392,7 +392,7 @@ setReadOnly( Float16Array, 'from', function from( src ) { if ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) { // eslint-disable-line max-len buf = src[ ITERATOR_SYMBOL ](); if ( !isFunction( buf.next ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) ); + throw new TypeError( format( 'null2J', src ) ); } if ( clbk ) { tmp = fromIteratorMap( buf, clbk, thisArg ); @@ -410,7 +410,7 @@ setReadOnly( Float16Array, 'from', function from( src ) { } return out; } - throw new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) ); + throw new TypeError( format( 'null2J', src ) ); }); /** @@ -438,7 +438,7 @@ setReadOnly( Float16Array, 'of', function of() { var args; var i; if ( !isFunction( this ) ) { - throw new TypeError( 'invalid invocation. `this` context must be a constructor.' ); + throw new TypeError( format('null01') ); } if ( !isFloatingPointArrayConstructor( this ) ) { throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); @@ -478,7 +478,7 @@ setReadOnly( Float16Array.prototype, 'at', function at( idx ) { throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Must provide an integer. Value: `%s`.', idx ) ); + throw new TypeError( format( 'null8A', idx ) ); } if ( idx < 0 ) { idx += this._length; @@ -731,7 +731,7 @@ setReadOnly( Float16Array.prototype, 'every', function every( predicate, thisArg throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( 'null3c', predicate ) ); } buf = this._buffer; for ( i = 0; i < this._length; i++ ) { @@ -781,13 +781,13 @@ setReadOnly( Float16Array.prototype, 'fill', function fill( value, start, end ) throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isNumber( value ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a number. Value: `%s`.', value ) ); + throw new TypeError( format( 'null49', value ) ); } buf = this._buffer; len = this._length; if ( arguments.length > 1 ) { if ( !isInteger( start ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', start ) ); + throw new TypeError( format( 'null7f', start ) ); } if ( start < 0 ) { start += len; @@ -797,7 +797,7 @@ setReadOnly( Float16Array.prototype, 'fill', function fill( value, start, end ) } if ( arguments.length > 2 ) { if ( !isInteger( end ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', end ) ); + throw new TypeError( format( 'null2z', end ) ); } if ( end < 0 ) { end += len; @@ -863,7 +863,7 @@ setReadOnly( Float16Array.prototype, 'filter', function filter( predicate, thisA throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( 'null3c', predicate ) ); } buf = this._buffer; out = []; @@ -907,7 +907,7 @@ setReadOnly( Float16Array.prototype, 'find', function find( predicate, thisArg ) throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( 'null3c', predicate ) ); } buf = this._buffer; for ( i = 0; i < this._length; i++ ) { @@ -949,7 +949,7 @@ setReadOnly( Float16Array.prototype, 'findIndex', function findIndex( predicate, throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( 'null3c', predicate ) ); } buf = this._buffer; for ( i = 0; i < this._length; i++ ) { @@ -992,7 +992,7 @@ setReadOnly( Float16Array.prototype, 'findLast', function findLast( predicate, t throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( 'null3c', predicate ) ); } buf = this._buffer; for ( i = this._length-1; i >= 0; i-- ) { @@ -1034,7 +1034,7 @@ setReadOnly( Float16Array.prototype, 'findLastIndex', function findLastIndex( pr throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( 'null3c', predicate ) ); } buf = this._buffer; for ( i = this._length-1; i >= 0; i-- ) { @@ -1074,7 +1074,7 @@ setReadOnly( Float16Array.prototype, 'forEach', function forEach( fcn, thisArg ) throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( 'null3c', fcn ) ); } buf = this._buffer; for ( i = 0; i < this._length; i++ ) { @@ -1099,7 +1099,7 @@ setReadOnly( Float16Array.prototype, '_get', function get( idx ) { throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isNonNegativeInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Must provide a nonnegative integer. Value: `%s`.', idx ) ); + throw new TypeError( format( 'null2K', idx ) ); } if ( idx >= this._length ) { return; @@ -1141,11 +1141,11 @@ setReadOnly( Float16Array.prototype, 'includes', function includes( searchElemen throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isNumber( searchElement ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a number. Value: `%s`.', searchElement ) ); + throw new TypeError( format( 'null49', searchElement ) ); } if ( arguments.length > 1 ) { if ( !isInteger( fromIndex ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) ); + throw new TypeError( format( 'null7f', fromIndex ) ); } if ( fromIndex < 0 ) { fromIndex += this._length; @@ -1200,11 +1200,11 @@ setReadOnly( Float16Array.prototype, 'indexOf', function indexOf( searchElement, throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isNumber( searchElement ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a number. Value: `%s`.', searchElement ) ); + throw new TypeError( format( 'null49', searchElement ) ); } if ( arguments.length > 1 ) { if ( !isInteger( fromIndex ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) ); + throw new TypeError( format( 'null7f', fromIndex ) ); } if ( fromIndex < 0 ) { fromIndex += this._length; @@ -1255,7 +1255,7 @@ setReadOnly( Float16Array.prototype, 'join', function join( separator ) { } if ( arguments.length > 0 ) { if ( !isString( separator ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', separator ) ); + throw new TypeError( format( 'null3F', separator ) ); } } else { separator = ','; @@ -1404,11 +1404,11 @@ setReadOnly( Float16Array.prototype, 'lastIndexOf', function lastIndexOf( search throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isNumber( searchElement ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a number. Value: `%s`.', searchElement ) ); + throw new TypeError( format( 'null49', searchElement ) ); } if ( arguments.length > 1 ) { if ( !isInteger( fromIndex ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) ); + throw new TypeError( format( 'null7f', fromIndex ) ); } if ( fromIndex >= this._length ) { fromIndex = this._length - 1; @@ -1486,7 +1486,7 @@ setReadOnly( Float16Array.prototype, 'map', function map( fcn, thisArg ) { throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isFunction( fcn ) ) { - throw new TypeError( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ); + throw new TypeError( format('null3c'), fcn ); } buf = this._buffer; out = new this.constructor( this._length ); @@ -1529,7 +1529,7 @@ setReadOnly( Float16Array.prototype, 'reduce', function reduce( reducer, initial throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isFunction( reducer ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', reducer ) ); + throw new TypeError( format( 'null3c', reducer ) ); } buf = this._buffer; len = this._length; @@ -1581,7 +1581,7 @@ setReadOnly( Float16Array.prototype, 'reduceRight', function reduceRight( reduce throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isFunction( reducer ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', reducer ) ); + throw new TypeError( format( 'null3c', reducer ) ); } buf = this._buffer; len = this._length; @@ -1707,20 +1707,20 @@ setReadOnly( Float16Array.prototype, 'set', function set( value ) { throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isCollection( value ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', value ) ); + throw new TypeError( format( 'null2O', value ) ); } buf = this._buffer; if ( arguments.length > 1 ) { idx = arguments[ 1 ]; if ( !isNonNegativeInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Index argument must be a nonnegative integer. Value: `%s`.', idx ) ); + throw new TypeError( format( 'null2L', idx ) ); } } else { idx = 0; } N = value.length; if ( idx+N > this._length ) { - throw new RangeError( 'invalid arguments. Target array lacks sufficient storage to accommodate source values.' ); + throw new RangeError( format('null03') ); } if ( isFloat16Array( value ) ) { sbuf = value._buffer; // eslint-disable-line no-underscore-dangle @@ -1814,7 +1814,7 @@ setReadOnly( Float16Array.prototype, 'slice', function slice( begin, end ) { end = len; } else { if ( !isInteger( begin ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', begin ) ); + throw new TypeError( format( 'null7e', begin ) ); } if ( begin < 0 ) { begin += len; @@ -1826,7 +1826,7 @@ setReadOnly( Float16Array.prototype, 'slice', function slice( begin, end ) { end = len; } else { if ( !isInteger( end ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', end ) ); + throw new TypeError( format( 'null7f', end ) ); } if ( end < 0 ) { end += len; @@ -1881,7 +1881,7 @@ setReadOnly( Float16Array.prototype, 'some', function some( predicate, thisArg ) throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( 'null3c', predicate ) ); } buf = this._buffer; for ( i = 0; i < this._length; i++ ) { @@ -1939,7 +1939,7 @@ setReadOnly( Float16Array.prototype, 'sort', function sort( compareFcn ) { return this; } if ( !isFunction( compareFcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', compareFcn ) ); + throw new TypeError( format( 'null3c', compareFcn ) ); } buf.sort( compare ); return this; @@ -2044,7 +2044,7 @@ setReadOnly( Float16Array.prototype, 'subarray', function subarray( begin, end ) end = len; } else { if ( !isInteger( begin ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', begin ) ); + throw new TypeError( format( 'null7e', begin ) ); } if ( begin < 0 ) { begin += len; @@ -2056,7 +2056,7 @@ setReadOnly( Float16Array.prototype, 'subarray', function subarray( begin, end ) end = len; } else { if ( !isInteger( end ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', end ) ); + throw new TypeError( format( 'null7f', end ) ); } if ( end < 0 ) { end += len; @@ -2122,7 +2122,7 @@ setReadOnly( Float16Array.prototype, 'toLocaleString', function toLocaleString( } else if ( isObject( options ) ) { opts = options; } else { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( 'null2V', options ) ); } buf = this._buffer; out = []; @@ -2387,14 +2387,14 @@ setReadOnly( Float16Array.prototype, 'with', function copyWith( index, value ) { throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isInteger( index ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', index ) ); + throw new TypeError( format( 'null7e', index ) ); } len = this._length; if ( index < 0 ) { index += len; } if ( index < 0 || index >= len ) { - throw new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%s`.', index ) ); + throw new RangeError( format( 'nullFP', index ) ); } if ( !isNumber( value ) ) { throw new TypeError( format( 'invalid argument. Second argument must be a floating-point number. Value: `%s`.', value ) ); diff --git a/package.json b/package.json index ab1dfb2..476464f 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "@stdlib/number-float16-base-from-word": "^0.2.1", "@stdlib/number-float16-base-to-word": "^0.1.1", "@stdlib/number-float64-base-to-float16": "^0.1.2", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/symbol-iterator": "^0.2.3", "@stdlib/types": "^0.4.3", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.4", From 3972214fb5ecf054fd6b376fec401e6de696bd19 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 9 May 2026 20:57:33 +0000 Subject: [PATCH 02/14] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 204 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 50 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 49 +- SECURITY.md | 5 - benchmark/benchmark.at.js | 79 - benchmark/benchmark.copy_within.js | 52 - benchmark/benchmark.copy_within.length.js | 95 - benchmark/benchmark.entries.js | 52 - benchmark/benchmark.every.js | 83 - benchmark/benchmark.every.length.js | 107 - benchmark/benchmark.fill.js | 53 - benchmark/benchmark.fill.length.js | 97 - benchmark/benchmark.filter.js | 82 - benchmark/benchmark.filter.length.js | 106 - benchmark/benchmark.find.js | 84 - benchmark/benchmark.find.length.js | 106 - benchmark/benchmark.find_index.js | 84 - benchmark/benchmark.find_index.length.js | 106 - benchmark/benchmark.find_last.js | 84 - benchmark/benchmark.find_last.length.js | 106 - benchmark/benchmark.find_last_index.js | 84 - benchmark/benchmark.find_last_index.length.js | 110 - benchmark/benchmark.for_each.js | 90 - benchmark/benchmark.for_each.length.js | 108 - benchmark/benchmark.from.js | 238 - benchmark/benchmark.get.js | 55 - benchmark/benchmark.includes.js | 54 - benchmark/benchmark.includes.length.js | 97 - benchmark/benchmark.index_of.js | 54 - benchmark/benchmark.index_of.length.js | 96 - benchmark/benchmark.join.js | 53 - benchmark/benchmark.join.length.js | 96 - benchmark/benchmark.js | 338 -- benchmark/benchmark.keys.js | 52 - benchmark/benchmark.keys.length.js | 96 - benchmark/benchmark.last_index_of.js | 53 - benchmark/benchmark.last_index_of.length.js | 95 - benchmark/benchmark.length.js | 93 - benchmark/benchmark.map.js | 82 - benchmark/benchmark.map.length.js | 106 - benchmark/benchmark.of.js | 48 - benchmark/benchmark.reduce.js | 82 - benchmark/benchmark.reduce.length.js | 107 - benchmark/benchmark.reduce_right.js | 82 - benchmark/benchmark.reduce_right.length.js | 107 - benchmark/benchmark.reverse.js | 53 - benchmark/benchmark.reverse.length.js | 96 - benchmark/benchmark.set.js | 95 - benchmark/benchmark.set.length.js | 110 - benchmark/benchmark.slice.js | 53 - benchmark/benchmark.slice.length.js | 96 - benchmark/benchmark.some.js | 83 - benchmark/benchmark.some.length.js | 107 - benchmark/benchmark.sort.js | 53 - benchmark/benchmark.sort.length.js | 96 - benchmark/benchmark.subarray.js | 52 - benchmark/benchmark.subarray.length.js | 95 - benchmark/benchmark.to_locale_string.js | 53 - .../benchmark.to_locale_string.length.js | 96 - benchmark/benchmark.to_reversed.js | 52 - benchmark/benchmark.to_reversed.length.js | 95 - benchmark/benchmark.to_sorted.js | 53 - benchmark/benchmark.to_sorted.length.js | 96 - benchmark/benchmark.to_string.js | 53 - benchmark/benchmark.to_string.length.js | 96 - benchmark/benchmark.values.js | 52 - benchmark/benchmark.values.length.js | 96 - benchmark/benchmark.with.js | 54 - benchmark/benchmark.with.length.js | 98 - benchmark/polyfill/benchmark.at.js | 79 - benchmark/polyfill/benchmark.copy_within.js | 52 - .../polyfill/benchmark.copy_within.length.js | 95 - benchmark/polyfill/benchmark.entries.js | 52 - benchmark/polyfill/benchmark.every.js | 83 - benchmark/polyfill/benchmark.every.length.js | 107 - benchmark/polyfill/benchmark.fill.js | 53 - benchmark/polyfill/benchmark.fill.length.js | 97 - benchmark/polyfill/benchmark.filter.js | 82 - benchmark/polyfill/benchmark.filter.length.js | 106 - benchmark/polyfill/benchmark.find.js | 84 - benchmark/polyfill/benchmark.find.length.js | 106 - benchmark/polyfill/benchmark.find_index.js | 84 - .../polyfill/benchmark.find_index.length.js | 106 - benchmark/polyfill/benchmark.find_last.js | 84 - .../polyfill/benchmark.find_last.length.js | 106 - .../polyfill/benchmark.find_last_index.js | 84 - .../benchmark.find_last_index.length.js | 110 - benchmark/polyfill/benchmark.for_each.js | 90 - .../polyfill/benchmark.for_each.length.js | 108 - benchmark/polyfill/benchmark.from.js | 238 - benchmark/polyfill/benchmark.get.js | 55 - benchmark/polyfill/benchmark.includes.js | 54 - .../polyfill/benchmark.includes.length.js | 97 - benchmark/polyfill/benchmark.index_of.js | 54 - .../polyfill/benchmark.index_of.length.js | 96 - benchmark/polyfill/benchmark.join.js | 53 - benchmark/polyfill/benchmark.join.length.js | 96 - benchmark/polyfill/benchmark.js | 338 -- benchmark/polyfill/benchmark.keys.js | 52 - benchmark/polyfill/benchmark.keys.length.js | 96 - benchmark/polyfill/benchmark.last_index_of.js | 53 - .../benchmark.last_index_of.length.js | 95 - benchmark/polyfill/benchmark.length.js | 93 - benchmark/polyfill/benchmark.map.js | 82 - benchmark/polyfill/benchmark.map.length.js | 106 - benchmark/polyfill/benchmark.of.js | 48 - benchmark/polyfill/benchmark.reduce.js | 82 - benchmark/polyfill/benchmark.reduce.length.js | 107 - benchmark/polyfill/benchmark.reduce_right.js | 82 - .../polyfill/benchmark.reduce_right.length.js | 107 - benchmark/polyfill/benchmark.reverse.js | 53 - .../polyfill/benchmark.reverse.length.js | 96 - benchmark/polyfill/benchmark.set.js | 95 - benchmark/polyfill/benchmark.set.length.js | 110 - benchmark/polyfill/benchmark.slice.js | 53 - benchmark/polyfill/benchmark.slice.length.js | 96 - benchmark/polyfill/benchmark.some.js | 83 - benchmark/polyfill/benchmark.some.length.js | 107 - benchmark/polyfill/benchmark.sort.js | 53 - benchmark/polyfill/benchmark.sort.length.js | 96 - benchmark/polyfill/benchmark.subarray.js | 52 - .../polyfill/benchmark.subarray.length.js | 95 - .../polyfill/benchmark.to_locale_string.js | 53 - .../benchmark.to_locale_string.length.js | 96 - benchmark/polyfill/benchmark.to_reversed.js | 52 - .../polyfill/benchmark.to_reversed.length.js | 95 - benchmark/polyfill/benchmark.to_sorted.js | 53 - .../polyfill/benchmark.to_sorted.length.js | 96 - benchmark/polyfill/benchmark.to_string.js | 53 - .../polyfill/benchmark.to_string.length.js | 96 - benchmark/polyfill/benchmark.values.js | 52 - benchmark/polyfill/benchmark.values.length.js | 96 - benchmark/polyfill/benchmark.with.js | 54 - benchmark/polyfill/benchmark.with.length.js | 98 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 1222 ----- docs/types/test.ts | 129 - examples/index.js | 42 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 106 - lib/main.js | 28 - lib/polyfill/from_array.js | 51 - lib/polyfill/from_iterator.js | 54 - lib/polyfill/from_iterator_map.js | 59 - lib/polyfill/index.js | 2410 -------- package.json | 86 +- stats.html | 4842 +++++++++++++++++ test/dist/test.js | 33 - test/polyfill/test.at.js | 144 - test/polyfill/test.copy_within.js | 281 - test/polyfill/test.entries.js | 238 - test/polyfill/test.every.js | 174 - test/polyfill/test.fill.js | 305 -- test/polyfill/test.filter.js | 226 - test/polyfill/test.find.js | 174 - test/polyfill/test.find_index.js | 173 - test/polyfill/test.find_last.js | 174 - test/polyfill/test.find_last_index.js | 173 - test/polyfill/test.for_each.js | 196 - test/polyfill/test.from.js | 654 --- test/polyfill/test.includes.js | 222 - test/polyfill/test.index_of.js | 222 - test/polyfill/test.join.js | 173 - test/polyfill/test.js | 740 --- test/polyfill/test.keys.js | 261 - test/polyfill/test.last_index_of.js | 211 - test/polyfill/test.map.js | 178 - test/polyfill/test.of.js | 130 - test/polyfill/test.reduce.js | 189 - test/polyfill/test.reduce_right.js | 192 - test/polyfill/test.reverse.js | 122 - test/polyfill/test.set.js | 259 - test/polyfill/test.slice.js | 311 -- test/polyfill/test.some.js | 196 - test/polyfill/test.sort.js | 189 - test/polyfill/test.subarray.js | 308 -- test/polyfill/test.to_locale_string.js | 187 - test/polyfill/test.to_reversed.js | 121 - test/polyfill/test.to_sorted.js | 172 - test/polyfill/test.to_string.js | 97 - test/polyfill/test.values.js | 264 - test/polyfill/test.with.js | 213 - test/test.at.js | 111 - test/test.copy_within.js | 279 - test/test.entries.js | 96 - test/test.every.js | 172 - test/test.fill.js | 212 - test/test.filter.js | 224 - test/test.find.js | 172 - test/test.find_index.js | 171 - test/test.find_last.js | 172 - test/test.find_last_index.js | 171 - test/test.for_each.js | 194 - test/test.from.js | 309 -- test/test.includes.js | 160 - test/test.index_of.js | 160 - test/test.join.js | 141 - test/test.js | 320 -- test/test.keys.js | 144 - test/test.last_index_of.js | 149 - test/test.map.js | 176 - test/test.of.js | 128 - test/test.polyfill.js | 80 - test/test.reduce.js | 187 - test/test.reduce_right.js | 190 - test/test.reverse.js | 120 - test/test.set.js | 225 - test/test.slice.js | 249 - test/test.some.js | 194 - test/test.sort.js | 186 - test/test.subarray.js | 246 - test/test.to_locale_string.js | 95 - test/test.to_reversed.js | 119 - test/test.to_sorted.js | 169 - test/test.to_string.js | 87 - test/test.values.js | 147 - test/test.with.js | 151 - 244 files changed, 4870 insertions(+), 33230 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.at.js delete mode 100644 benchmark/benchmark.copy_within.js delete mode 100644 benchmark/benchmark.copy_within.length.js delete mode 100644 benchmark/benchmark.entries.js delete mode 100644 benchmark/benchmark.every.js delete mode 100644 benchmark/benchmark.every.length.js delete mode 100644 benchmark/benchmark.fill.js delete mode 100644 benchmark/benchmark.fill.length.js delete mode 100644 benchmark/benchmark.filter.js delete mode 100644 benchmark/benchmark.filter.length.js delete mode 100644 benchmark/benchmark.find.js delete mode 100644 benchmark/benchmark.find.length.js delete mode 100644 benchmark/benchmark.find_index.js delete mode 100644 benchmark/benchmark.find_index.length.js delete mode 100644 benchmark/benchmark.find_last.js delete mode 100644 benchmark/benchmark.find_last.length.js delete mode 100644 benchmark/benchmark.find_last_index.js delete mode 100644 benchmark/benchmark.find_last_index.length.js delete mode 100644 benchmark/benchmark.for_each.js delete mode 100644 benchmark/benchmark.for_each.length.js delete mode 100644 benchmark/benchmark.from.js delete mode 100644 benchmark/benchmark.get.js delete mode 100644 benchmark/benchmark.includes.js delete mode 100644 benchmark/benchmark.includes.length.js delete mode 100644 benchmark/benchmark.index_of.js delete mode 100644 benchmark/benchmark.index_of.length.js delete mode 100644 benchmark/benchmark.join.js delete mode 100644 benchmark/benchmark.join.length.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.keys.js delete mode 100644 benchmark/benchmark.keys.length.js delete mode 100644 benchmark/benchmark.last_index_of.js delete mode 100644 benchmark/benchmark.last_index_of.length.js delete mode 100644 benchmark/benchmark.length.js delete mode 100644 benchmark/benchmark.map.js delete mode 100644 benchmark/benchmark.map.length.js delete mode 100644 benchmark/benchmark.of.js delete mode 100644 benchmark/benchmark.reduce.js delete mode 100644 benchmark/benchmark.reduce.length.js delete mode 100644 benchmark/benchmark.reduce_right.js delete mode 100644 benchmark/benchmark.reduce_right.length.js delete mode 100644 benchmark/benchmark.reverse.js delete mode 100644 benchmark/benchmark.reverse.length.js delete mode 100644 benchmark/benchmark.set.js delete mode 100644 benchmark/benchmark.set.length.js delete mode 100644 benchmark/benchmark.slice.js delete mode 100644 benchmark/benchmark.slice.length.js delete mode 100644 benchmark/benchmark.some.js delete mode 100644 benchmark/benchmark.some.length.js delete mode 100644 benchmark/benchmark.sort.js delete mode 100644 benchmark/benchmark.sort.length.js delete mode 100644 benchmark/benchmark.subarray.js delete mode 100644 benchmark/benchmark.subarray.length.js delete mode 100644 benchmark/benchmark.to_locale_string.js delete mode 100644 benchmark/benchmark.to_locale_string.length.js delete mode 100644 benchmark/benchmark.to_reversed.js delete mode 100644 benchmark/benchmark.to_reversed.length.js delete mode 100644 benchmark/benchmark.to_sorted.js delete mode 100644 benchmark/benchmark.to_sorted.length.js delete mode 100644 benchmark/benchmark.to_string.js delete mode 100644 benchmark/benchmark.to_string.length.js delete mode 100644 benchmark/benchmark.values.js delete mode 100644 benchmark/benchmark.values.length.js delete mode 100644 benchmark/benchmark.with.js delete mode 100644 benchmark/benchmark.with.length.js delete mode 100644 benchmark/polyfill/benchmark.at.js delete mode 100644 benchmark/polyfill/benchmark.copy_within.js delete mode 100644 benchmark/polyfill/benchmark.copy_within.length.js delete mode 100644 benchmark/polyfill/benchmark.entries.js delete mode 100644 benchmark/polyfill/benchmark.every.js delete mode 100644 benchmark/polyfill/benchmark.every.length.js delete mode 100644 benchmark/polyfill/benchmark.fill.js delete mode 100644 benchmark/polyfill/benchmark.fill.length.js delete mode 100644 benchmark/polyfill/benchmark.filter.js delete mode 100644 benchmark/polyfill/benchmark.filter.length.js delete mode 100644 benchmark/polyfill/benchmark.find.js delete mode 100644 benchmark/polyfill/benchmark.find.length.js delete mode 100644 benchmark/polyfill/benchmark.find_index.js delete mode 100644 benchmark/polyfill/benchmark.find_index.length.js delete mode 100644 benchmark/polyfill/benchmark.find_last.js delete mode 100644 benchmark/polyfill/benchmark.find_last.length.js delete mode 100644 benchmark/polyfill/benchmark.find_last_index.js delete mode 100644 benchmark/polyfill/benchmark.find_last_index.length.js delete mode 100644 benchmark/polyfill/benchmark.for_each.js delete mode 100644 benchmark/polyfill/benchmark.for_each.length.js delete mode 100644 benchmark/polyfill/benchmark.from.js delete mode 100644 benchmark/polyfill/benchmark.get.js delete mode 100644 benchmark/polyfill/benchmark.includes.js delete mode 100644 benchmark/polyfill/benchmark.includes.length.js delete mode 100644 benchmark/polyfill/benchmark.index_of.js delete mode 100644 benchmark/polyfill/benchmark.index_of.length.js delete mode 100644 benchmark/polyfill/benchmark.join.js delete mode 100644 benchmark/polyfill/benchmark.join.length.js delete mode 100644 benchmark/polyfill/benchmark.js delete mode 100644 benchmark/polyfill/benchmark.keys.js delete mode 100644 benchmark/polyfill/benchmark.keys.length.js delete mode 100644 benchmark/polyfill/benchmark.last_index_of.js delete mode 100644 benchmark/polyfill/benchmark.last_index_of.length.js delete mode 100644 benchmark/polyfill/benchmark.length.js delete mode 100644 benchmark/polyfill/benchmark.map.js delete mode 100644 benchmark/polyfill/benchmark.map.length.js delete mode 100644 benchmark/polyfill/benchmark.of.js delete mode 100644 benchmark/polyfill/benchmark.reduce.js delete mode 100644 benchmark/polyfill/benchmark.reduce.length.js delete mode 100644 benchmark/polyfill/benchmark.reduce_right.js delete mode 100644 benchmark/polyfill/benchmark.reduce_right.length.js delete mode 100644 benchmark/polyfill/benchmark.reverse.js delete mode 100644 benchmark/polyfill/benchmark.reverse.length.js delete mode 100644 benchmark/polyfill/benchmark.set.js delete mode 100644 benchmark/polyfill/benchmark.set.length.js delete mode 100644 benchmark/polyfill/benchmark.slice.js delete mode 100644 benchmark/polyfill/benchmark.slice.length.js delete mode 100644 benchmark/polyfill/benchmark.some.js delete mode 100644 benchmark/polyfill/benchmark.some.length.js delete mode 100644 benchmark/polyfill/benchmark.sort.js delete mode 100644 benchmark/polyfill/benchmark.sort.length.js delete mode 100644 benchmark/polyfill/benchmark.subarray.js delete mode 100644 benchmark/polyfill/benchmark.subarray.length.js delete mode 100644 benchmark/polyfill/benchmark.to_locale_string.js delete mode 100644 benchmark/polyfill/benchmark.to_locale_string.length.js delete mode 100644 benchmark/polyfill/benchmark.to_reversed.js delete mode 100644 benchmark/polyfill/benchmark.to_reversed.length.js delete mode 100644 benchmark/polyfill/benchmark.to_sorted.js delete mode 100644 benchmark/polyfill/benchmark.to_sorted.length.js delete mode 100644 benchmark/polyfill/benchmark.to_string.js delete mode 100644 benchmark/polyfill/benchmark.to_string.length.js delete mode 100644 benchmark/polyfill/benchmark.values.js delete mode 100644 benchmark/polyfill/benchmark.values.length.js delete mode 100644 benchmark/polyfill/benchmark.with.js delete mode 100644 benchmark/polyfill/benchmark.with.length.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill/from_array.js delete mode 100644 lib/polyfill/from_iterator.js delete mode 100644 lib/polyfill/from_iterator_map.js delete mode 100644 lib/polyfill/index.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/polyfill/test.at.js delete mode 100644 test/polyfill/test.copy_within.js delete mode 100644 test/polyfill/test.entries.js delete mode 100644 test/polyfill/test.every.js delete mode 100644 test/polyfill/test.fill.js delete mode 100644 test/polyfill/test.filter.js delete mode 100644 test/polyfill/test.find.js delete mode 100644 test/polyfill/test.find_index.js delete mode 100644 test/polyfill/test.find_last.js delete mode 100644 test/polyfill/test.find_last_index.js delete mode 100644 test/polyfill/test.for_each.js delete mode 100644 test/polyfill/test.from.js delete mode 100644 test/polyfill/test.includes.js delete mode 100644 test/polyfill/test.index_of.js delete mode 100644 test/polyfill/test.join.js delete mode 100644 test/polyfill/test.js delete mode 100644 test/polyfill/test.keys.js delete mode 100644 test/polyfill/test.last_index_of.js delete mode 100644 test/polyfill/test.map.js delete mode 100644 test/polyfill/test.of.js delete mode 100644 test/polyfill/test.reduce.js delete mode 100644 test/polyfill/test.reduce_right.js delete mode 100644 test/polyfill/test.reverse.js delete mode 100644 test/polyfill/test.set.js delete mode 100644 test/polyfill/test.slice.js delete mode 100644 test/polyfill/test.some.js delete mode 100644 test/polyfill/test.sort.js delete mode 100644 test/polyfill/test.subarray.js delete mode 100644 test/polyfill/test.to_locale_string.js delete mode 100644 test/polyfill/test.to_reversed.js delete mode 100644 test/polyfill/test.to_sorted.js delete mode 100644 test/polyfill/test.to_string.js delete mode 100644 test/polyfill/test.values.js delete mode 100644 test/polyfill/test.with.js delete mode 100644 test/test.at.js delete mode 100644 test/test.copy_within.js delete mode 100644 test/test.entries.js delete mode 100644 test/test.every.js delete mode 100644 test/test.fill.js delete mode 100644 test/test.filter.js delete mode 100644 test/test.find.js delete mode 100644 test/test.find_index.js delete mode 100644 test/test.find_last.js delete mode 100644 test/test.find_last_index.js delete mode 100644 test/test.for_each.js delete mode 100644 test/test.from.js delete mode 100644 test/test.includes.js delete mode 100644 test/test.index_of.js delete mode 100644 test/test.join.js delete mode 100644 test/test.js delete mode 100644 test/test.keys.js delete mode 100644 test/test.last_index_of.js delete mode 100644 test/test.map.js delete mode 100644 test/test.of.js delete mode 100644 test/test.polyfill.js delete mode 100644 test/test.reduce.js delete mode 100644 test/test.reduce_right.js delete mode 100644 test/test.reverse.js delete mode 100644 test/test.set.js delete mode 100644 test/test.slice.js delete mode 100644 test/test.some.js delete mode 100644 test/test.sort.js delete mode 100644 test/test.subarray.js delete mode 100644 test/test.to_locale_string.js delete mode 100644 test/test.to_reversed.js delete mode 100644 test/test.to_sorted.js delete mode 100644 test/test.to_string.js delete mode 100644 test/test.values.js delete mode 100644 test/test.with.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index f756a5e..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/float16) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 44e2d76..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/float16) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 4584730..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '9 21 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -1587,7 +1578,7 @@ logEach( '%s', out ); ## Notice -This package is part of [stdlib][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. +This package is part of [stdlib][stdlib], a standard library 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][stdlib], see the main project [repository][stdlib]. @@ -1652,9 +1643,9 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. [mdn-iterator-protocol]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterator_protocol -[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed +[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed/tree/esm -[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer +[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.at.js b/benchmark/benchmark.at.js deleted file mode 100644 index 7068020..0000000 --- a/benchmark/benchmark.at.js +++ /dev/null @@ -1,79 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s::nonnegative_indices:at', pkg ), function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float16Array( uniform( 10, 0.0, 10.0 ) ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.at( i%N ); - if ( typeof v !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNumber( v ) ) { - b.fail( 'should return a number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::negative_indices:at', pkg ), function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float16Array( uniform( 10, 1.0, 10.0 ) ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.at( -(i%N)-1 ); - if ( typeof v !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNumber( v ) ) { - b.fail( 'should return a number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.copy_within.js b/benchmark/benchmark.copy_within.js deleted file mode 100644 index 2182e0d..0000000 --- a/benchmark/benchmark.copy_within.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:copyWithin', pkg ), function benchmark( b ) { - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.copy_within.length.js b/benchmark/benchmark.copy_within.length.js deleted file mode 100644 index 9c952bb..0000000 --- a/benchmark/benchmark.copy_within.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - 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( format( '%s:copyWithin:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.entries.js b/benchmark/benchmark.entries.js deleted file mode 100644 index ddef73f..0000000 --- a/benchmark/benchmark.entries.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:entries', pkg ), function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.every.js b/benchmark/benchmark.every.js deleted file mode 100644 index ec830e9..0000000 --- a/benchmark/benchmark.every.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:every', pkg ), function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0.0; - } -}); - -bench( format( '%s::this_context:every', pkg ), function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0.0; - } -}); diff --git a/benchmark/benchmark.every.length.js b/benchmark/benchmark.every.length.js deleted file mode 100644 index a0f3d94..0000000 --- a/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,107 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - 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( format( '%s:every:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.fill.js b/benchmark/benchmark.fill.js deleted file mode 100644 index 7b27d39..0000000 --- a/benchmark/benchmark.fill.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:fill', pkg ), function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = [ 1.0, 2.0, 3.0 ]; - arr = new Float16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.fill( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.fill.length.js b/benchmark/benchmark.fill.length.js deleted file mode 100644 index 612d1b9..0000000 --- a/benchmark/benchmark.fill.length.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var values; - var out; - var i; - - values = [ 1.0, 2.0, 3.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.fill( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s:fill:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.filter.js b/benchmark/benchmark.filter.js deleted file mode 100644 index 555ad11..0000000 --- a/benchmark/benchmark.filter.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:filter', pkg ), function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0.0; - } -}); - -bench( format( '%s::this_context:filter', pkg ), function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0.0; - } -}); diff --git a/benchmark/benchmark.filter.length.js b/benchmark/benchmark.filter.length.js deleted file mode 100644 index 89f5124..0000000 --- a/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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 = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:filter:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.find.js b/benchmark/benchmark.find.js deleted file mode 100644 index b15c9fa..0000000 --- a/benchmark/benchmark.find.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:find', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); - -bench( format( '%s::this_context:find', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); diff --git a/benchmark/benchmark.find.length.js b/benchmark/benchmark.find.length.js deleted file mode 100644 index 58997d9..0000000 --- a/benchmark/benchmark.find.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value < 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - 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( format( '%s:find:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.find_index.js b/benchmark/benchmark.find_index.js deleted file mode 100644 index 4491bb3..0000000 --- a/benchmark/benchmark.find_index.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:findIndex', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); - -bench( format( '%s::this_context:findIndex', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); diff --git a/benchmark/benchmark.find_index.length.js b/benchmark/benchmark.find_index.length.js deleted file mode 100644 index 4bed308..0000000 --- a/benchmark/benchmark.find_index.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value < 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - 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( format( '%s:findIndex:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.find_last.js b/benchmark/benchmark.find_last.js deleted file mode 100644 index e134fbb..0000000 --- a/benchmark/benchmark.find_last.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:findLast', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findLast( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); - -bench( format( '%s::this_context:findLast', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findLast( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); diff --git a/benchmark/benchmark.find_last.length.js b/benchmark/benchmark.find_last.length.js deleted file mode 100644 index 50aad42..0000000 --- a/benchmark/benchmark.find_last.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value < 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.findLast( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - 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( format( '%s:findLast:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.find_last_index.js b/benchmark/benchmark.find_last_index.js deleted file mode 100644 index 85217bd..0000000 --- a/benchmark/benchmark.find_last_index.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:findLastIndex', pkg ), function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findLastIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -bench( format( '%s::this_context:findLastIndex', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findLastIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); diff --git a/benchmark/benchmark.find_last_index.length.js b/benchmark/benchmark.find_last_index.length.js deleted file mode 100644 index 69468cd..0000000 --- a/benchmark/benchmark.find_last_index.length.js +++ /dev/null @@ -1,110 +0,0 @@ -/** - * @license Apache-2.0 -* -* Copyright (c) 2026 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. -*/ - -/* eslint-disable stdlib/jsdoc-typedef-typos */ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {boolean} value - array element -* @param {NonNegativeInteger} idx - array element index -* @param {Float16Array} arr - array instance -* @returns {boolean} boolean indicating whether a value passes a test -*/ -function predicate( value ) { - return value < 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.findLastIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - 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( format( '%s:findLastIndex:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.for_each.js b/benchmark/benchmark.for_each.js deleted file mode 100644 index af73bce..0000000 --- a/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:forEach', pkg ), function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( format( '%s::this_context:forEach', pkg ), function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/benchmark/benchmark.for_each.length.js b/benchmark/benchmark.for_each.length.js deleted file mode 100644 index 935da80..0000000 --- a/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// 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( format( '%s:forEach:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.from.js b/benchmark/benchmark.from.js deleted file mode 100644 index 2242134..0000000 --- a/benchmark/benchmark.from.js +++ /dev/null @@ -1,238 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( format( '%s::typed_array:from', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::typed_array,clbk:from', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1.0; - } -}); - -bench( format( '%s::array:from', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1.0, 2.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::array,clbk:from', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1.0, 2.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1.0; - } -}); - -bench( format( '%s::iterable:from', pkg ), opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0.0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( format( '%s::iterable,clbk:from:', pkg ), opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1.0, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1.0; - } -}); diff --git a/benchmark/benchmark.get.js b/benchmark/benchmark.get.js deleted file mode 100644 index 90788e1..0000000 --- a/benchmark/benchmark.get.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:get', pkg ), function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float16Array( uniform( 10, 0.0, 10.0 ) ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( typeof v !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNumber( v ) ) { - b.fail( 'should return a number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.includes.js b/benchmark/benchmark.includes.js deleted file mode 100644 index c24dcc3..0000000 --- a/benchmark/benchmark.includes.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:includes', pkg ), function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Float16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1.0; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.includes.length.js b/benchmark/benchmark.includes.length.js deleted file mode 100644 index db686a1..0000000 --- a/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1.0; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - 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( format( '%s:includes:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.index_of.js b/benchmark/benchmark.index_of.js deleted file mode 100644 index 222370c..0000000 --- a/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:indexOf', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.indexOf( 11.0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( out ) ) { - b.fail( 'should return an integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.index_of.length.js b/benchmark/benchmark.index_of.length.js deleted file mode 100644 index ca2c5ee..0000000 --- a/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.indexOf( 11.0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( out ) ) { - b.fail( 'should return an integer' ); - } - 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( format( '%s:indexOf:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.join.js b/benchmark/benchmark.join.js deleted file mode 100644 index ce25730..0000000 --- a/benchmark/benchmark.join.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:join', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.join.length.js b/benchmark/benchmark.join.length.js deleted file mode 100644 index 26092d0..0000000 --- a/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - 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( format( '%s:join:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 1d756ec..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,338 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( format( '%s::instantiation,new', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array(); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::instantiation,no_new', pkg ), function benchmark( b ) { - var ctor; - var arr; - var i; - - ctor = Float16Array; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = ctor(); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::instantiation,length', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::instantiation,typed_array', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::instantiation,array', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = []; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::instantiation,iterable', pkg ), opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( createIterable() ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - return { - 'done': true - }; - } - } -}); - -bench( format( '%s::instantiation,arraybuffer', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::instantiation,arraybuffer,byte_offset', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 8 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( buf, 8 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::instantiation,arraybuffer,byte_offset,length', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 8 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( buf, 8, 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::get:buffer', pkg ), function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float16Array(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::get:byteLength', pkg ), function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float16Array(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::get:byteOffset', pkg ), function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float16Array(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::get:length', pkg ), function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float16Array(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.keys.js b/benchmark/benchmark.keys.js deleted file mode 100644 index 9bd4d5f..0000000 --- a/benchmark/benchmark.keys.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:keys', pkg ), function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.keys.length.js b/benchmark/benchmark.keys.length.js deleted file mode 100644 index a9b25c9..0000000 --- a/benchmark/benchmark.keys.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var iter; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isIteratorLike( iter ) ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - 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( format( '%s:keys:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.last_index_of.js b/benchmark/benchmark.last_index_of.js deleted file mode 100644 index 96d9d71..0000000 --- a/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:lastIndexOf', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.lastIndexOf( 11.0 ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.length.js b/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index 230c543..0000000 --- a/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.lastIndexOf( 11.0 ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - 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( format( '%s:lastIndexOf:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index c67eb26..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.map.js b/benchmark/benchmark.map.js deleted file mode 100644 index 7968e8c..0000000 --- a/benchmark/benchmark.map.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:map', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1.0; - } -}); - -bench( format( '%s::this_context:map', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1.0; - } -}); diff --git a/benchmark/benchmark.map.length.js b/benchmark/benchmark.map.length.js deleted file mode 100644 index 3948193..0000000 --- a/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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 = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:map:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.of.js b/benchmark/benchmark.of.js deleted file mode 100644 index 3b8ae26..0000000 --- a/benchmark/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:of', pkg ), function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.of( i, 2.0 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reduce.js b/benchmark/benchmark.reduce.js deleted file mode 100644 index 39ce31c..0000000 --- a/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:reduce', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1.0; - } -}); - -bench( format( '%s::initial_value:reduce', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3.14 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1.0; - } -}); diff --git a/benchmark/benchmark.reduce.length.js b/benchmark/benchmark.reduce.length.js deleted file mode 100644 index 763b4c2..0000000 --- a/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,107 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - 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( format( '%s:reduce:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.reduce_right.js b/benchmark/benchmark.reduce_right.js deleted file mode 100644 index 8a71b79..0000000 --- a/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:reduceRight', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1.0; - } -}); - -bench( format( '%s::initial_value:reduceRight', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3.14 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1.0; - } -}); diff --git a/benchmark/benchmark.reduce_right.length.js b/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index 2001fe5..0000000 --- a/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,107 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - 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( format( '%s:reduceRight:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.reverse.js b/benchmark/benchmark.reverse.js deleted file mode 100644 index a2a239c..0000000 --- a/benchmark/benchmark.reverse.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:reverse', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reverse.length.js b/benchmark/benchmark.reverse.length.js deleted file mode 100644 index 3b526c7..0000000 --- a/benchmark/benchmark.reverse.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s:reverse:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.set.js b/benchmark/benchmark.set.js deleted file mode 100644 index 7648c39..0000000 --- a/benchmark/benchmark.set.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s::array:set', pkg ), function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Float16Array( 2 ); - buf = [ 0.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::typed_array:set', pkg ), function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Float16Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Float16Array( 2 ); - buf = new Float16Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.set.length.js b/benchmark/benchmark.set.length.js deleted file mode 100644 index f174a4a..0000000 --- a/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - - arr1 = uniform( len, 0.0, 10.0 ); - arr2 = uniform( len, 0.0, 10.0 ); - arr = new Float16Array( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - 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( format( '%s:set:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.slice.js b/benchmark/benchmark.slice.js deleted file mode 100644 index 9f5005a..0000000 --- a/benchmark/benchmark.slice.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:slice', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.slice.length.js b/benchmark/benchmark.slice.length.js deleted file mode 100644 index 2374b1b..0000000 --- a/benchmark/benchmark.slice.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s:slice:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.some.js b/benchmark/benchmark.some.js deleted file mode 100644 index 0c81afa..0000000 --- a/benchmark/benchmark.some.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:some', pkg ), function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); - -bench( format( '%s::this_context:some', pkg ), function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); diff --git a/benchmark/benchmark.some.length.js b/benchmark/benchmark.some.length.js deleted file mode 100644 index dd32df4..0000000 --- a/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,107 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value < 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - 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( format( '%s:some:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.sort.js b/benchmark/benchmark.sort.js deleted file mode 100644 index d9e6c30..0000000 --- a/benchmark/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:sort', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.sort.length.js b/benchmark/benchmark.sort.length.js deleted file mode 100644 index 508049c..0000000 --- a/benchmark/benchmark.sort.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ i%len ] = i; - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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 = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:sort:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.subarray.js b/benchmark/benchmark.subarray.js deleted file mode 100644 index 9d6a26b..0000000 --- a/benchmark/benchmark.subarray.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:subarray', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.subarray.length.js b/benchmark/benchmark.subarray.length.js deleted file mode 100644 index c40760b..0000000 --- a/benchmark/benchmark.subarray.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s:subarray:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_locale_string.js b/benchmark/benchmark.to_locale_string.js deleted file mode 100644 index 682ca77..0000000 --- a/benchmark/benchmark.to_locale_string.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:toLocaleString', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_locale_string.length.js b/benchmark/benchmark.to_locale_string.length.js deleted file mode 100644 index 20f510e..0000000 --- a/benchmark/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - 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 = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:toLocaleString:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_reversed.js b/benchmark/benchmark.to_reversed.js deleted file mode 100644 index 1b78c11..0000000 --- a/benchmark/benchmark.to_reversed.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:toReversed', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - 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 ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_reversed.length.js b/benchmark/benchmark.to_reversed.length.js deleted file mode 100644 index 66bf5dc..0000000 --- a/benchmark/benchmark.to_reversed.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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 ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s:toReversed:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_sorted.js b/benchmark/benchmark.to_sorted.js deleted file mode 100644 index d2021b5..0000000 --- a/benchmark/benchmark.to_sorted.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:toSorted', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toSorted(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_sorted.length.js b/benchmark/benchmark.to_sorted.length.js deleted file mode 100644 index b74ea43..0000000 --- a/benchmark/benchmark.to_sorted.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ i%len ] = i; - out = arr.toSorted(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a isFloat16Array' ); - } - 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( format( '%s:toSorted:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_string.js b/benchmark/benchmark.to_string.js deleted file mode 100644 index 6a31520..0000000 --- a/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:toString', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_string.length.js b/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 375cc12..0000000 --- a/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - 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 = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:toString:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.values.js b/benchmark/benchmark.values.js deleted file mode 100644 index 4352d26..0000000 --- a/benchmark/benchmark.values.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:values', pkg ), function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.values.length.js b/benchmark/benchmark.values.length.js deleted file mode 100644 index e0ac1ed..0000000 --- a/benchmark/benchmark.values.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var iter; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isIteratorLike( iter ) ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - 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( format( '%s:values:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.with.js b/benchmark/benchmark.with.js deleted file mode 100644 index 0ca8231..0000000 --- a/benchmark/benchmark.with.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:with', pkg ), function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = uniform( 2, 0.0, 1.0 ); - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.with( i%arr.length, values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.with.length.js b/benchmark/benchmark.with.length.js deleted file mode 100644 index efdf808..0000000 --- a/benchmark/benchmark.with.length.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var values; - var out; - var i; - - values = uniform( 2, 0.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.with( i%len, values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s:with:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.at.js b/benchmark/polyfill/benchmark.at.js deleted file mode 100644 index f0b2b78..0000000 --- a/benchmark/polyfill/benchmark.at.js +++ /dev/null @@ -1,79 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill::nonnegative_indices:at', pkg ), function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float16Array( uniform( 10, 0.0, 10.0 ) ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.at( i%N ); - if ( typeof v !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNumber( v ) ) { - b.fail( 'should return a number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::negative_indices:at', pkg ), function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float16Array( uniform( 10, 1.0, 10.0 ) ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.at( -(i%N)-1 ); - if ( typeof v !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNumber( v ) ) { - b.fail( 'should return a number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.copy_within.js b/benchmark/polyfill/benchmark.copy_within.js deleted file mode 100644 index 867e40a..0000000 --- a/benchmark/polyfill/benchmark.copy_within.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:copyWithin', pkg ), function benchmark( b ) { - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.copy_within.length.js b/benchmark/polyfill/benchmark.copy_within.length.js deleted file mode 100644 index 86bd362..0000000 --- a/benchmark/polyfill/benchmark.copy_within.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - 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( format( '%s::polyfill:copyWithin:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.entries.js b/benchmark/polyfill/benchmark.entries.js deleted file mode 100644 index 013036c..0000000 --- a/benchmark/polyfill/benchmark.entries.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:entries', pkg ), function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.every.js b/benchmark/polyfill/benchmark.every.js deleted file mode 100644 index 2b505c5..0000000 --- a/benchmark/polyfill/benchmark.every.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:every', pkg ), function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0.0; - } -}); - -bench( format( '%s::polyfill::this_context:every', pkg ), function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0.0; - } -}); diff --git a/benchmark/polyfill/benchmark.every.length.js b/benchmark/polyfill/benchmark.every.length.js deleted file mode 100644 index df08cff..0000000 --- a/benchmark/polyfill/benchmark.every.length.js +++ /dev/null @@ -1,107 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - 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( format( '%s::polyfill:every:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.fill.js b/benchmark/polyfill/benchmark.fill.js deleted file mode 100644 index 0c6e740..0000000 --- a/benchmark/polyfill/benchmark.fill.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:fill', pkg ), function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = [ 1.0, 2.0, 3.0 ]; - arr = new Float16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.fill( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.fill.length.js b/benchmark/polyfill/benchmark.fill.length.js deleted file mode 100644 index 6e72c6a..0000000 --- a/benchmark/polyfill/benchmark.fill.length.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var values; - var out; - var i; - - values = [ 1.0, 2.0, 3.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.fill( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s::polyfill:fill:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.filter.js b/benchmark/polyfill/benchmark.filter.js deleted file mode 100644 index 328c3d1..0000000 --- a/benchmark/polyfill/benchmark.filter.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:filter', pkg ), function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0.0; - } -}); - -bench( format( '%s::polyfill::this_context:filter', pkg ), function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0.0; - } -}); diff --git a/benchmark/polyfill/benchmark.filter.length.js b/benchmark/polyfill/benchmark.filter.length.js deleted file mode 100644 index 8673396..0000000 --- a/benchmark/polyfill/benchmark.filter.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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 = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s::polyfill:filter:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.find.js b/benchmark/polyfill/benchmark.find.js deleted file mode 100644 index aef5da9..0000000 --- a/benchmark/polyfill/benchmark.find.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:find', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); - -bench( format( '%s::polyfill::this_context:find', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); diff --git a/benchmark/polyfill/benchmark.find.length.js b/benchmark/polyfill/benchmark.find.length.js deleted file mode 100644 index 0059567..0000000 --- a/benchmark/polyfill/benchmark.find.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value < 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - 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( format( '%s::polyfill:find:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.find_index.js b/benchmark/polyfill/benchmark.find_index.js deleted file mode 100644 index 183c1e4..0000000 --- a/benchmark/polyfill/benchmark.find_index.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:findIndex', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); - -bench( format( '%s::polyfill::this_context:findIndex', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); diff --git a/benchmark/polyfill/benchmark.find_index.length.js b/benchmark/polyfill/benchmark.find_index.length.js deleted file mode 100644 index c9d2887..0000000 --- a/benchmark/polyfill/benchmark.find_index.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value < 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - 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( format( '%s::polyfill:findIndex:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.find_last.js b/benchmark/polyfill/benchmark.find_last.js deleted file mode 100644 index 1d79bb8..0000000 --- a/benchmark/polyfill/benchmark.find_last.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:findLast', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findLast( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); - -bench( format( '%s::polyfill::this_context:findLast', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findLast( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); diff --git a/benchmark/polyfill/benchmark.find_last.length.js b/benchmark/polyfill/benchmark.find_last.length.js deleted file mode 100644 index 5abddac..0000000 --- a/benchmark/polyfill/benchmark.find_last.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value < 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.findLast( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - 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( format( '%s::polyfill:findLast:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.find_last_index.js b/benchmark/polyfill/benchmark.find_last_index.js deleted file mode 100644 index 9fc8543..0000000 --- a/benchmark/polyfill/benchmark.find_last_index.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:findLastIndex', pkg ), function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findLastIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -bench( format( '%s::polyfill::this_context:findLastIndex', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findLastIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); diff --git a/benchmark/polyfill/benchmark.find_last_index.length.js b/benchmark/polyfill/benchmark.find_last_index.length.js deleted file mode 100644 index cd49c40..0000000 --- a/benchmark/polyfill/benchmark.find_last_index.length.js +++ /dev/null @@ -1,110 +0,0 @@ -/** - * @license Apache-2.0 -* -* Copyright (c) 2026 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. -*/ - -/* eslint-disable stdlib/jsdoc-typedef-typos */ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {boolean} value - array element -* @param {NonNegativeInteger} idx - array element index -* @param {Float16Array} arr - array instance -* @returns {boolean} boolean indicating whether a value passes a test -*/ -function predicate( value ) { - return value < 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.findLastIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - 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( format( '%s::polyfill:findLastIndex:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.for_each.js b/benchmark/polyfill/benchmark.for_each.js deleted file mode 100644 index d16383b..0000000 --- a/benchmark/polyfill/benchmark.for_each.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:forEach', pkg ), function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( format( '%s::polyfill::this_context:forEach', pkg ), function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/benchmark/polyfill/benchmark.for_each.length.js b/benchmark/polyfill/benchmark.for_each.length.js deleted file mode 100644 index 5b4f977..0000000 --- a/benchmark/polyfill/benchmark.for_each.length.js +++ /dev/null @@ -1,108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// 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( format( '%s::polyfill:forEach:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.from.js b/benchmark/polyfill/benchmark.from.js deleted file mode 100644 index 8af766a..0000000 --- a/benchmark/polyfill/benchmark.from.js +++ /dev/null @@ -1,238 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( format( '%s::polyfill::typed_array:from', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::typed_array,clbk:from', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1.0; - } -}); - -bench( format( '%s::polyfill::array:from', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1.0, 2.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::array,clbk:from', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1.0, 2.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1.0; - } -}); - -bench( format( '%s::polyfill::iterable:from', pkg ), opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0.0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( format( '%s::polyfill::iterable,clbk:from:', pkg ), opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1.0, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1.0; - } -}); diff --git a/benchmark/polyfill/benchmark.get.js b/benchmark/polyfill/benchmark.get.js deleted file mode 100644 index 2bc111b..0000000 --- a/benchmark/polyfill/benchmark.get.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:get', pkg ), function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float16Array( uniform( 10, 0.0, 10.0 ) ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( typeof v !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNumber( v ) ) { - b.fail( 'should return a number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.includes.js b/benchmark/polyfill/benchmark.includes.js deleted file mode 100644 index 30fc8c4..0000000 --- a/benchmark/polyfill/benchmark.includes.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:includes', pkg ), function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Float16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1.0; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.includes.length.js b/benchmark/polyfill/benchmark.includes.length.js deleted file mode 100644 index 8ac1374..0000000 --- a/benchmark/polyfill/benchmark.includes.length.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1.0; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - 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( format( '%s::polyfill:includes:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.index_of.js b/benchmark/polyfill/benchmark.index_of.js deleted file mode 100644 index c11797c..0000000 --- a/benchmark/polyfill/benchmark.index_of.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:indexOf', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.indexOf( 11.0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( out ) ) { - b.fail( 'should return an integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.index_of.length.js b/benchmark/polyfill/benchmark.index_of.length.js deleted file mode 100644 index 96dfe78..0000000 --- a/benchmark/polyfill/benchmark.index_of.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.indexOf( 11.0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( out ) ) { - b.fail( 'should return an integer' ); - } - 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( format( '%s::polyfill:indexOf:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.join.js b/benchmark/polyfill/benchmark.join.js deleted file mode 100644 index d3d5a47..0000000 --- a/benchmark/polyfill/benchmark.join.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:join', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.join.length.js b/benchmark/polyfill/benchmark.join.length.js deleted file mode 100644 index ca50459..0000000 --- a/benchmark/polyfill/benchmark.join.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - 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( format( '%s::polyfill:join:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.js b/benchmark/polyfill/benchmark.js deleted file mode 100644 index 7c38bae..0000000 --- a/benchmark/polyfill/benchmark.js +++ /dev/null @@ -1,338 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( format( '%s::polyfill::instantiation,new', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array(); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::instantiation,no_new', pkg ), function benchmark( b ) { - var ctor; - var arr; - var i; - - ctor = Float16Array; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = ctor(); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::instantiation,length', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::instantiation,typed_array', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::instantiation,array', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = []; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::instantiation,iterable', pkg ), opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( createIterable() ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - return { - 'done': true - }; - } - } -}); - -bench( format( '%s::polyfill::instantiation,arraybuffer', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::instantiation,arraybuffer,byte_offset', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 8 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( buf, 8 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::instantiation,arraybuffer,byte_offset,length', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 8 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( buf, 8, 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::get:buffer', pkg ), function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float16Array(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::get:byteLength', pkg ), function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float16Array(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::get:byteOffset', pkg ), function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float16Array(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::get:length', pkg ), function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float16Array(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.keys.js b/benchmark/polyfill/benchmark.keys.js deleted file mode 100644 index b51d241..0000000 --- a/benchmark/polyfill/benchmark.keys.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:keys', pkg ), function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.keys.length.js b/benchmark/polyfill/benchmark.keys.length.js deleted file mode 100644 index c6ac13c..0000000 --- a/benchmark/polyfill/benchmark.keys.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var iter; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isIteratorLike( iter ) ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - 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( format( '%s::polyfill:keys:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.last_index_of.js b/benchmark/polyfill/benchmark.last_index_of.js deleted file mode 100644 index 950c98b..0000000 --- a/benchmark/polyfill/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:lastIndexOf', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.lastIndexOf( 11.0 ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.last_index_of.length.js b/benchmark/polyfill/benchmark.last_index_of.length.js deleted file mode 100644 index bf069bb..0000000 --- a/benchmark/polyfill/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.lastIndexOf( 11.0 ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - 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( format( '%s::polyfill:lastIndexOf:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.length.js b/benchmark/polyfill/benchmark.length.js deleted file mode 100644 index 488b91b..0000000 --- a/benchmark/polyfill/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s::polyfill:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.map.js b/benchmark/polyfill/benchmark.map.js deleted file mode 100644 index 810ce41..0000000 --- a/benchmark/polyfill/benchmark.map.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:map', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1.0; - } -}); - -bench( format( '%s::polyfill::this_context:map', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1.0; - } -}); diff --git a/benchmark/polyfill/benchmark.map.length.js b/benchmark/polyfill/benchmark.map.length.js deleted file mode 100644 index 6156472..0000000 --- a/benchmark/polyfill/benchmark.map.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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 = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s::polyfill:map:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.of.js b/benchmark/polyfill/benchmark.of.js deleted file mode 100644 index 165e244..0000000 --- a/benchmark/polyfill/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:of', pkg ), function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.of( i, 2.0 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.reduce.js b/benchmark/polyfill/benchmark.reduce.js deleted file mode 100644 index b8215bd..0000000 --- a/benchmark/polyfill/benchmark.reduce.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:reduce', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1.0; - } -}); - -bench( format( '%s::polyfill::initial_value:reduce', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3.14 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1.0; - } -}); diff --git a/benchmark/polyfill/benchmark.reduce.length.js b/benchmark/polyfill/benchmark.reduce.length.js deleted file mode 100644 index 6d74ccc..0000000 --- a/benchmark/polyfill/benchmark.reduce.length.js +++ /dev/null @@ -1,107 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - 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( format( '%s::polyfill:reduce:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.reduce_right.js b/benchmark/polyfill/benchmark.reduce_right.js deleted file mode 100644 index f2686f6..0000000 --- a/benchmark/polyfill/benchmark.reduce_right.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:reduceRight', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1.0; - } -}); - -bench( format( '%s::polyfill::initial_value:reduceRight', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3.14 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1.0; - } -}); diff --git a/benchmark/polyfill/benchmark.reduce_right.length.js b/benchmark/polyfill/benchmark.reduce_right.length.js deleted file mode 100644 index 62948e3..0000000 --- a/benchmark/polyfill/benchmark.reduce_right.length.js +++ /dev/null @@ -1,107 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - 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( format( '%s::polyfill:reduceRight:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.reverse.js b/benchmark/polyfill/benchmark.reverse.js deleted file mode 100644 index 386b361..0000000 --- a/benchmark/polyfill/benchmark.reverse.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:reverse', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.reverse.length.js b/benchmark/polyfill/benchmark.reverse.length.js deleted file mode 100644 index 5f051b7..0000000 --- a/benchmark/polyfill/benchmark.reverse.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s::polyfill:reverse:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.set.js b/benchmark/polyfill/benchmark.set.js deleted file mode 100644 index e2394cf..0000000 --- a/benchmark/polyfill/benchmark.set.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill::array:set', pkg ), function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Float16Array( 2 ); - buf = [ 0.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::typed_array:set', pkg ), function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Float16Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Float16Array( 2 ); - buf = new Float16Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.set.length.js b/benchmark/polyfill/benchmark.set.length.js deleted file mode 100644 index 72a56e7..0000000 --- a/benchmark/polyfill/benchmark.set.length.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - - arr1 = uniform( len, 0.0, 10.0 ); - arr2 = uniform( len, 0.0, 10.0 ); - arr = new Float16Array( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - 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( format( '%s::polyfill:set:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.slice.js b/benchmark/polyfill/benchmark.slice.js deleted file mode 100644 index 8ee2df0..0000000 --- a/benchmark/polyfill/benchmark.slice.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:slice', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.slice.length.js b/benchmark/polyfill/benchmark.slice.length.js deleted file mode 100644 index 232cff3..0000000 --- a/benchmark/polyfill/benchmark.slice.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s::polyfill:slice:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.some.js b/benchmark/polyfill/benchmark.some.js deleted file mode 100644 index c987ef3..0000000 --- a/benchmark/polyfill/benchmark.some.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:some', pkg ), function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); - -bench( format( '%s::polyfill::this_context:some', pkg ), function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); diff --git a/benchmark/polyfill/benchmark.some.length.js b/benchmark/polyfill/benchmark.some.length.js deleted file mode 100644 index fb689b5..0000000 --- a/benchmark/polyfill/benchmark.some.length.js +++ /dev/null @@ -1,107 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value < 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - 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( format( '%s::polyfill:some:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.sort.js b/benchmark/polyfill/benchmark.sort.js deleted file mode 100644 index 1ffaac3..0000000 --- a/benchmark/polyfill/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:sort', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.sort.length.js b/benchmark/polyfill/benchmark.sort.length.js deleted file mode 100644 index ec66cc2..0000000 --- a/benchmark/polyfill/benchmark.sort.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ i%len ] = i; - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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 = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s::polyfill:sort:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.subarray.js b/benchmark/polyfill/benchmark.subarray.js deleted file mode 100644 index b07f552..0000000 --- a/benchmark/polyfill/benchmark.subarray.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:subarray', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.subarray.length.js b/benchmark/polyfill/benchmark.subarray.length.js deleted file mode 100644 index 7313db0..0000000 --- a/benchmark/polyfill/benchmark.subarray.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s::polyfill:subarray:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.to_locale_string.js b/benchmark/polyfill/benchmark.to_locale_string.js deleted file mode 100644 index 7add18e..0000000 --- a/benchmark/polyfill/benchmark.to_locale_string.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:toLocaleString', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.to_locale_string.length.js b/benchmark/polyfill/benchmark.to_locale_string.length.js deleted file mode 100644 index 3f98d03..0000000 --- a/benchmark/polyfill/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - 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 = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s::polyfill:toLocaleString:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.to_reversed.js b/benchmark/polyfill/benchmark.to_reversed.js deleted file mode 100644 index ca7d6b5..0000000 --- a/benchmark/polyfill/benchmark.to_reversed.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:toReversed', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - 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 ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.to_reversed.length.js b/benchmark/polyfill/benchmark.to_reversed.length.js deleted file mode 100644 index e9fee39..0000000 --- a/benchmark/polyfill/benchmark.to_reversed.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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 ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s::polyfill:toReversed:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.to_sorted.js b/benchmark/polyfill/benchmark.to_sorted.js deleted file mode 100644 index 736fcf1..0000000 --- a/benchmark/polyfill/benchmark.to_sorted.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:toSorted', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toSorted(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.to_sorted.length.js b/benchmark/polyfill/benchmark.to_sorted.length.js deleted file mode 100644 index 32884b3..0000000 --- a/benchmark/polyfill/benchmark.to_sorted.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ i%len ] = i; - out = arr.toSorted(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a isFloat16Array' ); - } - 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( format( '%s::polyfill:toSorted:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.to_string.js b/benchmark/polyfill/benchmark.to_string.js deleted file mode 100644 index a2f7647..0000000 --- a/benchmark/polyfill/benchmark.to_string.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:toString', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.to_string.length.js b/benchmark/polyfill/benchmark.to_string.length.js deleted file mode 100644 index a772983..0000000 --- a/benchmark/polyfill/benchmark.to_string.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - 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 = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s::polyfill:toString:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.values.js b/benchmark/polyfill/benchmark.values.js deleted file mode 100644 index 59a4470..0000000 --- a/benchmark/polyfill/benchmark.values.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:values', pkg ), function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.values.length.js b/benchmark/polyfill/benchmark.values.length.js deleted file mode 100644 index f300b23..0000000 --- a/benchmark/polyfill/benchmark.values.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var iter; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isIteratorLike( iter ) ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - 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( format( '%s::polyfill:values:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.with.js b/benchmark/polyfill/benchmark.with.js deleted file mode 100644 index 05edb05..0000000 --- a/benchmark/polyfill/benchmark.with.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:with', pkg ), function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = uniform( 2, 0.0, 1.0 ); - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.with( i%arr.length, values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.with.length.js b/benchmark/polyfill/benchmark.with.length.js deleted file mode 100644 index cf76a7d..0000000 --- a/benchmark/polyfill/benchmark.with.length.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var values; - var out; - var i; - - values = uniform( 2, 0.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.with( i%len, values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s::polyfill:with:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 62eb7f0..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/float16" -%% click B href "https://github.com/stdlib-js/array-float16/tree/main" -%% click C href "https://github.com/stdlib-js/array-float16/tree/production" -%% click D href "https://github.com/stdlib-js/array-float16/tree/esm" -%% click E href "https://github.com/stdlib-js/array-float16/tree/deno" -%% click F href "https://github.com/stdlib-js/array-float16/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/float16 -[production-url]: https://github.com/stdlib-js/array-float16/tree/production -[deno-url]: https://github.com/stdlib-js/array-float16/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-float16/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-float16/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-float16/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-float16/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-float16/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 0b44231..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ctor from '../docs/types/index'; -export = ctor; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c93dada..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var T=function(o,r){return function(){return r||o((r={exports:{}}).exports,r),r.exports}};var O=T(function(pr,R){"use strict";var D=require("@stdlib/number-float64-base-to-float16"),J=require("@stdlib/number-float16-base-to-word");function K(o,r){var t,i;for(t=r.length,i=0;it.byteLength-o)throw new RangeError(s("invalid arguments. ArrayBuffer has insufficient capacity. Either decrease the array length or provide a bigger buffer. Minimum capacity: `%u`.",i*w));t=new b(t,o,i)}}for(f(this,"_buffer",t),f(this,"_length",t.length),n=0;n1){if(e=arguments[1],!p(e))throw new TypeError(s("invalid argument. Second argument must be a function. Value: `%s`.",e));i>2&&(t=arguments[2])}if(S(r)){if(e){for(h=r.length,n=new this(h),a=n._buffer,y=0;y=this._length))return g(this._buffer[r])});F(u.prototype,"buffer",function(){return this._buffer.buffer});F(u.prototype,"byteLength",function(){return this._buffer.byteLength});F(u.prototype,"byteOffset",function(){return this._buffer.byteOffset});f(u.prototype,"BYTES_PER_ELEMENT",u.BYTES_PER_ELEMENT);f(u.prototype,"copyWithin",function(r,t){if(!v(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");return arguments.length===2?this._buffer.copyWithin(r,t):this._buffer.copyWithin(r,t,arguments[2]),this});f(u.prototype,"entries",function(){var r,t,i,e,n,a;if(!v(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");return r=this,e=this._buffer,i=this._length,a=-1,t={},f(t,"next",l),f(t,"return",h),c&&f(t,c,y),t;function l(){return a+=1,n||a>=i?{done:!0}:{value:[a,g(e[a])],done:!1}}function h(q){return n=!0,arguments.length?{value:q,done:!0}:{done:!0}}function y(){return r.entries()}});f(u.prototype,"every",function(r,t){var i,e;if(!v(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!p(r))throw new TypeError(s("invalid argument. First argument must be a function. Value: `%s`.",r));for(i=this._buffer,e=0;e1){if(!m(t))throw new TypeError(s("invalid argument. Second argument must be an integer. Value: `%s`.",t));if(t<0&&(t+=n,t<0&&(t=0)),arguments.length>2){if(!m(i))throw new TypeError(s("invalid argument. Third argument must be an integer. Value: `%s`.",i));i<0&&(i+=n,i<0&&(i=0)),i>n&&(i=n)}else i=n}else t=0,i=n;for(l=E(r),a=t;a=0;n--)if(e=g(i[n]),r.call(t,e,n,this))return e});f(u.prototype,"findLastIndex",function(r,t){var i,e,n;if(!v(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!p(r))throw new TypeError(s("invalid argument. First argument must be a function. Value: `%s`.",r));for(i=this._buffer,n=this._length-1;n>=0;n--)if(e=g(i[n]),r.call(t,e,n,this))return n;return-1});f(u.prototype,"forEach",function(r,t){var i,e;if(!v(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!p(r))throw new TypeError(s("invalid argument. First argument must be a function. Value: `%s`.",r));for(i=this._buffer,e=0;e=this._length))return g(this._buffer[r])});f(u.prototype,"includes",function(r,t){var i,e,n;if(!v(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!d(r))throw new TypeError(s("invalid argument. First argument must be a number. Value: `%s`.",r));if(arguments.length>1){if(!m(t))throw new TypeError(s("invalid argument. Second argument must be an integer. Value: `%s`.",t));t<0&&(t+=this._length,t<0&&(t=0))}else t=0;for(i=this._buffer,n=E(r),e=t;e1){if(!m(t))throw new TypeError(s("invalid argument. Second argument must be an integer. Value: `%s`.",t));t<0&&(t+=this._length,t<0&&(t=0))}else t=0;for(i=this._buffer,n=E(r),e=t;e0){if(!P(r))throw new TypeError(s("invalid argument. First argument must be a string. Value: `%s`.",r))}else r=",";for(t=this._buffer,i=[],e=0;e=i?{done:!0}:{value:n,done:!1}}function l(y){return e=!0,arguments.length?{value:y,done:!0}:{done:!0}}function h(){return r.keys()}});f(u.prototype,"lastIndexOf",function(r,t){var i,e,n;if(!v(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!d(r))throw new TypeError(s("invalid argument. First argument must be a number. Value: `%s`.",r));if(arguments.length>1){if(!m(t))throw new TypeError(s("invalid argument. Second argument must be an integer. Value: `%s`.",t));t>=this._length?t=this._length-1:t<0&&(t+=this._length)}else t=this._length-1;for(i=this._buffer,n=E(r),e=t;e>=0;e--)if(n===i[e])return e;return-1});F(u.prototype,"length",function(){return this._length});f(u.prototype,"map",function(r,t){var i,e,n,a;if(!v(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!p(r))throw new TypeError("invalid argument. First argument must be a function. Value: `%s`.",r);for(n=this._buffer,e=new this.constructor(this._length),i=e._buffer,a=0;a1)n=t,a=0;else{if(e===0)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");n=g(i[0]),a=1}for(;a1)n=t,a=e-1;else{if(e===0)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");n=g(i[e-1]),a=e-2}for(;a>=0;a--)n=r(n,g(i[a]),a,this);return n});f(u.prototype,"reverse",function(){var r,t,i,e,n,a;if(!v(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");for(r=this._buffer,i=this._length,e=ir(i/2),n=0;n1){if(i=arguments[1],!_(i))throw new TypeError(s("invalid argument. Index argument must be a nonnegative integer. Value: `%s`.",i))}else i=0;if(l=r.length,i+l>this._length)throw new RangeError("invalid arguments. Target array lacks sufficient storage to accommodate source values.");if(v(r)?(t=r._buffer,a=!0):(t=r,a=!1),y=e.byteOffset+i*w,t.buffer===e.buffer&&t.byteOffsety){for(n=new b(t.length),h=0;hl&&(t=l)}}for(rh?1:0}function e(n,a){return r(g(n),g(a))}});f(u.prototype,"subarray",function(r,t){var i,e,n;if(!v(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(e=this._buffer,n=this._length,arguments.length===0)r=0,t=n;else{if(!m(r))throw new TypeError(s("invalid argument. First argument must be an integer. Value: `%s`.",r));if(r<0&&(r+=n,r<0&&(r=0)),arguments.length===1)t=n;else{if(!m(t))throw new TypeError(s("invalid argument. Second argument must be an integer. Value: `%s`.",t));t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n)}}return r>=n?(n=0,i=e.byteLength):r>=t?(n=0,i=e.byteOffset+r*w):(n=t-r,i=e.byteOffset+r*w),new this.constructor(e.buffer,i,n<0?0:n)});f(u.prototype,"toLocaleString",function(r,t){var i,e,n,a,l;if(!v(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(arguments.length===0)e=[];else if(P(r)||tr(r))e=r;else throw new TypeError(s("invalid argument. First argument must be a string or an array of strings. Value: `%s`.",r));if(arguments.length<2)i={};else if(A(t))i=t;else throw new TypeError(s("invalid argument. Options argument must be an object. Value: `%s`.",t));for(a=this._buffer,n=[],l=0;l=i?{done:!0}:{value:g(n[a]),done:!1}}function h(q){return e=!0,arguments.length?{value:q,done:!0}:{done:!0}}function y(){return t.values()}});f(u.prototype,"with",function(r,t){var i,e;if(!v(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!m(r))throw new TypeError(s("invalid argument. First argument must be an integer. Value: `%s`.",r));if(e=this._length,r<0&&(r+=e),r<0||r>=e)throw new RangeError(s("invalid argument. Index argument is out-of-bounds. Value: `%s`.",r));if(!d(t))throw new TypeError(s("invalid argument. Second argument must be a floating-point number. Value: `%s`.",t));return i=new this.constructor(this),i[r]=t,i});G.exports=u});var z=T(function(cr,U){"use strict";var lr=typeof Float16Array=="function"?Float16Array:void 0;U.exports=lr});var hr=require("@stdlib/assert-has-float16array-support"),vr=H(),gr=z(),L;hr()?L=gr:L=vr;module.exports=L; -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index c463d30..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/polyfill/from_array.js", "../lib/polyfill/from_iterator.js", "../lib/polyfill/from_iterator_map.js", "../lib/polyfill/index.js", "../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar f16 = require( '@stdlib/number-float64-base-to-float16' );\nvar toWord = require( '@stdlib/number-float16-base-to-word' );\n\n\n// MAIN //\n\n/**\n* Fills an output array with unsigned 16-bit integers corresponding to the IEEE 754 binary representation of respective half-precision floating-point numbers.\n*\n* @private\n* @param {Uint16Array} buf - output array\n* @param {Array} arr - input array\n* @returns {Uint16Array} output array\n*/\nfunction fromArray( buf, arr ) {\n\tvar len;\n\tvar i;\n\n\tlen = arr.length;\n\tfor ( i = 0; i < len; i++ ) {\n\t\tbuf[ i ] = toWord( f16( arr[ i ] ) );\n\t}\n\treturn buf;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fromArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar f16 = require( '@stdlib/number-float64-base-to-float16' );\nvar toWord = require( '@stdlib/number-float16-base-to-word' );\n\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @returns {Array} output array\n*/\nfunction fromIterator( it ) {\n\tvar out;\n\tvar v;\n\n\tout = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tout.push( toWord( f16( v.value ) ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fromIterator;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar f16 = require( '@stdlib/number-float64-base-to-float16' );\nvar toWord = require( '@stdlib/number-float16-base-to-word' );\n\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @param {Function} clbk - callback to invoke for each iterated value\n* @param {*} thisArg - invocation context\n* @returns {Array} output array\n*/\nfunction fromIteratorMap( it, clbk, thisArg ) {\n\tvar out;\n\tvar v;\n\tvar i;\n\n\tout = [];\n\ti = -1;\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\ti += 1;\n\t\tout.push( toWord( f16( clbk.call( thisArg, v.value, i ) ) ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fromIteratorMap;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this, stdlib/jsdoc-typedef-typos, max-lines */\n\n'use strict';\n\n// MODULES //\n\nvar hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' );\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar isStringArray = require( '@stdlib/assert-is-string-array' ).primitives;\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isObject = require( '@stdlib/assert-is-object' );\nvar isnan = require( '@stdlib/math-base-assert-is-nan' );\nvar ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' );\nvar floor = require( '@stdlib/math-base-special-floor' );\nvar format = require( '@stdlib/string-format' );\nvar Uint16Array = require( '@stdlib/array-uint16' );\nvar f16 = require( '@stdlib/number-float64-base-to-float16' );\nvar toWord = require( '@stdlib/number-float16-base-to-word' );\nvar fromWord = require( '@stdlib/number-float16-base-from-word' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar fromArray = require( './from_array.js' );\nvar fromIterator = require( './from_iterator.js' );\nvar fromIteratorMap = require( './from_iterator_map.js' );\n\n\n// VARIABLES //\n\nvar BYTES_PER_ELEMENT = Uint16Array.BYTES_PER_ELEMENT;\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\n\n\n// FUNCTIONS //\n\n/**\n* Returns a boolean indicating if a value is a `Float16Array`.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `Float16Array`\n*/\nfunction isFloat16Array( value ) {\n\treturn (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\tvalue.constructor.name === 'Float16Array' &&\n\t\tvalue.BYTES_PER_ELEMENT === BYTES_PER_ELEMENT\n\t);\n}\n\n/**\n* Returns a boolean indicating if a value is a floating-point typed array constructor.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a floating-point typed array constructor\n*/\nfunction isFloatingPointArrayConstructor( value ) { // eslint-disable-line id-length\n\treturn ( value === Float16Array );\n}\n\n/**\n* Returns a getter.\n*\n* @private\n* @param {Float16Array} ctx - typed array instance\n* @param {NonNegativeInteger} idx - element index\n* @returns {Function} getter\n*/\nfunction getter( ctx, idx ) {\n\treturn get;\n\n\t/**\n\t* Returns an array element.\n\t*\n\t* @private\n\t* @returns {(number|void)} array element\n\t*/\n\tfunction get() {\n\t\treturn ctx._get( idx ); // eslint-disable-line no-underscore-dangle\n\t}\n}\n\n/**\n* Returns a setter.\n*\n* @private\n* @param {Float16Array} ctx - typed array instance\n* @param {NonNegativeInteger} idx - element index\n* @returns {Function} setter\n*/\nfunction setter( ctx, idx ) {\n\treturn set;\n\n\t/**\n\t* Sets an array element.\n\t*\n\t* @private\n\t* @param {number} value - value to set\n\t*/\n\tfunction set( value ) {\n\t\tctx.set( [ value ], idx );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* 16-bit floating-point number array constructor.\n*\n* @constructor\n* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable\n* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n* @param {NonNegativeInteger} [length] - view length\n* @throws {RangeError} ArrayBuffer byte length must be a multiple of `2`\n* @throws {TypeError} if provided only a single argument, must provide a valid argument\n* @throws {TypeError} byte offset must be a nonnegative integer\n* @throws {RangeError} byte offset must be a multiple of `2`\n* @throws {TypeError} view length must be a positive multiple of `2`\n* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n* @returns {Float16Array} half-precision floating-point number array\n*\n* @example\n* var arr = new Float16Array();\n* // returns \n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var arr = new Float16Array( 5 );\n* // returns \n*\n* var len = arr.length;\n* // returns 5\n*\n* @example\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 5\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float16Array( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 8\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float16Array( buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 4\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Float16Array( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nfunction Float16Array() {\n\tvar byteOffset;\n\tvar nargs;\n\tvar buf;\n\tvar len;\n\tvar arg;\n\tvar i;\n\n\tnargs = arguments.length;\n\tif ( !(this instanceof Float16Array) ) {\n\t\tif ( nargs === 0 ) {\n\t\t\treturn new Float16Array();\n\t\t}\n\t\tif ( nargs === 1 ) {\n\t\t\treturn new Float16Array( arguments[0] );\n\t\t}\n\t\tif ( nargs === 2 ) {\n\t\t\treturn new Float16Array( arguments[0], arguments[1] );\n\t\t}\n\t\treturn new Float16Array( arguments[0], arguments[1], arguments[2] );\n\t}\n\t// Create the underlying data buffer...\n\tif ( nargs === 0 ) {\n\t\tbuf = new Uint16Array( 0 ); // backward-compatibility\n\t} else if ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\t\tif ( isNonNegativeInteger( arg ) ) {\n\t\t\tbuf = new Uint16Array( arg );\n\t\t} else if ( isCollection( arg ) ) {\n\t\t\tif ( isFloat16Array( arg ) ) {\n\t\t\t\tbuf = new Uint16Array( arg.length );\n\t\t\t\tgcopy.ndarray( arg.length, new Uint16Array( arg.buffer, arg.byteOffset, arg.length ), 1, 0, buf, 1, 0 ); // eslint-disable-line max-len\n\t\t\t} else {\n\t\t\t\tbuf = fromArray( new Uint16Array( arg.length ), arg );\n\t\t\t}\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tif ( !isInteger( arg.byteLength/BYTES_PER_ELEMENT ) ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer byte length must be a multiple of %u. Byte length: `%u`.', BYTES_PER_ELEMENT, arg.byteLength ) );\n\t\t\t}\n\t\t\tbuf = new Uint16Array( arg );\n\t\t} else if ( isObject( arg ) ) {\n\t\t\tif ( HAS_ITERATOR_SYMBOL === false ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, ArrayBuffer, typed array, or array-like object. Value: `%s`.', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t\t}\n\t\t\tbuf = arg[ ITERATOR_SYMBOL ]();\n\t\t\tif ( !isFunction( buf.next ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t\t}\n\t\t\tbuf = new Uint16Array( fromIterator( buf ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t}\n\t} else {\n\t\tbuf = arguments[ 0 ];\n\t\tif ( !isArrayBuffer( buf ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', buf ) );\n\t\t}\n\t\tbyteOffset = arguments[ 1 ];\n\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) );\n\t\t}\n\t\tif ( !isInteger( byteOffset/BYTES_PER_ELEMENT ) ) {\n\t\t\tthrow new RangeError( format( 'invalid argument. Byte offset must be a multiple of %u. Value: `%u`.', BYTES_PER_ELEMENT, byteOffset ) );\n\t\t}\n\t\tif ( nargs === 2 ) {\n\t\t\tlen = buf.byteLength - byteOffset;\n\t\t\tif ( !isInteger( len/BYTES_PER_ELEMENT ) ) {\n\t\t\t\tthrow new RangeError( format( 'invalid arguments. ArrayBuffer view byte length must be a multiple of %u. View byte length: `%u`.', BYTES_PER_ELEMENT, len ) );\n\t\t\t}\n\t\t\tbuf = new Uint16Array( buf, byteOffset );\n\t\t} else {\n\t\t\tlen = arguments[ 2 ];\n\t\t\tif ( !isNonNegativeInteger( len ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', len ) );\n\t\t\t}\n\t\t\tif ( (len*BYTES_PER_ELEMENT) > (buf.byteLength-byteOffset) ) {\n\t\t\t\tthrow new RangeError( format( 'invalid arguments. ArrayBuffer has insufficient capacity. Either decrease the array length or provide a bigger buffer. Minimum capacity: `%u`.', len*BYTES_PER_ELEMENT ) );\n\t\t\t}\n\t\t\tbuf = new Uint16Array( buf, byteOffset, len );\n\t\t}\n\t}\n\tsetReadOnly( this, '_buffer', buf );\n\tsetReadOnly( this, '_length', buf.length );\n\tfor ( i = 0; i < buf.length; i++ ) {\n\t\tsetReadWriteAccessor( this, i, getter( this, i ), setter( this, i ) );\n\t}\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each array element.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Float16Array\n* @readonly\n* @type {PositiveInteger}\n* @default 2\n*\n* @example\n* var nbytes = Float16Array.BYTES_PER_ELEMENT;\n* // returns 2\n*/\nsetReadOnly( Float16Array, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT );\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof Float16Array\n* @readonly\n* @type {string}\n* @default 'Float16Array'\n*\n* @example\n* var str = Float16Array.name;\n* // returns 'Float16Array'\n*/\nsetReadOnly( Float16Array, 'name', 'Float16Array' );\n\n/**\n* Creates a new 16-bit floating-point number array from an array-like object or an iterable.\n*\n* @name from\n* @memberof Float16Array\n* @type {Function}\n* @param {(Collection|Iterable)} src - array-like object or iterable\n* @param {Function} [clbk] - callback to invoke for each source element\n* @param {*} [thisArg] - context\n* @throws {TypeError} `this` context must be a constructor\n* @throws {TypeError} `this` must be a floating-point array\n* @throws {TypeError} first argument must be an array-like object or an iterable\n* @throws {TypeError} second argument must be a function\n* @returns {Float16Array} half-precision floating-point number array\n*\n* @example\n* var arr = Float16Array.from( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* function clbk( v ) {\n* return v * 2.0;\n* }\n*\n* var arr = Float16Array.from( [ 1.0, 2.0 ], clbk );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nsetReadOnly( Float16Array, 'from', function from( src ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar clbk;\n\tvar out;\n\tvar buf;\n\tvar tmp;\n\tvar len;\n\tvar i;\n\tif ( !isFunction( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` context must be a constructor.' );\n\t}\n\tif ( !isFloatingPointArrayConstructor( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point array.' );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs > 1 ) {\n\t\tclbk = arguments[ 1 ];\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t\tif ( nargs > 2 ) {\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( isCollection( src ) ) {\n\t\tif ( clbk ) {\n\t\t\tlen = src.length;\n\t\t\tout = new this( len );\n\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tbuf[ i ] = toWord( f16( clbk.call( thisArg, src[ i ], i ) ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\treturn new this( src );\n\t}\n\tif ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) { // eslint-disable-line max-len\n\t\tbuf = src[ ITERATOR_SYMBOL ]();\n\t\tif ( !isFunction( buf.next ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) );\n\t\t}\n\t\tif ( clbk ) {\n\t\t\ttmp = fromIteratorMap( buf, clbk, thisArg );\n\t\t} else {\n\t\t\ttmp = fromIterator( buf );\n\t\t}\n\t\tif ( tmp instanceof Error ) {\n\t\t\tthrow tmp;\n\t\t}\n\t\tlen = tmp.length;\n\t\tout = new this( len );\n\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tbuf[ i ] = tmp[ i ];\n\t\t}\n\t\treturn out;\n\t}\n\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) );\n});\n\n/**\n* Creates a new 16-bit floating-point number array from a variable number of arguments.\n*\n* @name of\n* @memberof Float16Array\n* @type {Function}\n* @param {...*} element - array elements\n* @throws {TypeError} `this` context must be a constructor\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Float16Array} half-precision floating-point number array\n*\n* @example\n* var arr = Float16Array.of( 1.0, 1.0, 1.0, 1.0 );\n* // returns \n*\n* var x = arr[ 0 ];\n* // returns 1.0\n*\n* var len = arr.length;\n* // returns 4\n*/\nsetReadOnly( Float16Array, 'of', function of() {\n\tvar args;\n\tvar i;\n\tif ( !isFunction( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` context must be a constructor.' );\n\t}\n\tif ( !isFloatingPointArrayConstructor( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\targs = [];\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\targs.push( arguments[ i ] );\n\t}\n\treturn new this( args );\n});\n\n/**\n* Returns an array element with support for both nonnegative and negative integer indices.\n*\n* @name at\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} must provide an integer\n* @returns {(number|void)} array element\n*\n* @example\n* var arr = new Float16Array( [ 10.0, 20.0, 30.0 ] );\n*\n* var v = arr.at( 0 );\n* // returns 10.0\n*\n* v = arr.at( -1 );\n* // returns 30.0\n*\n* v = arr.at( 100 );\n* // returns undefined\n*/\nsetReadOnly( Float16Array.prototype, 'at', function at( idx ) {\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += this._length;\n\t}\n\tif ( idx < 0 || idx >= this._length ) {\n\t\treturn;\n\t}\n\treturn fromWord( this._buffer[ idx ] );\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name buffer\n* @memberof Float16Array.prototype\n* @readonly\n* @type {ArrayBuffer}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var buf = arr.buffer;\n* // returns \n*/\nsetReadOnlyAccessor( Float16Array.prototype, 'buffer', function get() {\n\treturn this._buffer.buffer;\n});\n\n/**\n* Size (in bytes) of the array.\n*\n* @name byteLength\n* @memberof Float16Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var byteLength = arr.byteLength;\n* // returns 20\n*/\nsetReadOnlyAccessor( Float16Array.prototype, 'byteLength', function get() {\n\treturn this._buffer.byteLength;\n});\n\n/**\n* Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`.\n*\n* @name byteOffset\n* @memberof Float16Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var byteOffset = arr.byteOffset;\n* // returns 0\n*/\nsetReadOnlyAccessor( Float16Array.prototype, 'byteOffset', function get() {\n\treturn this._buffer.byteOffset;\n});\n\n/**\n* Size (in bytes) of each array element.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Float16Array.prototype\n* @readonly\n* @type {PositiveInteger}\n* @default 2\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var nbytes = arr.BYTES_PER_ELEMENT;\n* // returns 2\n*/\nsetReadOnly( Float16Array.prototype, 'BYTES_PER_ELEMENT', Float16Array.BYTES_PER_ELEMENT );\n\n/**\n* Copies a sequence of elements within the array to the position starting at `target`.\n*\n* @name copyWithin\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} target - index at which to start copying elements\n* @param {integer} start - source index at which to copy elements from\n* @param {integer} [end] - source index at which to stop copying elements from\n* @throws {TypeError} `this` must be a floating-point array\n* @returns {Float16Array} modified array\n*\n* @example\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0 ] );\n*\n* // Copy the first two elements to the last two elements:\n* arr.copyWithin( 2, 0, 2 );\n*\n* var v = arr[ 2 ];\n* // returns 1.0\n*\n* v = arr[ 3 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'copyWithin', function copyWithin( target, start ) {\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\t// FIXME: prefer a functional `copyWithin` implementation which addresses lack of universal browser support (e.g., IE11 and Safari) or ensure that typed arrays are polyfilled\n\tif ( arguments.length === 2 ) {\n\t\tthis._buffer.copyWithin( target, start );\n\t} else {\n\t\tthis._buffer.copyWithin( target, start, arguments[2] );\n\t}\n\treturn this;\n});\n\n/**\n* Returns an iterator for iterating over array key-value pairs.\n*\n* @name entries\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] );\n*\n* var it = arr.entries();\n*\n* var v = it.next().value;\n* // returns [ 0, 1.0 ]\n*\n* v = it.next().value;\n* // returns [ 1, 2.0 ]\n*\n* v = it.next().value;\n* // returns [ 2, 3.0 ]\n*\n* var bool = it.next().done;\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'entries', function entries() {\n\tvar self;\n\tvar iter;\n\tvar len;\n\tvar buf;\n\tvar FLG;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tself = this;\n\tbuf = this._buffer;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': [ i, fromWord( buf[ i ] ) ],\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.entries();\n\t}\n});\n\n/**\n* Tests whether all elements in an array pass a test implemented by a predicate function.\n*\n* @name every\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {boolean} boolean indicating whether all elements pass a test\n*\n* @example\n* function predicate( v ) {\n* return v === 0.0;\n* }\n*\n* var arr = new Float16Array( 3 );\n*\n* var bool = arr.every( predicate );\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'every', function every( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( !predicate.call( thisArg, fromWord( buf[ i ] ), i, this ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n});\n\n/**\n* Returns a modified typed array filled with a fill value.\n*\n* @name fill\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {number} value - fill value\n* @param {integer} [start=0] - starting index (inclusive)\n* @param {integer} [end] - ending index (exclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a floating-point number\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be an integer\n* @returns {Float16Array} modified array\n*\n* @example\n* var arr = new Float16Array( 3 );\n*\n* arr.fill( 1.0, 1 );\n*\n* var v = arr[ 0 ];\n* // returns 0.0\n*\n* v = arr[ 1 ];\n* // returns 1.0\n*\n* v = arr[ 2 ];\n* // returns 1.0\n*/\nsetReadOnly( Float16Array.prototype, 'fill', function fill( value, start, end ) {\n\tvar buf;\n\tvar len;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNumber( value ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a number. Value: `%s`.', value ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( start ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', start ) );\n\t\t}\n\t\tif ( start < 0 ) {\n\t\t\tstart += len;\n\t\t\tif ( start < 0 ) {\n\t\t\t\tstart = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length > 2 ) {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t} else {\n\t\t\tend = len;\n\t\t}\n\t} else {\n\t\tstart = 0;\n\t\tend = len;\n\t}\n\tv = toWord( value );\n\tfor ( i = start; i < end; i++ ) {\n\t\tbuf[ i ] = v;\n\t}\n\treturn this;\n});\n\n/**\n* Returns a new array containing the elements of an array which pass a test implemented by a predicate function.\n*\n* @name filter\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {Float16Array} floating-point number array\n*\n* @example\n* function predicate( v ) {\n* return ( v === 0.0 );\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] );\n*\n* var out = arr.filter( predicate );\n* // returns \n*\n* var len = out.length;\n* // returns 2\n*\n* var v = out[ 0 ];\n* // returns 0.0\n*\n* v = out[ 1 ];\n* // returns 0.0\n*/\nsetReadOnly( Float16Array.prototype, 'filter', function filter( predicate, thisArg ) {\n\tvar buf;\n\tvar out;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\tout.push( v );\n\t\t}\n\t}\n\treturn new this.constructor( out );\n});\n\n/**\n* Returns the first element in an array for which a predicate function returns a truthy value.\n*\n* @name find\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {(boolean|void)} array element or undefined\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] );\n*\n* var v = arr.find( predicate );\n* // returns 1.0\n*/\nsetReadOnly( Float16Array.prototype, 'find', function find( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn v;\n\t\t}\n\t}\n});\n\n/**\n* Returns the index of the first element in an array for which a predicate function returns a truthy value.\n*\n* @name findIndex\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {integer} index or -1\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var v = arr.findIndex( predicate );\n* // returns 1\n*/\nsetReadOnly( Float16Array.prototype, 'findIndex', function findIndex( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Returns the last element in an array for which a predicate function returns a truthy value.\n*\n* @name findLast\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {(boolean|void)} array element or undefined\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] );\n*\n* var v = arr.findLast( predicate );\n* // returns 1.0\n*/\nsetReadOnly( Float16Array.prototype, 'findLast', function findLast( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = this._length-1; i >= 0; i-- ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn v;\n\t\t}\n\t}\n});\n\n/**\n* Returns the index of the last element in an array for which a predicate function returns a truthy value.\n*\n* @name findLastIndex\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {integer} index or -1\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] );\n*\n* var v = arr.findLastIndex( predicate );\n* // returns 1\n*/\nsetReadOnly( Float16Array.prototype, 'findLastIndex', function findLastIndex( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = this._length-1; i >= 0; i-- ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Invokes a function once for each array element.\n*\n* @name forEach\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} fcn - function to invoke\n* @param {*} [thisArg] - function invocation context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n*\n* @example\n* function log( v, i ) {\n* console.log( '%s: %s', i, v.toString() );\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* arr.forEach( log );\n*/\nsetReadOnly( Float16Array.prototype, 'forEach', function forEach( fcn, thisArg ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( fcn ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tfcn.call( thisArg, fromWord( buf[ i ] ), i, this );\n\t}\n});\n\n/**\n* Returns an array element.\n*\n* @private\n* @name _get\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {NonNegativeInteger} idx - element index\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} must provide a nonnegative integer\n* @returns {(number|void)} array element\n*/\nsetReadOnly( Float16Array.prototype, '_get', function get( idx ) {\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNonNegativeInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a nonnegative integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx >= this._length ) {\n\t\treturn;\n\t}\n\treturn fromWord( this._buffer[ idx ] );\n});\n\n/**\n* Returns a boolean indicating whether an array includes a provided value.\n*\n* @name includes\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {number} searchElement - search element\n* @param {integer} [fromIndex=0] - starting index (inclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a floating-point number\n* @throws {TypeError} second argument must be an integer\n* @returns {boolean} boolean indicating whether an array includes a value\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] );\n*\n* var bool = arr.includes( 1.0 );\n* // returns true\n*\n* bool = arr.includes( 1.0, 2 );\n* // returns false\n*\n* bool = arr.includes( 5.0 );\n* // returns false\n*/\nsetReadOnly( Float16Array.prototype, 'includes', function includes( searchElement, fromIndex ) {\n\tvar buf;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNumber( searchElement ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a number. Value: `%s`.', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\tfromIndex = 0;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfromIndex = 0;\n\t}\n\tbuf = this._buffer;\n\tv = toWord( searchElement );\n\tfor ( i = fromIndex; i < this._length; i++ ) {\n\t\tif ( v === buf[ i ] ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n});\n\n/**\n* Returns the first index at which a given element can be found.\n*\n* @name indexOf\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {float16} searchElement - element to find\n* @param {integer} [fromIndex=0] - starting index (inclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a floating-point number\n* @throws {TypeError} second argument must be an integer\n* @returns {integer} index or -1\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] );\n*\n* var idx = arr.indexOf( 2.0 );\n* // returns 2\n*\n* idx = arr.indexOf( 2.0, 3 );\n* // returns -1\n*\n* idx = arr.indexOf( 3.0, 3 );\n* // returns 3\n*/\nsetReadOnly( Float16Array.prototype, 'indexOf', function indexOf( searchElement, fromIndex ) {\n\tvar buf;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNumber( searchElement ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a number. Value: `%s`.', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\tfromIndex = 0;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfromIndex = 0;\n\t}\n\tbuf = this._buffer;\n\tv = toWord( searchElement );\n\tfor ( i = fromIndex; i < this._length; i++ ) {\n\t\tif ( v === buf[ i ] ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Returns a new string by concatenating all array elements.\n*\n* @name join\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {string} [separator=','] - element separator\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a string\n* @returns {string} string representation\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var str = arr.join();\n* // returns '0,1,2'\n*\n* str = arr.join( '|' );\n* // returns '0|1|2'\n*/\nsetReadOnly( Float16Array.prototype, 'join', function join( separator ) {\n\tvar buf;\n\tvar out;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( arguments.length > 0 ) {\n\t\tif ( !isString( separator ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', separator ) );\n\t\t}\n\t} else {\n\t\tseparator = ',';\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( fromWord( buf[ i ] ) );\n\t}\n\treturn out.join( separator );\n});\n\n/**\n* Returns an iterator for iterating over each index key in a typed array.\n*\n* @name keys\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new Float16Array( [ 1.0, 2.0 ] );\n*\n* var iter = arr.keys();\n*\n* var v = iter.next().value;\n* // returns 0\n*\n* v = iter.next().value;\n* // returns 1\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'keys', function keys() {\n\tvar self;\n\tvar iter;\n\tvar len;\n\tvar FLG;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tself = this;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': i,\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.keys();\n\t}\n});\n\n/**\n* Returns the last index at which a given element can be found.\n*\n* @name lastIndexOf\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {number} searchElement - element to find\n* @param {integer} [fromIndex] - starting index (inclusive)\n* @throws {TypeError} `this` must be a floating-point number\n* @throws {TypeError} first argument must be a numeric value\n* @throws {TypeError} second argument must be an integer\n* @returns {integer} index or -1\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 2.0 ] );\n*\n* var idx = arr.lastIndexOf( 2.0 );\n* // returns 4\n*\n* idx = arr.lastIndexOf( 2.0, 3 );\n* // returns 2\n*\n* idx = arr.lastIndexOf( 4.0, 3 );\n* // returns -1\n*\n* idx = arr.lastIndexOf( 1.0, -3 );\n* // returns 1\n*/\nsetReadOnly( Float16Array.prototype, 'lastIndexOf', function lastIndexOf( searchElement, fromIndex ) {\n\tvar buf;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNumber( searchElement ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a number. Value: `%s`.', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex >= this._length ) {\n\t\t\tfromIndex = this._length - 1;\n\t\t} else if ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t}\n\t} else {\n\t\tfromIndex = this._length - 1;\n\t}\n\tbuf = this._buffer;\n\tv = toWord( searchElement );\n\tfor ( i = fromIndex; i >= 0; i-- ) {\n\t\tif ( v === buf[ i ] ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Number of array elements.\n*\n* @name length\n* @memberof Float16Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var len = arr.length;\n* // returns 10\n*/\nsetReadOnlyAccessor( Float16Array.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Returns a new array with each element being the result of a provided callback function.\n*\n* @name map\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} fcn - callback function\n* @param {*} [thisArg] - callback function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {Float16Array} new floating-point number array\n*\n* @example\n* function scale( v ) {\n* return v * 2.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var out = arr.map( scale );\n* // returns \n*\n* var z = out[ 0 ];\n* // returns 0.0\n*\n* z = out[ 1 ];\n* // returns 2.0\n*\n* z = out[ 2 ];\n* // returns 4.0\n*/\nsetReadOnly( Float16Array.prototype, 'map', function map( fcn, thisArg ) {\n\tvar outbuf;\n\tvar out;\n\tvar buf;\n\tvar i;\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( fcn ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be a function. Value: `%s`.', fcn );\n\t}\n\tbuf = this._buffer;\n\tout = new this.constructor( this._length );\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\toutbuf[ i ] = toWord( fcn.call( thisArg, fromWord( buf[ i ] ), i, this ) ); // eslint-disable-line max-len\n\t}\n\treturn out;\n});\n\n/**\n* Applies a provided callback function to each element of the array, in order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion.\n*\n* @name reduce\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} reducer - callback function\n* @param {*} [initialValue] - initial value\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {Error} if not provided an initial value, the array must have at least one element\n* @returns {*} accumulated result\n*\n* @example\n* function add( acc, v ) {\n* return acc + v;\n* }\n*\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] );\n*\n* var out = arr.reduce( add, 0 );\n* // returns 6.0\n*/\nsetReadOnly( Float16Array.prototype, 'reduce', function reduce( reducer, initialValue ) {\n\tvar buf;\n\tvar len;\n\tvar acc;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( reducer ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', reducer ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tacc = initialValue;\n\t\ti = 0;\n\t} else {\n\t\tif ( len === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' );\n\t\t}\n\t\tacc = fromWord( buf[ 0 ] );\n\t\ti = 1;\n\t}\n\tfor ( ; i < len; i++ ) {\n\t\tacc = reducer( acc, fromWord( buf[ i ] ), i, this );\n\t}\n\treturn acc;\n});\n\n/**\n* Applies a provided callback function to each element of the array, in reverse order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion.\n*\n* @name reduceRight\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} reducer - callback function\n* @param {*} [initialValue] - initial value\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {Error} if not provided an initial value, the array must have at least one element\n* @returns {*} accumulated result\n*\n* @example\n* function add( acc, v ) {\n* return acc + v;\n* }\n*\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] );\n*\n* var out = arr.reduceRight( add, 0 );\n* // returns 6.0\n*/\nsetReadOnly( Float16Array.prototype, 'reduceRight', function reduceRight( reducer, initialValue ) {\n\tvar buf;\n\tvar len;\n\tvar acc;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( reducer ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', reducer ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tacc = initialValue;\n\t\ti = len - 1;\n\t} else {\n\t\tif ( len === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' );\n\t\t}\n\t\tacc = fromWord( buf[ len-1 ] );\n\t\ti = len - 2;\n\t}\n\tfor ( ; i >= 0; i-- ) {\n\t\tacc = reducer( acc, fromWord( buf[ i ] ), i, this );\n\t}\n\treturn acc;\n});\n\n/**\n* Reverses an array in-place.\n*\n* @name reverse\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Float16Array} reversed array\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var out = arr.reverse();\n* // returns \n*\n* var v = out[ 0 ];\n* // returns 2.0\n*\n* v = out[ 1 ];\n* // returns 1.0\n*\n* v = out[ 2 ];\n* // returns 0.0\n*/\nsetReadOnly( Float16Array.prototype, 'reverse', function reverse() {\n\tvar buf;\n\tvar tmp;\n\tvar len;\n\tvar N;\n\tvar i;\n\tvar j;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tN = floor( len / 2 );\n\tfor ( i = 0; i < N; i++ ) {\n\t\tj = len - i - 1;\n\t\ttmp = buf[ i ];\n\t\tbuf[ i ] = buf[ j ];\n\t\tbuf[ j ] = tmp;\n\t}\n\treturn this;\n});\n\n/**\n* Sets one or more array elements.\n*\n* ## Notes\n*\n* - When provided a typed array, we must check whether the source array shares the same buffer as the target array and whether the underlying memory overlaps. In particular, we are concerned with the following scenario:\n*\n* ```text\n* buf: ---------------------\n* src: ---------------------\n* ```\n*\n* In the above, as we copy values from `src`, we will overwrite values in the `src` view, resulting in duplicated values copied into the end of `buf`, which is not intended. Hence, to avoid overwriting source values, we must **copy** source values to a temporary array.\n*\n* In the other overlapping scenario,\n*\n* ```text\n* buf: ---------------------\n* src: ---------------------\n* ```\n*\n* by the time we begin copying into the overlapping region, we are copying from the end of `src`, a non-overlapping region, which means we don't run the risk of copying copied values, rather than the original `src` values, as intended.\n*\n* @name set\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {(Collection|Float16Array)} value - value(s)\n* @param {NonNegativeInteger} [i=0] - element index at which to start writing values\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a collection\n* @throws {TypeError} index argument must be a nonnegative integer\n* @throws {RangeError} index argument is out-of-bounds\n* @throws {RangeError} target array lacks sufficient storage to accommodate source values\n* @returns {void}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var v = arr[ 0 ];\n* // returns 0.0\n*\n* arr.set( [ 1.0, 2.0 ], 0 );\n*\n* v = arr[ 0 ];\n* // returns 1.0\n*/\nsetReadOnly( Float16Array.prototype, 'set', function set( value ) {\n\tvar sbuf;\n\tvar idx;\n\tvar buf;\n\tvar tmp;\n\tvar flg;\n\tvar N;\n\tvar i;\n\tvar j;\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isCollection( value ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', value ) );\n\t}\n\tbuf = this._buffer;\n\tif ( arguments.length > 1 ) {\n\t\tidx = arguments[ 1 ];\n\t\tif ( !isNonNegativeInteger( idx ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Index argument must be a nonnegative integer. Value: `%s`.', idx ) );\n\t\t}\n\t} else {\n\t\tidx = 0;\n\t}\n\tN = value.length;\n\tif ( idx+N > this._length ) {\n\t\tthrow new RangeError( 'invalid arguments. Target array lacks sufficient storage to accommodate source values.' );\n\t}\n\tif ( isFloat16Array( value ) ) {\n\t\tsbuf = value._buffer; // eslint-disable-line no-underscore-dangle\n\t\tflg = true;\n\t} else {\n\t\tsbuf = value;\n\t\tflg = false;\n\t}\n\t// Check for overlapping memory...\n\tj = buf.byteOffset + (idx*BYTES_PER_ELEMENT);\n\tif (\n\t\tsbuf.buffer === buf.buffer &&\n\t\t(\n\t\t\tsbuf.byteOffset < j &&\n\t\t\tsbuf.byteOffset+sbuf.byteLength > j\n\t\t)\n\t) {\n\t\t// We need to copy source values...\n\t\ttmp = new Uint16Array( sbuf.length );\n\t\tfor ( i = 0; i < sbuf.length; i++ ) {\n\t\t\ttmp[ i ] = sbuf[ i ];\n\t\t}\n\t\tsbuf = tmp;\n\t}\n\tif ( flg ) {\n\t\tfor ( i = 0; i < N; idx++, i++ ) {\n\t\t\tbuf[ idx ] = sbuf[ i ];\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < N; idx++, i++ ) {\n\t\t\tbuf[ idx ] = toWord( sbuf[ i ] );\n\t\t}\n\t}\n});\n\n/**\n* Copies a portion of a typed array to a new typed array.\n*\n* @name slice\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} [begin] - start index (inclusive)\n* @param {integer} [end] - end index (exclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be integer\n* @throws {TypeError} second argument must be integer\n* @returns {Float16Array} floating-point number array\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] );\n*\n* var out = arr.slice();\n* // returns \n*\n* var len = out.length;\n* // returns 5\n*\n* var v = out[ 0 ];\n* // returns 0.0\n*\n* v = out[ len-1 ];\n* // returns 4.0\n*\n* out = arr.slice( 1, -2 );\n* // returns \n*\n* len = out.length;\n* // returns 2\n*\n* v = out[ 0 ];\n* // returns 1.0\n*\n* v = out[ len-1 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'slice', function slice( begin, end ) {\n\tvar outlen;\n\tvar outbuf;\n\tvar out;\n\tvar buf;\n\tvar len;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length === 0 ) {\n\t\tbegin = 0;\n\t\tend = len;\n\t} else {\n\t\tif ( !isInteger( begin ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', begin ) );\n\t\t}\n\t\tif ( begin < 0 ) {\n\t\t\tbegin += len;\n\t\t\tif ( begin < 0 ) {\n\t\t\t\tbegin = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\tend = len;\n\t\t} else {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t} else if ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t}\n\t}\n\tif ( begin < end ) {\n\t\toutlen = end - begin;\n\t} else {\n\t\toutlen = 0;\n\t}\n\tout = new this.constructor( outlen );\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < outlen; i++ ) {\n\t\toutbuf[ i ] = buf[ i+begin ];\n\t}\n\treturn out;\n});\n\n/**\n* Tests whether at least one element in an array passes a test implemented by a predicate function.\n*\n* @name some\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {boolean} boolean indicating whether at least one element passes a test\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var bool = arr.some( predicate );\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'some', function some( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( predicate.call( thisArg, fromWord( buf[ i ] ), i, this ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n});\n\n/**\n* Sorts an array in-place.\n*\n* @name sort\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} [compareFcn] - comparison function\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {Float16Array} sorted array\n*\n* @example\n* function compare( a, b ) {\n* if ( a < b ) {\n* return -1;\n* }\n* if ( a > b ) {\n* return 1;\n* }\n* return 0;\n* }\n*\n* var arr = new Float16Array( [ 1.0, 0.0, 2.0 ] );\n*\n* arr.sort( compare );\n*\n* var v = arr[ 0 ];\n* // returns 0.0\n*\n* v = arr[ 1 ];\n* // returns 1.0\n*\n* v = arr[ 2 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'sort', function sort( compareFcn ) {\n\tvar buf;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tif ( arguments.length === 0 ) {\n\t\tbuf.sort( defaultCompare );\n\t\treturn this;\n\t}\n\tif ( !isFunction( compareFcn ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', compareFcn ) );\n\t}\n\tbuf.sort( compare );\n\treturn this;\n\n\t/**\n\t* Default comparison function for float16 values.\n\t*\n\t* @private\n\t* @param {unsigned16} a - unsigned 16-bit integer for comparison\n\t* @param {unsigned16} b - unsigned 16-bit integer for comparison\n\t* @returns {number} comparison result\n\t*/\n\tfunction defaultCompare( a, b ) { // eslint-disable-line stdlib/no-unnecessary-nested-functions\n\t\tvar x = fromWord( a );\n\t\tvar y = fromWord( b );\n\n\t\t// Handle NaN...\n\t\tif ( isnan( x ) && isnan( y ) ) {\n\t\t\treturn 0;\n\t\t}\n\t\tif ( isnan( x ) ) {\n\t\t\treturn 1;\n\t\t}\n\t\tif ( isnan( y ) ) {\n\t\t\treturn -1;\n\t\t}\n\t\t// Normal comparison\n\t\tif ( x < y ) {\n\t\t\treturn -1;\n\t\t}\n\t\tif ( x > y ) {\n\t\t\treturn 1;\n\t\t}\n\t\treturn 0;\n\t}\n\n\t/**\n\t* Comparison function wrapper.\n\t*\n\t* @private\n\t* @param {unsigned16} a - unsigned 16-bit integer for comparison\n\t* @param {unsigned16} b - unsigned 16-bit integer for comparison\n\t* @returns {number} comparison result\n\t*/\n\tfunction compare( a, b ) {\n\t\treturn compareFcn( fromWord( a ), fromWord( b ) );\n\t}\n});\n\n/**\n* Creates a new typed array view over the same underlying `ArrayBuffer` and with the same underlying data type as the host array.\n*\n* @name subarray\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} [begin] - start index (inclusive)\n* @param {integer} [end] - end index (exclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be an integer\n* @throws {TypeError} second argument must be an integer\n* @returns {Float16Array} subarray\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] );\n*\n* var subarr = arr.subarray();\n* // returns \n*\n* var len = subarr.length;\n* // returns 5\n*\n* var bool = subarr[ 0 ];\n* // returns 0.0\n*\n* bool = subarr[ len-1 ];\n* // returns 4.0\n*\n* subarr = arr.subarray( 1, -2 );\n* // returns \n*\n* len = subarr.length;\n* // returns 2\n*\n* bool = subarr[ 0 ];\n* // returns 1.0\n*\n* bool = subarr[ len-1 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'subarray', function subarray( begin, end ) {\n\tvar offset;\n\tvar buf;\n\tvar len;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length === 0 ) {\n\t\tbegin = 0;\n\t\tend = len;\n\t} else {\n\t\tif ( !isInteger( begin ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', begin ) );\n\t\t}\n\t\tif ( begin < 0 ) {\n\t\t\tbegin += len;\n\t\t\tif ( begin < 0 ) {\n\t\t\t\tbegin = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\tend = len;\n\t\t} else {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t} else if ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t}\n\t}\n\tif ( begin >= len ) {\n\t\tlen = 0;\n\t\toffset = buf.byteLength;\n\t} else if ( begin >= end ) {\n\t\tlen = 0;\n\t\toffset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT );\n\t} else {\n\t\tlen = end - begin;\n\t\toffset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT );\n\t}\n\treturn new this.constructor( buf.buffer, offset, ( len < 0 ) ? 0 : len );\n});\n\n/**\n* Serializes an array as a locale-specific string.\n*\n* @name toLocaleString\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {(string|Array)} [locales] - locale identifier(s)\n* @param {Object} [options] - configuration options\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a string or an array of strings\n* @throws {TypeError} options argument must be an object\n* @returns {string} string representation\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var str = arr.toLocaleString();\n* // returns '0,1,2'\n*/\nsetReadOnly( Float16Array.prototype, 'toLocaleString', function toLocaleString( locales, options ) {\n\tvar opts;\n\tvar loc;\n\tvar out;\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( arguments.length === 0 ) {\n\t\tloc = [];\n\t} else if ( isString( locales ) || isStringArray( locales ) ) {\n\t\tloc = locales;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a string or an array of strings. Value: `%s`.', locales ) );\n\t}\n\tif ( arguments.length < 2 ) {\n\t\topts = {};\n\t} else if ( isObject( options ) ) {\n\t\topts = options;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( fromWord( buf[ i ] ) );\n\t}\n\treturn out.toLocaleString( loc, opts );\n});\n\n/**\n* Returns a new typed array containing the elements in reversed order.\n*\n* @name toReversed\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Float16Array} reversed array\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var out = arr.toReversed();\n* // returns \n*\n* var v = out[ 0 ];\n* // returns 2.0\n*\n* v = out[ 1 ];\n* // returns 1.0\n*\n* v = out[ 2 ];\n* // returns 0.0\n*/\nsetReadOnly( Float16Array.prototype, 'toReversed', function toReversed() {\n\tvar outbuf;\n\tvar out;\n\tvar len;\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tlen = this._length;\n\tout = new this.constructor( len );\n\tbuf = this._buffer;\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < len; i++ ) {\n\t\toutbuf[ i ] = buf[ len - i - 1 ];\n\t}\n\treturn out;\n});\n\n/**\n* Returns a new typed array containing the elements in sorted order.\n*\n* @name toSorted\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} [compareFcn] - comparison function\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {Float16Array} sorted array\n*\n* @example\n* function compare( a, b ) {\n* if ( a > b ) {\n* return 1;\n* }\n* if ( a < b ) {\n* return -1;\n* }\n* return 0;\n* }\n*\n* var arr = new Float16Array( [ 2.0, 0.0, 1.0 ] );\n*\n* var out = arr.toSorted( compare );\n* // returns \n*\n* var v = out[ 0 ];\n* // returns 0.0\n*\n* v = out[ 1 ];\n* // returns 1.0\n*\n* v = out[ 2 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'toSorted', function toSorted( compareFcn ) {\n\tvar out;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tout = new this.constructor( this );\n\tif ( arguments.length === 0 ) {\n\t\treturn out.sort();\n\t}\n\treturn out.sort( compareFcn );\n});\n\n/**\n* Serializes an array as a string.\n*\n* @name toString\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {string} string representation\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var str = arr.toString();\n* // returns '0,1,2'\n*/\nsetReadOnly( Float16Array.prototype, 'toString', function toString() {\n\tvar out;\n\tvar buf;\n\tvar i;\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( fromWord( buf[ i ] ) );\n\t}\n\treturn out.join( ',' );\n});\n\n/**\n* Returns an iterator for iterating over each value in a typed array.\n*\n* @name values\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0 ] );\n*\n* var iter = arr.values();\n*\n* var v = iter.next().value;\n* // returns 0.0\n*\n* v = iter.next().value;\n* // returns 1.0\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'values', function values() {\n\tvar iter;\n\tvar self;\n\tvar len;\n\tvar FLG;\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tself = this;\n\tbuf = this._buffer;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': fromWord( buf[ i ] ),\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.values();\n\t}\n});\n\n/**\n* Returns a new typed array with the element at a provided index replaced with a provided value.\n*\n* @name with\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} index - element index\n* @param {number} value - new value\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be an integer\n* @throws {RangeError} index argument is out-of-bounds\n* @throws {TypeError} second argument must be a floating-point number\n* @returns {Float16Array} new typed array\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var out = arr.with( 0, 3.0 );\n* // returns \n*\n* var v = out[ 0 ];\n* // returns 3.0\n*/\nsetReadOnly( Float16Array.prototype, 'with', function copyWith( index, value ) {\n\tvar out;\n\tvar len;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isInteger( index ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', index ) );\n\t}\n\tlen = this._length;\n\tif ( index < 0 ) {\n\t\tindex += len;\n\t}\n\tif ( index < 0 || index >= len ) {\n\t\tthrow new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%s`.', index ) );\n\t}\n\tif ( !isNumber( value ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a floating-point number. Value: `%s`.', value ) );\n\t}\n\tout = new this.constructor( this );\n\tout[ index ] = value;\n\treturn out;\n});\n\n\n// EXPORTS //\n\nmodule.exports = Float16Array;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Float16Array === 'function' ) ? Float16Array : void 0; // eslint-disable-line no-undef, stdlib/require-globals\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* 16-bit floating-point number array constructor.\n*\n* @module @stdlib/array-float16\n*\n* @example\n* var Float16Array = require( '@stdlib/array-float16' );\n*\n* var arr = new Float16Array();\n* // returns \n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var Float16Array = require( '@stdlib/array-float16' );\n*\n* var arr = new Float16Array( 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var Float16Array = require( '@stdlib/array-float16' );\n*\n* var arr = new Float16Array( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var Float16Array = require( '@stdlib/array-float16' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float16Array( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 8\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var Float16Array = require( '@stdlib/array-float16' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float16Array( buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 4\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var Float16Array = require( '@stdlib/array-float16' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Float16Array( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\n\n// MODULES //\n\nvar hasFloat16ArraySupport = require( '@stdlib/assert-has-float16array-support' );\nvar polyfill = require( './polyfill' );\nvar builtin = require( './main.js' );\n\n\n// MAIN //\n\nvar ctor;\nif ( hasFloat16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAM,QAAS,wCAAyC,EACxDC,EAAS,QAAS,qCAAsC,EAa5D,SAASC,EAAWC,EAAKC,EAAM,CAC9B,IAAIC,EACA,EAGJ,IADAA,EAAMD,EAAI,OACJ,EAAI,EAAG,EAAIC,EAAK,IACrBF,EAAK,CAAE,EAAIF,EAAQD,EAAKI,EAAK,CAAE,CAAE,CAAE,EAEpC,OAAOD,CACR,CAKAJ,EAAO,QAAUG,IClDjB,IAAAI,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAM,QAAS,wCAAyC,EACxDC,EAAS,QAAS,qCAAsC,EAY5D,SAASC,EAAcC,EAAK,CAC3B,IAAIC,EACAC,EAGJ,IADAD,EAAM,CAAC,EAENC,EAAIF,EAAG,KAAK,EACP,CAAAE,EAAE,MAGPD,EAAI,KAAMH,EAAQD,EAAKK,EAAE,KAAM,CAAE,CAAE,EAEpC,OAAOD,CACR,CAKAL,EAAO,QAAUG,ICrDjB,IAAAI,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAM,QAAS,wCAAyC,EACxDC,EAAS,QAAS,qCAAsC,EAc5D,SAASC,EAAiBC,EAAIC,EAAMC,EAAU,CAC7C,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAM,CAAC,EACPE,EAAI,GAEHD,EAAIJ,EAAG,KAAK,EACP,CAAAI,EAAE,MAGPC,GAAK,EACLF,EAAI,KAAML,EAAQD,EAAKI,EAAK,KAAMC,EAASE,EAAE,MAAOC,CAAE,CAAE,CAAE,CAAE,EAE7D,OAAOF,CACR,CAKAP,EAAO,QAAUG,IC1DjB,IAAAO,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAwBA,IAAIC,GAA2B,QAAS,4CAA6C,EACjFC,EAAuB,QAAS,uCAAwC,EAAE,YAC1EC,GAAgB,QAAS,gCAAiC,EAAE,WAC5DC,EAAe,QAAS,8BAA+B,EACvDC,EAAgB,QAAS,+BAAgC,EACzDC,EAAa,QAAS,4BAA6B,EACnDC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAW,QAAS,0BAA2B,EAC/CC,EAAQ,QAAS,iCAAkC,EACnDC,EAAkB,QAAS,yBAA0B,EACrDC,EAAsB,QAAS,uDAAwD,EACvFC,EAAc,QAAS,uDAAwD,EAC/EC,GAAuB,QAAS,0CAA2C,EAC3EC,GAAQ,QAAS,iCAAkC,EACnDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAc,QAAS,sBAAuB,EAC9CC,GAAM,QAAS,wCAAyC,EACxDC,EAAS,QAAS,qCAAsC,EACxDC,EAAW,QAAS,uCAAwC,EAC5DC,GAAQ,QAAS,yBAA0B,EAC3CC,GAAY,IACZC,EAAe,IACfC,GAAkB,IAKlBC,EAAoBR,EAAY,kBAChCS,EAAsB1B,GAAyB,EAYnD,SAAS2B,EAAgBC,EAAQ,CAChC,OACC,OAAOA,GAAU,UACjBA,IAAU,MACVA,EAAM,YAAY,OAAS,gBAC3BA,EAAM,oBAAsBH,CAE9B,CASA,SAASI,EAAiCD,EAAQ,CACjD,OAASA,IAAUE,CACpB,CAUA,SAASC,GAAQC,EAAKC,EAAM,CAC3B,OAAOC,EAQP,SAASA,GAAM,CACd,OAAOF,EAAI,KAAMC,CAAI,CACtB,CACD,CAUA,SAASE,GAAQH,EAAKC,EAAM,CAC3B,OAAOG,EAQP,SAASA,EAAKR,EAAQ,CACrBI,EAAI,IAAK,CAAEJ,CAAM,EAAGK,CAAI,CACzB,CACD,CAuEA,SAASH,GAAe,CACvB,IAAIO,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAJ,EAAQ,UAAU,OACb,EAAE,gBAAgBR,GACtB,OAAKQ,IAAU,EACP,IAAIR,EAEPQ,IAAU,EACP,IAAIR,EAAc,UAAU,CAAC,CAAE,EAElCQ,IAAU,EACP,IAAIR,EAAc,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,EAE9C,IAAIA,EAAc,UAAU,CAAC,EAAG,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,EAGnE,GAAKQ,IAAU,EACdC,EAAM,IAAItB,EAAa,CAAE,UACdqB,IAAU,EAErB,GADAG,EAAM,UAAW,CAAE,EACdxC,EAAsBwC,CAAI,EAC9BF,EAAM,IAAItB,EAAawB,CAAI,UAChBtC,EAAcsC,CAAI,EACxBd,EAAgBc,CAAI,GACxBF,EAAM,IAAItB,EAAawB,EAAI,MAAO,EAClCpB,GAAM,QAASoB,EAAI,OAAQ,IAAIxB,EAAawB,EAAI,OAAQA,EAAI,WAAYA,EAAI,MAAO,EAAG,EAAG,EAAGF,EAAK,EAAG,CAAE,GAEtGA,EAAMjB,GAAW,IAAIL,EAAawB,EAAI,MAAO,EAAGA,CAAI,UAE1CrC,EAAeqC,CAAI,EAAI,CAClC,GAAK,CAACnC,EAAWmC,EAAI,WAAWhB,CAAkB,EACjD,MAAM,IAAI,WAAYT,EAAQ,yFAA0FS,EAAmBgB,EAAI,UAAW,CAAE,EAE7JF,EAAM,IAAItB,EAAawB,CAAI,CAC5B,SAAYhC,EAAUgC,CAAI,EAAI,CAC7B,GAAKf,IAAwB,GAC5B,MAAM,IAAI,UAAWV,EAAQ,mJAAoJyB,CAAI,CAAE,EAExL,GAAK,CAACpC,EAAYoC,EAAK9B,CAAgB,CAAE,EACxC,MAAM,IAAI,UAAWK,EAAQ,qHAAsHyB,CAAI,CAAE,EAG1J,GADAF,EAAME,EAAK9B,CAAgB,EAAE,EACxB,CAACN,EAAYkC,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWvB,EAAQ,qHAAsHyB,CAAI,CAAE,EAE1JF,EAAM,IAAItB,EAAaM,EAAcgB,CAAI,CAAE,CAC5C,KACC,OAAM,IAAI,UAAWvB,EAAQ,qHAAsHyB,CAAI,CAAE,MAEpJ,CAEN,GADAF,EAAM,UAAW,CAAE,EACd,CAACnC,EAAemC,CAAI,EACxB,MAAM,IAAI,UAAWvB,EAAQ,wEAAyEuB,CAAI,CAAE,EAG7G,GADAF,EAAa,UAAW,CAAE,EACrB,CAACpC,EAAsBoC,CAAW,EACtC,MAAM,IAAI,UAAWrB,EAAQ,4EAA6EqB,CAAW,CAAE,EAExH,GAAK,CAAC/B,EAAW+B,EAAWZ,CAAkB,EAC7C,MAAM,IAAI,WAAYT,EAAQ,uEAAwES,EAAmBY,CAAW,CAAE,EAEvI,GAAKC,IAAU,EAAI,CAElB,GADAE,EAAMD,EAAI,WAAaF,EAClB,CAAC/B,EAAWkC,EAAIf,CAAkB,EACtC,MAAM,IAAI,WAAYT,EAAQ,oGAAqGS,EAAmBe,CAAI,CAAE,EAE7JD,EAAM,IAAItB,EAAasB,EAAKF,CAAW,CACxC,KAAO,CAEN,GADAG,EAAM,UAAW,CAAE,EACd,CAACvC,EAAsBuC,CAAI,EAC/B,MAAM,IAAI,UAAWxB,EAAQ,uEAAwEwB,CAAI,CAAE,EAE5G,GAAMA,EAAIf,EAAsBc,EAAI,WAAWF,EAC9C,MAAM,IAAI,WAAYrB,EAAQ,iJAAkJwB,EAAIf,CAAkB,CAAE,EAEzMc,EAAM,IAAItB,EAAasB,EAAKF,EAAYG,CAAI,CAC7C,CACD,CAGA,IAFA3B,EAAa,KAAM,UAAW0B,CAAI,EAClC1B,EAAa,KAAM,UAAW0B,EAAI,MAAO,EACnCG,EAAI,EAAGA,EAAIH,EAAI,OAAQG,IAC5B5B,GAAsB,KAAM4B,EAAGX,GAAQ,KAAMW,CAAE,EAAGP,GAAQ,KAAMO,CAAE,CAAE,EAErE,OAAO,IACR,CAeA7B,EAAaiB,EAAc,oBAAqBL,CAAkB,EAelEZ,EAAaiB,EAAc,OAAQ,cAAe,EAmClDjB,EAAaiB,EAAc,OAAQ,SAAea,EAAM,CACvD,IAAIC,EACAN,EACAO,EACAC,EACAP,EACAQ,EACAP,EACAE,EACJ,GAAK,CAACrC,EAAY,IAAK,EACtB,MAAM,IAAI,UAAW,2DAA4D,EAElF,GAAK,CAACwB,EAAiC,IAAK,EAC3C,MAAM,IAAI,UAAW,2DAA4D,EAGlF,GADAS,EAAQ,UAAU,OACbA,EAAQ,EAAI,CAEhB,GADAO,EAAO,UAAW,CAAE,EACf,CAACxC,EAAYwC,CAAK,EACtB,MAAM,IAAI,UAAW7B,EAAQ,qEAAsE6B,CAAK,CAAE,EAEtGP,EAAQ,IACZM,EAAU,UAAW,CAAE,EAEzB,CACA,GAAKzC,EAAcwC,CAAI,EAAI,CAC1B,GAAKE,EAAO,CAIX,IAHAL,EAAMG,EAAI,OACVG,EAAM,IAAI,KAAMN,CAAI,EACpBD,EAAMO,EAAI,QACJJ,EAAI,EAAGA,EAAIF,EAAKE,IACrBH,EAAKG,CAAE,EAAIvB,EAAQD,GAAK2B,EAAK,KAAMD,EAASD,EAAKD,CAAE,EAAGA,CAAE,CAAE,CAAE,EAE7D,OAAOI,CACR,CACA,OAAO,IAAI,KAAMH,CAAI,CACtB,CACA,GAAKlC,EAAUkC,CAAI,GAAKjB,GAAuBrB,EAAYsC,EAAKhC,CAAgB,CAAE,EAAI,CAErF,GADA4B,EAAMI,EAAKhC,CAAgB,EAAE,EACxB,CAACN,EAAYkC,EAAI,IAAK,EAC1B,MAAM,IAAI,UAAWvB,EAAQ,6FAA8F2B,CAAI,CAAE,EAOlI,GALKE,EACJE,EAAMvB,GAAiBe,EAAKM,EAAMD,CAAQ,EAE1CG,EAAMxB,EAAcgB,CAAI,EAEpBQ,aAAe,MACnB,MAAMA,EAKP,IAHAP,EAAMO,EAAI,OACVD,EAAM,IAAI,KAAMN,CAAI,EACpBD,EAAMO,EAAI,QACJJ,EAAI,EAAGA,EAAIF,EAAKE,IACrBH,EAAKG,CAAE,EAAIK,EAAKL,CAAE,EAEnB,OAAOI,CACR,CACA,MAAM,IAAI,UAAW9B,EAAQ,6FAA8F2B,CAAI,CAAE,CAClI,CAAC,EAuBD9B,EAAaiB,EAAc,KAAM,UAAc,CAC9C,IAAIkB,EACAN,EACJ,GAAK,CAACrC,EAAY,IAAK,EACtB,MAAM,IAAI,UAAW,2DAA4D,EAElF,GAAK,CAACwB,EAAiC,IAAK,EAC3C,MAAM,IAAI,UAAW,kEAAmE,EAGzF,IADAmB,EAAO,CAAC,EACFN,EAAI,EAAGA,EAAI,UAAU,OAAQA,IAClCM,EAAK,KAAM,UAAWN,CAAE,CAAE,EAE3B,OAAO,IAAI,KAAMM,CAAK,CACvB,CAAC,EAyBDnC,EAAaiB,EAAa,UAAW,KAAM,SAAaG,EAAM,CAC7D,GAAK,CAACN,EAAgB,IAAK,EAC1B,MAAM,IAAI,UAAW,kEAAmE,EAEzF,GAAK,CAACrB,EAAW2B,CAAI,EACpB,MAAM,IAAI,UAAWjB,EAAQ,0DAA2DiB,CAAI,CAAE,EAK/F,GAHKA,EAAM,IACVA,GAAO,KAAK,SAER,EAAAA,EAAM,GAAKA,GAAO,KAAK,SAG5B,OAAOb,EAAU,KAAK,QAASa,CAAI,CAAE,CACtC,CAAC,EAgBDrB,EAAqBkB,EAAa,UAAW,SAAU,UAAe,CACrE,OAAO,KAAK,QAAQ,MACrB,CAAC,EAgBDlB,EAAqBkB,EAAa,UAAW,aAAc,UAAe,CACzE,OAAO,KAAK,QAAQ,UACrB,CAAC,EAgBDlB,EAAqBkB,EAAa,UAAW,aAAc,UAAe,CACzE,OAAO,KAAK,QAAQ,UACrB,CAAC,EAiBDjB,EAAaiB,EAAa,UAAW,oBAAqBA,EAAa,iBAAkB,EA0BzFjB,EAAaiB,EAAa,UAAW,aAAc,SAAqBmB,EAAQC,EAAQ,CACvF,GAAK,CAACvB,EAAgB,IAAK,EAC1B,MAAM,IAAI,UAAW,kEAAmE,EAGzF,OAAK,UAAU,SAAW,EACzB,KAAK,QAAQ,WAAYsB,EAAQC,CAAM,EAEvC,KAAK,QAAQ,WAAYD,EAAQC,EAAO,UAAU,CAAC,CAAE,EAE/C,IACR,CAAC,EA4BDrC,EAAaiB,EAAa,UAAW,UAAW,UAAmB,CAClE,IAAIqB,EACAC,EACAZ,EACAD,EACAc,EACAX,EAEJ,GAAK,CAACf,EAAgB,IAAK,EAC1B,MAAM,IAAI,UAAW,kEAAmE,EAEzF,OAAAwB,EAAO,KACPZ,EAAM,KAAK,QACXC,EAAM,KAAK,QAGXE,EAAI,GAGJU,EAAO,CAAC,EACRvC,EAAauC,EAAM,OAAQE,CAAK,EAChCzC,EAAauC,EAAM,SAAUG,CAAI,EAE5B5C,GACJE,EAAauC,EAAMzC,EAAiB6C,CAAQ,EAEtCJ,EAQP,SAASE,GAAO,CAEf,OADAZ,GAAK,EACAW,GAAOX,GAAKF,EACT,CACN,KAAQ,EACT,EAEM,CACN,MAAS,CAAEE,EAAGtB,EAAUmB,EAAKG,CAAE,CAAE,CAAE,EACnC,KAAQ,EACT,CACD,CASA,SAASa,EAAK3B,EAAQ,CAErB,OADAyB,EAAM,GACD,UAAU,OACP,CACN,MAASzB,EACT,KAAQ,EACT,EAEM,CACN,KAAQ,EACT,CACD,CAQA,SAAS4B,GAAU,CAClB,OAAOL,EAAK,QAAQ,CACrB,CACD,CAAC,EAwBDtC,EAAaiB,EAAa,UAAW,QAAS,SAAgB2B,EAAWb,EAAU,CAClF,IAAIL,EACAG,EAEJ,GAAK,CAACf,EAAgB,IAAK,EAC1B,MAAM,IAAI,UAAW,kEAAmE,EAEzF,GAAK,CAACtB,EAAYoD,CAAU,EAC3B,MAAM,IAAI,UAAWzC,EAAQ,oEAAqEyC,CAAU,CAAE,EAG/G,IADAlB,EAAM,KAAK,QACLG,EAAI,EAAGA,EAAI,KAAK,QAASA,IAC9B,GAAK,CAACe,EAAU,KAAMb,EAASxB,EAAUmB,EAAKG,CAAE,CAAE,EAAGA,EAAG,IAAK,EAC5D,MAAO,GAGT,MAAO,EACR,CAAC,EA+BD7B,EAAaiB,EAAa,UAAW,OAAQ,SAAeF,EAAOsB,EAAOK,EAAM,CAC/E,IAAIhB,EACAC,EACAE,EACAgB,EAEJ,GAAK,CAAC/B,EAAgB,IAAK,EAC1B,MAAM,IAAI,UAAW,kEAAmE,EAEzF,GAAK,CAACpB,EAAUqB,CAAM,EACrB,MAAM,IAAI,UAAWZ,EAAQ,kEAAmEY,CAAM,CAAE,EAIzG,GAFAW,EAAM,KAAK,QACXC,EAAM,KAAK,QACN,UAAU,OAAS,EAAI,CAC3B,GAAK,CAAClC,EAAW4C,CAAM,EACtB,MAAM,IAAI,UAAWlC,EAAQ,qEAAsEkC,CAAM,CAAE,EAQ5G,GANKA,EAAQ,IACZA,GAASV,EACJU,EAAQ,IACZA,EAAQ,IAGL,UAAU,OAAS,EAAI,CAC3B,GAAK,CAAC5C,EAAWiD,CAAI,EACpB,MAAM,IAAI,UAAWvC,EAAQ,oEAAqEuC,CAAI,CAAE,EAEpGA,EAAM,IACVA,GAAOf,EACFe,EAAM,IACVA,EAAM,IAGHA,EAAMf,IACVe,EAAMf,EAER,MACCe,EAAMf,CAER,MACCU,EAAQ,EACRK,EAAMf,EAGP,IADAkB,EAAIvC,EAAQS,CAAM,EACZc,EAAIQ,EAAOR,EAAIa,EAAKb,IACzBH,EAAKG,CAAE,EAAIgB,EAEZ,OAAO,IACR,CAAC,EAiCD7C,EAAaiB,EAAa,UAAW,SAAU,SAAiB2B,EAAWb,EAAU,CACpF,IAAIL,EACAO,EACAJ,EACAgB,EAEJ,GAAK,CAAC/B,EAAgB,IAAK,EAC1B,MAAM,IAAI,UAAW,kEAAmE,EAEzF,GAAK,CAACtB,EAAYoD,CAAU,EAC3B,MAAM,IAAI,UAAWzC,EAAQ,oEAAqEyC,CAAU,CAAE,EAI/G,IAFAlB,EAAM,KAAK,QACXO,EAAM,CAAC,EACDJ,EAAI,EAAGA,EAAI,KAAK,QAASA,IAC9BgB,EAAItC,EAAUmB,EAAKG,CAAE,CAAE,EAClBe,EAAU,KAAMb,EAASc,EAAGhB,EAAG,IAAK,GACxCI,EAAI,KAAMY,CAAE,EAGd,OAAO,IAAI,KAAK,YAAaZ,CAAI,CAClC,CAAC,EAwBDjC,EAAaiB,EAAa,UAAW,OAAQ,SAAe2B,EAAWb,EAAU,CAChF,IAAIL,EACAmB,EACAhB,EAEJ,GAAK,CAACf,EAAgB,IAAK,EAC1B,MAAM,IAAI,UAAW,kEAAmE,EAEzF,GAAK,CAACtB,EAAYoD,CAAU,EAC3B,MAAM,IAAI,UAAWzC,EAAQ,oEAAqEyC,CAAU,CAAE,EAG/G,IADAlB,EAAM,KAAK,QACLG,EAAI,EAAGA,EAAI,KAAK,QAASA,IAE9B,GADAgB,EAAItC,EAAUmB,EAAKG,CAAE,CAAE,EAClBe,EAAU,KAAMb,EAASc,EAAGhB,EAAG,IAAK,EACxC,OAAOgB,CAGV,CAAC,EAwBD7C,EAAaiB,EAAa,UAAW,YAAa,SAAoB2B,EAAWb,EAAU,CAC1F,IAAIL,EACAmB,EACAhB,EAEJ,GAAK,CAACf,EAAgB,IAAK,EAC1B,MAAM,IAAI,UAAW,kEAAmE,EAEzF,GAAK,CAACtB,EAAYoD,CAAU,EAC3B,MAAM,IAAI,UAAWzC,EAAQ,oEAAqEyC,CAAU,CAAE,EAG/G,IADAlB,EAAM,KAAK,QACLG,EAAI,EAAGA,EAAI,KAAK,QAASA,IAE9B,GADAgB,EAAItC,EAAUmB,EAAKG,CAAE,CAAE,EAClBe,EAAU,KAAMb,EAASc,EAAGhB,EAAG,IAAK,EACxC,OAAOA,EAGT,MAAO,EACR,CAAC,EAwBD7B,EAAaiB,EAAa,UAAW,WAAY,SAAmB2B,EAAWb,EAAU,CACxF,IAAIL,EACAmB,EACAhB,EAEJ,GAAK,CAACf,EAAgB,IAAK,EAC1B,MAAM,IAAI,UAAW,kEAAmE,EAEzF,GAAK,CAACtB,EAAYoD,CAAU,EAC3B,MAAM,IAAI,UAAWzC,EAAQ,oEAAqEyC,CAAU,CAAE,EAG/G,IADAlB,EAAM,KAAK,QACLG,EAAI,KAAK,QAAQ,EAAGA,GAAK,EAAGA,IAEjC,GADAgB,EAAItC,EAAUmB,EAAKG,CAAE,CAAE,EAClBe,EAAU,KAAMb,EAASc,EAAGhB,EAAG,IAAK,EACxC,OAAOgB,CAGV,CAAC,EAwBD7C,EAAaiB,EAAa,UAAW,gBAAiB,SAAwB2B,EAAWb,EAAU,CAClG,IAAIL,EACAmB,EACAhB,EAEJ,GAAK,CAACf,EAAgB,IAAK,EAC1B,MAAM,IAAI,UAAW,kEAAmE,EAEzF,GAAK,CAACtB,EAAYoD,CAAU,EAC3B,MAAM,IAAI,UAAWzC,EAAQ,oEAAqEyC,CAAU,CAAE,EAG/G,IADAlB,EAAM,KAAK,QACLG,EAAI,KAAK,QAAQ,EAAGA,GAAK,EAAGA,IAEjC,GADAgB,EAAItC,EAAUmB,EAAKG,CAAE,CAAE,EAClBe,EAAU,KAAMb,EAASc,EAAGhB,EAAG,IAAK,EACxC,OAAOA,EAGT,MAAO,EACR,CAAC,EAsBD7B,EAAaiB,EAAa,UAAW,UAAW,SAAkB6B,EAAKf,EAAU,CAChF,IAAIL,EACAG,EAEJ,GAAK,CAACf,EAAgB,IAAK,EAC1B,MAAM,IAAI,UAAW,kEAAmE,EAEzF,GAAK,CAACtB,EAAYsD,CAAI,EACrB,MAAM,IAAI,UAAW3C,EAAQ,oEAAqE2C,CAAI,CAAE,EAGzG,IADApB,EAAM,KAAK,QACLG,EAAI,EAAGA,EAAI,KAAK,QAASA,IAC9BiB,EAAI,KAAMf,EAASxB,EAAUmB,EAAKG,CAAE,CAAE,EAAGA,EAAG,IAAK,CAEnD,CAAC,EAcD7B,EAAaiB,EAAa,UAAW,OAAQ,SAAcG,EAAM,CAChE,GAAK,CAACN,EAAgB,IAAK,EAC1B,MAAM,IAAI,UAAW,kEAAmE,EAEzF,GAAK,CAAC1B,EAAsBgC,CAAI,EAC/B,MAAM,IAAI,UAAWjB,EAAQ,qEAAsEiB,CAAI,CAAE,EAE1G,GAAK,EAAAA,GAAO,KAAK,SAGjB,OAAOb,EAAU,KAAK,QAASa,CAAI,CAAE,CACtC,CAAC,EA2BDpB,EAAaiB,EAAa,UAAW,WAAY,SAAmB8B,EAAeC,EAAY,CAC9F,IAAItB,EACAG,EACAgB,EAEJ,GAAK,CAAC/B,EAAgB,IAAK,EAC1B,MAAM,IAAI,UAAW,kEAAmE,EAEzF,GAAK,CAACpB,EAAUqD,CAAc,EAC7B,MAAM,IAAI,UAAW5C,EAAQ,kEAAmE4C,CAAc,CAAE,EAEjH,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACtD,EAAWuD,CAAU,EAC1B,MAAM,IAAI,UAAW7C,EAAQ,qEAAsE6C,CAAU,CAAE,EAE3GA,EAAY,IAChBA,GAAa,KAAK,QACbA,EAAY,IAChBA,EAAY,GAGf,MACCA,EAAY,EAIb,IAFAtB,EAAM,KAAK,QACXmB,EAAIvC,EAAQyC,CAAc,EACpBlB,EAAImB,EAAWnB,EAAI,KAAK,QAASA,IACtC,GAAKgB,IAAMnB,EAAKG,CAAE,EACjB,MAAO,GAGT,MAAO,EACR,CAAC,EA2BD7B,EAAaiB,EAAa,UAAW,UAAW,SAAkB8B,EAAeC,EAAY,CAC5F,IAAItB,EACAG,EACAgB,EAEJ,GAAK,CAAC/B,EAAgB,IAAK,EAC1B,MAAM,IAAI,UAAW,kEAAmE,EAEzF,GAAK,CAACpB,EAAUqD,CAAc,EAC7B,MAAM,IAAI,UAAW5C,EAAQ,kEAAmE4C,CAAc,CAAE,EAEjH,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACtD,EAAWuD,CAAU,EAC1B,MAAM,IAAI,UAAW7C,EAAQ,qEAAsE6C,CAAU,CAAE,EAE3GA,EAAY,IAChBA,GAAa,KAAK,QACbA,EAAY,IAChBA,EAAY,GAGf,MACCA,EAAY,EAIb,IAFAtB,EAAM,KAAK,QACXmB,EAAIvC,EAAQyC,CAAc,EACpBlB,EAAImB,EAAWnB,EAAI,KAAK,QAASA,IACtC,GAAKgB,IAAMnB,EAAKG,CAAE,EACjB,OAAOA,EAGT,MAAO,EACR,CAAC,EAsBD7B,EAAaiB,EAAa,UAAW,OAAQ,SAAegC,EAAY,CACvE,IAAIvB,EACAO,EACAJ,EAEJ,GAAK,CAACf,EAAgB,IAAK,EAC1B,MAAM,IAAI,UAAW,kEAAmE,EAEzF,GAAK,UAAU,OAAS,GACvB,GAAK,CAACnB,EAAUsD,CAAU,EACzB,MAAM,IAAI,UAAW9C,EAAQ,kEAAmE8C,CAAU,CAAE,OAG7GA,EAAY,IAIb,IAFAvB,EAAM,KAAK,QACXO,EAAM,CAAC,EACDJ,EAAI,EAAGA,EAAI,KAAK,QAASA,IAC9BI,EAAI,KAAM1B,EAAUmB,EAAKG,CAAE,CAAE,CAAE,EAEhC,OAAOI,EAAI,KAAMgB,CAAU,CAC5B,CAAC,EAyBDjD,EAAaiB,EAAa,UAAW,OAAQ,UAAgB,CAC5D,IAAIqB,EACAC,EACAZ,EACAa,EACAX,EAEJ,GAAK,CAACf,EAAgB,IAAK,EAC1B,MAAM,IAAI,UAAW,kEAAmE,EAEzF,OAAAwB,EAAO,KACPX,EAAM,KAAK,QAGXE,EAAI,GAGJU,EAAO,CAAC,EACRvC,EAAauC,EAAM,OAAQE,CAAK,EAChCzC,EAAauC,EAAM,SAAUG,CAAI,EAE5B5C,GACJE,EAAauC,EAAMzC,EAAiB6C,CAAQ,EAEtCJ,EAQP,SAASE,GAAO,CAEf,OADAZ,GAAK,EACAW,GAAOX,GAAKF,EACT,CACN,KAAQ,EACT,EAEM,CACN,MAASE,EACT,KAAQ,EACT,CACD,CASA,SAASa,EAAK3B,EAAQ,CAErB,OADAyB,EAAM,GACD,UAAU,OACP,CACN,MAASzB,EACT,KAAQ,EACT,EAEM,CACN,KAAQ,EACT,CACD,CAQA,SAAS4B,GAAU,CAClB,OAAOL,EAAK,KAAK,CAClB,CACD,CAAC,EA8BDtC,EAAaiB,EAAa,UAAW,cAAe,SAAsB8B,EAAeC,EAAY,CACpG,IAAItB,EACAG,EACAgB,EAEJ,GAAK,CAAC/B,EAAgB,IAAK,EAC1B,MAAM,IAAI,UAAW,kEAAmE,EAEzF,GAAK,CAACpB,EAAUqD,CAAc,EAC7B,MAAM,IAAI,UAAW5C,EAAQ,kEAAmE4C,CAAc,CAAE,EAEjH,GAAK,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACtD,EAAWuD,CAAU,EAC1B,MAAM,IAAI,UAAW7C,EAAQ,qEAAsE6C,CAAU,CAAE,EAE3GA,GAAa,KAAK,QACtBA,EAAY,KAAK,QAAU,EAChBA,EAAY,IACvBA,GAAa,KAAK,QAEpB,MACCA,EAAY,KAAK,QAAU,EAI5B,IAFAtB,EAAM,KAAK,QACXmB,EAAIvC,EAAQyC,CAAc,EACpBlB,EAAImB,EAAWnB,GAAK,EAAGA,IAC5B,GAAKgB,IAAMnB,EAAKG,CAAE,EACjB,OAAOA,EAGT,MAAO,EACR,CAAC,EAgBD9B,EAAqBkB,EAAa,UAAW,SAAU,UAAe,CACrE,OAAO,KAAK,OACb,CAAC,EAiCDjB,EAAaiB,EAAa,UAAW,MAAO,SAAc6B,EAAKf,EAAU,CACxE,IAAImB,EACAjB,EACAP,EACAG,EACJ,GAAK,CAACf,EAAgB,IAAK,EAC1B,MAAM,IAAI,UAAW,kEAAmE,EAEzF,GAAK,CAACtB,EAAYsD,CAAI,EACrB,MAAM,IAAI,UAAW,oEAAqEA,CAAI,EAK/F,IAHApB,EAAM,KAAK,QACXO,EAAM,IAAI,KAAK,YAAa,KAAK,OAAQ,EACzCiB,EAASjB,EAAI,QACPJ,EAAI,EAAGA,EAAI,KAAK,QAASA,IAC9BqB,EAAQrB,CAAE,EAAIvB,EAAQwC,EAAI,KAAMf,EAASxB,EAAUmB,EAAKG,CAAE,CAAE,EAAGA,EAAG,IAAK,CAAE,EAE1E,OAAOI,CACR,CAAC,EAwBDjC,EAAaiB,EAAa,UAAW,SAAU,SAAiBkC,EAASC,EAAe,CACvF,IAAI1B,EACAC,EACA0B,EACAxB,EAEJ,GAAK,CAACf,EAAgB,IAAK,EAC1B,MAAM,IAAI,UAAW,kEAAmE,EAEzF,GAAK,CAACtB,EAAY2D,CAAQ,EACzB,MAAM,IAAI,UAAWhD,EAAQ,oEAAqEgD,CAAQ,CAAE,EAI7G,GAFAzB,EAAM,KAAK,QACXC,EAAM,KAAK,QACN,UAAU,OAAS,EACvB0B,EAAMD,EACNvB,EAAI,MACE,CACN,GAAKF,IAAQ,EACZ,MAAM,IAAI,MAAO,kGAAmG,EAErH0B,EAAM9C,EAAUmB,EAAK,CAAE,CAAE,EACzBG,EAAI,CACL,CACA,KAAQA,EAAIF,EAAKE,IAChBwB,EAAMF,EAASE,EAAK9C,EAAUmB,EAAKG,CAAE,CAAE,EAAGA,EAAG,IAAK,EAEnD,OAAOwB,CACR,CAAC,EAwBDrD,EAAaiB,EAAa,UAAW,cAAe,SAAsBkC,EAASC,EAAe,CACjG,IAAI1B,EACAC,EACA0B,EACAxB,EAEJ,GAAK,CAACf,EAAgB,IAAK,EAC1B,MAAM,IAAI,UAAW,kEAAmE,EAEzF,GAAK,CAACtB,EAAY2D,CAAQ,EACzB,MAAM,IAAI,UAAWhD,EAAQ,oEAAqEgD,CAAQ,CAAE,EAI7G,GAFAzB,EAAM,KAAK,QACXC,EAAM,KAAK,QACN,UAAU,OAAS,EACvB0B,EAAMD,EACNvB,EAAIF,EAAM,MACJ,CACN,GAAKA,IAAQ,EACZ,MAAM,IAAI,MAAO,kGAAmG,EAErH0B,EAAM9C,EAAUmB,EAAKC,EAAI,CAAE,CAAE,EAC7BE,EAAIF,EAAM,CACX,CACA,KAAQE,GAAK,EAAGA,IACfwB,EAAMF,EAASE,EAAK9C,EAAUmB,EAAKG,CAAE,CAAE,EAAGA,EAAG,IAAK,EAEnD,OAAOwB,CACR,CAAC,EA0BDrD,EAAaiB,EAAa,UAAW,UAAW,UAAmB,CAClE,IAAIS,EACAQ,EACAP,EACA2B,EACAzB,EACA0B,EAEJ,GAAK,CAACzC,EAAgB,IAAK,EAC1B,MAAM,IAAI,UAAW,kEAAmE,EAKzF,IAHAY,EAAM,KAAK,QACXC,EAAM,KAAK,QACX2B,EAAIpD,GAAOyB,EAAM,CAAE,EACbE,EAAI,EAAGA,EAAIyB,EAAGzB,IACnB0B,EAAI5B,EAAME,EAAI,EACdK,EAAMR,EAAKG,CAAE,EACbH,EAAKG,CAAE,EAAIH,EAAK6B,CAAE,EAClB7B,EAAK6B,CAAE,EAAIrB,EAEZ,OAAO,IACR,CAAC,EAgDDlC,EAAaiB,EAAa,UAAW,MAAO,SAAcF,EAAQ,CACjE,IAAIyC,EACApC,EACAM,EACAQ,EACAuB,EACAH,EACAzB,EACA0B,EACJ,GAAK,CAACzC,EAAgB,IAAK,EAC1B,MAAM,IAAI,UAAW,kEAAmE,EAEzF,GAAK,CAACxB,EAAcyB,CAAM,EACzB,MAAM,IAAI,UAAWZ,EAAQ,8EAA+EY,CAAM,CAAE,EAGrH,GADAW,EAAM,KAAK,QACN,UAAU,OAAS,GAEvB,GADAN,EAAM,UAAW,CAAE,EACd,CAAChC,EAAsBgC,CAAI,EAC/B,MAAM,IAAI,UAAWjB,EAAQ,+EAAgFiB,CAAI,CAAE,OAGpHA,EAAM,EAGP,GADAkC,EAAIvC,EAAM,OACLK,EAAIkC,EAAI,KAAK,QACjB,MAAM,IAAI,WAAY,wFAAyF,EAWhH,GATKxC,EAAgBC,CAAM,GAC1ByC,EAAOzC,EAAM,QACb0C,EAAM,KAEND,EAAOzC,EACP0C,EAAM,IAGPF,EAAI7B,EAAI,WAAcN,EAAIR,EAEzB4C,EAAK,SAAW9B,EAAI,QAEnB8B,EAAK,WAAaD,GAClBC,EAAK,WAAWA,EAAK,WAAaD,EAElC,CAGD,IADArB,EAAM,IAAI9B,EAAaoD,EAAK,MAAO,EAC7B3B,EAAI,EAAGA,EAAI2B,EAAK,OAAQ3B,IAC7BK,EAAKL,CAAE,EAAI2B,EAAM3B,CAAE,EAEpB2B,EAAOtB,CACR,CACA,GAAKuB,EACJ,IAAM5B,EAAI,EAAGA,EAAIyB,EAAGlC,IAAOS,IAC1BH,EAAKN,CAAI,EAAIoC,EAAM3B,CAAE,MAGtB,KAAMA,EAAI,EAAGA,EAAIyB,EAAGlC,IAAOS,IAC1BH,EAAKN,CAAI,EAAId,EAAQkD,EAAM3B,CAAE,CAAE,CAGlC,CAAC,EA0CD7B,EAAaiB,EAAa,UAAW,QAAS,SAAgByC,EAAOhB,EAAM,CAC1E,IAAIiB,EACAT,EACAjB,EACAP,EACAC,EACAE,EAEJ,GAAK,CAACf,EAAgB,IAAK,EAC1B,MAAM,IAAI,UAAW,kEAAmE,EAIzF,GAFAY,EAAM,KAAK,QACXC,EAAM,KAAK,QACN,UAAU,SAAW,EACzB+B,EAAQ,EACRhB,EAAMf,MACA,CACN,GAAK,CAAClC,EAAWiE,CAAM,EACtB,MAAM,IAAI,UAAWvD,EAAQ,oEAAqEuD,CAAM,CAAE,EAQ3G,GANKA,EAAQ,IACZA,GAAS/B,EACJ+B,EAAQ,IACZA,EAAQ,IAGL,UAAU,SAAW,EACzBhB,EAAMf,MACA,CACN,GAAK,CAAClC,EAAWiD,CAAI,EACpB,MAAM,IAAI,UAAWvC,EAAQ,qEAAsEuC,CAAI,CAAE,EAErGA,EAAM,GACVA,GAAOf,EACFe,EAAM,IACVA,EAAM,IAEIA,EAAMf,IACjBe,EAAMf,EAER,CACD,CAQA,IAPK+B,EAAQhB,EACZiB,EAASjB,EAAMgB,EAEfC,EAAS,EAEV1B,EAAM,IAAI,KAAK,YAAa0B,CAAO,EACnCT,EAASjB,EAAI,QACPJ,EAAI,EAAGA,EAAI8B,EAAQ9B,IACxBqB,EAAQrB,CAAE,EAAIH,EAAKG,EAAE6B,CAAM,EAE5B,OAAOzB,CACR,CAAC,EAwBDjC,EAAaiB,EAAa,UAAW,OAAQ,SAAe2B,EAAWb,EAAU,CAChF,IAAIL,EACAG,EAEJ,GAAK,CAACf,EAAgB,IAAK,EAC1B,MAAM,IAAI,UAAW,kEAAmE,EAEzF,GAAK,CAACtB,EAAYoD,CAAU,EAC3B,MAAM,IAAI,UAAWzC,EAAQ,oEAAqEyC,CAAU,CAAE,EAG/G,IADAlB,EAAM,KAAK,QACLG,EAAI,EAAGA,EAAI,KAAK,QAASA,IAC9B,GAAKe,EAAU,KAAMb,EAASxB,EAAUmB,EAAKG,CAAE,CAAE,EAAGA,EAAG,IAAK,EAC3D,MAAO,GAGT,MAAO,EACR,CAAC,EAqCD7B,EAAaiB,EAAa,UAAW,OAAQ,SAAe2C,EAAa,CACxE,IAAIlC,EAEJ,GAAK,CAACZ,EAAgB,IAAK,EAC1B,MAAM,IAAI,UAAW,kEAAmE,EAGzF,GADAY,EAAM,KAAK,QACN,UAAU,SAAW,EACzB,OAAAA,EAAI,KAAMmC,CAAe,EAClB,KAER,GAAK,CAACrE,EAAYoE,CAAW,EAC5B,MAAM,IAAI,UAAWzD,EAAQ,oEAAqEyD,CAAW,CAAE,EAEhH,OAAAlC,EAAI,KAAMoC,CAAQ,EACX,KAUP,SAASD,EAAgBE,EAAGC,EAAI,CAC/B,IAAIC,EAAI1D,EAAUwD,CAAE,EAChBG,EAAI3D,EAAUyD,CAAE,EAGpB,OAAKnE,EAAOoE,CAAE,GAAKpE,EAAOqE,CAAE,EACpB,EAEHrE,EAAOoE,CAAE,EACN,EAEHpE,EAAOqE,CAAE,GAITD,EAAIC,EACD,GAEHD,EAAIC,EACD,EAED,CACR,CAUA,SAASJ,EAASC,EAAGC,EAAI,CACxB,OAAOJ,EAAYrD,EAAUwD,CAAE,EAAGxD,EAAUyD,CAAE,CAAE,CACjD,CACD,CAAC,EA0CDhE,EAAaiB,EAAa,UAAW,WAAY,SAAmByC,EAAOhB,EAAM,CAChF,IAAIyB,EACAzC,EACAC,EAEJ,GAAK,CAACb,EAAgB,IAAK,EAC1B,MAAM,IAAI,UAAW,kEAAmE,EAIzF,GAFAY,EAAM,KAAK,QACXC,EAAM,KAAK,QACN,UAAU,SAAW,EACzB+B,EAAQ,EACRhB,EAAMf,MACA,CACN,GAAK,CAAClC,EAAWiE,CAAM,EACtB,MAAM,IAAI,UAAWvD,EAAQ,oEAAqEuD,CAAM,CAAE,EAQ3G,GANKA,EAAQ,IACZA,GAAS/B,EACJ+B,EAAQ,IACZA,EAAQ,IAGL,UAAU,SAAW,EACzBhB,EAAMf,MACA,CACN,GAAK,CAAClC,EAAWiD,CAAI,EACpB,MAAM,IAAI,UAAWvC,EAAQ,qEAAsEuC,CAAI,CAAE,EAErGA,EAAM,GACVA,GAAOf,EACFe,EAAM,IACVA,EAAM,IAEIA,EAAMf,IACjBe,EAAMf,EAER,CACD,CACA,OAAK+B,GAAS/B,GACbA,EAAM,EACNwC,EAASzC,EAAI,YACFgC,GAAShB,GACpBf,EAAM,EACNwC,EAASzC,EAAI,WAAegC,EAAM9C,IAElCe,EAAMe,EAAMgB,EACZS,EAASzC,EAAI,WAAegC,EAAM9C,GAE5B,IAAI,KAAK,YAAac,EAAI,OAAQyC,EAAUxC,EAAM,EAAM,EAAIA,CAAI,CACxE,CAAC,EAqBD3B,EAAaiB,EAAa,UAAW,iBAAkB,SAAyBmD,EAASC,EAAU,CAClG,IAAIC,EACAC,EACAtC,EACAP,EACAG,EAEJ,GAAK,CAACf,EAAgB,IAAK,EAC1B,MAAM,IAAI,UAAW,kEAAmE,EAEzF,GAAK,UAAU,SAAW,EACzByD,EAAM,CAAC,UACI5E,EAAUyE,CAAQ,GAAK/E,GAAe+E,CAAQ,EACzDG,EAAMH,MAEN,OAAM,IAAI,UAAWjE,EAAQ,yFAA0FiE,CAAQ,CAAE,EAElI,GAAK,UAAU,OAAS,EACvBE,EAAO,CAAC,UACG1E,EAAUyE,CAAQ,EAC7BC,EAAOD,MAEP,OAAM,IAAI,UAAWlE,EAAQ,qEAAsEkE,CAAQ,CAAE,EAI9G,IAFA3C,EAAM,KAAK,QACXO,EAAM,CAAC,EACDJ,EAAI,EAAGA,EAAI,KAAK,QAASA,IAC9BI,EAAI,KAAM1B,EAAUmB,EAAKG,CAAE,CAAE,CAAE,EAEhC,OAAOI,EAAI,eAAgBsC,EAAKD,CAAK,CACtC,CAAC,EA0BDtE,EAAaiB,EAAa,UAAW,aAAc,UAAsB,CACxE,IAAIiC,EACAjB,EACAN,EACAD,EACAG,EAEJ,GAAK,CAACf,EAAgB,IAAK,EAC1B,MAAM,IAAI,UAAW,kEAAmE,EAMzF,IAJAa,EAAM,KAAK,QACXM,EAAM,IAAI,KAAK,YAAaN,CAAI,EAChCD,EAAM,KAAK,QACXwB,EAASjB,EAAI,QACPJ,EAAI,EAAGA,EAAIF,EAAKE,IACrBqB,EAAQrB,CAAE,EAAIH,EAAKC,EAAME,EAAI,CAAE,EAEhC,OAAOI,CACR,CAAC,EAsCDjC,EAAaiB,EAAa,UAAW,WAAY,SAAmB2C,EAAa,CAChF,IAAI3B,EAEJ,GAAK,CAACnB,EAAgB,IAAK,EAC1B,MAAM,IAAI,UAAW,kEAAmE,EAGzF,OADAmB,EAAM,IAAI,KAAK,YAAa,IAAK,EAC5B,UAAU,SAAW,EAClBA,EAAI,KAAK,EAEVA,EAAI,KAAM2B,CAAW,CAC7B,CAAC,EAiBD5D,EAAaiB,EAAa,UAAW,WAAY,UAAoB,CACpE,IAAIgB,EACAP,EACA,EACJ,GAAK,CAACZ,EAAgB,IAAK,EAC1B,MAAM,IAAI,UAAW,kEAAmE,EAIzF,IAFAY,EAAM,KAAK,QACXO,EAAM,CAAC,EACD,EAAI,EAAG,EAAI,KAAK,QAAS,IAC9BA,EAAI,KAAM1B,EAAUmB,EAAK,CAAE,CAAE,CAAE,EAEhC,OAAOO,EAAI,KAAM,GAAI,CACtB,CAAC,EAyBDjC,EAAaiB,EAAa,UAAW,SAAU,UAAkB,CAChE,IAAIsB,EACAD,EACAX,EACAa,EACAd,EACAG,EAEJ,GAAK,CAACf,EAAgB,IAAK,EAC1B,MAAM,IAAI,UAAW,kEAAmE,EAEzF,OAAAwB,EAAO,KACPZ,EAAM,KAAK,QACXC,EAAM,KAAK,QAGXE,EAAI,GAGJU,EAAO,CAAC,EACRvC,EAAauC,EAAM,OAAQE,CAAK,EAChCzC,EAAauC,EAAM,SAAUG,CAAI,EAE5B5C,GACJE,EAAauC,EAAMzC,EAAiB6C,CAAQ,EAEtCJ,EAQP,SAASE,GAAO,CAEf,OADAZ,GAAK,EACAW,GAAOX,GAAKF,EACT,CACN,KAAQ,EACT,EAEM,CACN,MAASpB,EAAUmB,EAAKG,CAAE,CAAE,EAC5B,KAAQ,EACT,CACD,CASA,SAASa,EAAK3B,EAAQ,CAErB,OADAyB,EAAM,GACD,UAAU,OACP,CACN,MAASzB,EACT,KAAQ,EACT,EAEM,CACN,KAAQ,EACT,CACD,CAQA,SAAS4B,GAAU,CAClB,OAAOL,EAAK,OAAO,CACpB,CACD,CAAC,EAyBDtC,EAAaiB,EAAa,UAAW,OAAQ,SAAmBuD,EAAOzD,EAAQ,CAC9E,IAAIkB,EACAN,EAEJ,GAAK,CAACb,EAAgB,IAAK,EAC1B,MAAM,IAAI,UAAW,kEAAmE,EAEzF,GAAK,CAACrB,EAAW+E,CAAM,EACtB,MAAM,IAAI,UAAWrE,EAAQ,oEAAqEqE,CAAM,CAAE,EAM3G,GAJA7C,EAAM,KAAK,QACN6C,EAAQ,IACZA,GAAS7C,GAEL6C,EAAQ,GAAKA,GAAS7C,EAC1B,MAAM,IAAI,WAAYxB,EAAQ,kEAAmEqE,CAAM,CAAE,EAE1G,GAAK,CAAC9E,EAAUqB,CAAM,EACrB,MAAM,IAAI,UAAWZ,EAAQ,kFAAmFY,CAAM,CAAE,EAEzH,OAAAkB,EAAM,IAAI,KAAK,YAAa,IAAK,EACjCA,EAAKuC,CAAM,EAAIzD,EACRkB,CACR,CAAC,EAKD/C,EAAO,QAAU+B,ICz2EjB,IAAAwD,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,GAAS,OAAO,cAAiB,WAAe,aAAe,OAKnED,EAAO,QAAUC,KC6DjB,IAAIC,GAAyB,QAAS,yCAA0C,EAC5EC,GAAW,IACXC,GAAU,IAKVC,EACCH,GAAuB,EAC3BG,EAAOD,GAEPC,EAAOF,GAMR,OAAO,QAAUE", - "names": ["require_from_array", "__commonJSMin", "exports", "module", "f16", "toWord", "fromArray", "buf", "arr", "len", "require_from_iterator", "__commonJSMin", "exports", "module", "f16", "toWord", "fromIterator", "it", "out", "v", "require_from_iterator_map", "__commonJSMin", "exports", "module", "f16", "toWord", "fromIteratorMap", "it", "clbk", "thisArg", "out", "v", "i", "require_polyfill", "__commonJSMin", "exports", "module", "hasIteratorSymbolSupport", "isNonNegativeInteger", "isStringArray", "isCollection", "isArrayBuffer", "isFunction", "isInteger", "isNumber", "isString", "isObject", "isnan", "ITERATOR_SYMBOL", "setReadOnlyAccessor", "setReadOnly", "setReadWriteAccessor", "floor", "format", "Uint16Array", "f16", "toWord", "fromWord", "gcopy", "fromArray", "fromIterator", "fromIteratorMap", "BYTES_PER_ELEMENT", "HAS_ITERATOR_SYMBOL", "isFloat16Array", "value", "isFloatingPointArrayConstructor", "Float16Array", "getter", "ctx", "idx", "get", "setter", "set", "byteOffset", "nargs", "buf", "len", "arg", "i", "src", "thisArg", "clbk", "out", "tmp", "args", "target", "start", "self", "iter", "FLG", "next", "end", "factory", "predicate", "v", "fcn", "searchElement", "fromIndex", "separator", "outbuf", "reducer", "initialValue", "acc", "N", "j", "sbuf", "flg", "begin", "outlen", "compareFcn", "defaultCompare", "compare", "a", "b", "x", "y", "offset", "locales", "options", "opts", "loc", "index", "require_main", "__commonJSMin", "exports", "module", "ctor", "hasFloat16ArraySupport", "polyfill", "builtin", "ctor"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index e311742..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,1222 +0,0 @@ - -{{alias}}() - A 16-bit half-precision floating-point number array. - - Returns - ------- - out: Float16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Creates a half-precision floating-point number array having a specified - length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: Float16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - - > var len = arr.length - 5 - - -{{alias}}( typedarray ) - Creates a half-precision floating-point number array from a typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate a half-precision floating-point - number array. - - Returns - ------- - out: Float16Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/float64}}( [ 0.5, 0.5, 0.5 ] ) - - > var arr = new {{alias}}( buf ) - - > var len = arr.length - 3 - - -{{alias}}( obj ) - Creates a half-precision floating-point number array from an array-like - object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a half-precision - floating-point number array. - - Returns - ------- - out: Float16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( [ 0.5, 0.5, 0.5 ] ) - - > var len = arr.length - 3 - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a half-precision floating-point number array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - Returns - ------- - out: Float16Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 8 ); - > var arr1 = new {{alias}}( buf ) - - > var len = arr1.length - 4 - > var arr2 = new {{alias}}( buf, 2 ) - - > len = arr2.length - 3 - > var arr3 = new {{alias}}( buf, 2, 2 ) - - > len = arr3.length - 2 - - -{{alias}}.from( src[, clbk[, thisArg]] ) - Creates a new half-precision floating-point number array from an array-like - object or an iterable. - - A callback function is provided two arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - clbk: Function (optional) - Callback to invoke for each source element. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Float16Array - A typed array. - - Examples - -------- - > function clbkFcn( v ) { return v * 2.0 }; - > var arr = {{alias}}.from( [ 1.0, -1.0 ], clbkFcn ) - - > var len = arr.length - 2 - > var v = arr[ 0 ] - 2.0 - > v = arr[ 1 ] - -2.0 - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new half-precision floating-point number array from a variable - number of arguments. - - Parameters - ---------- - element0: number - Array element. - - element1: number (optional) - Array element. - - elementN: ...number (optional) - Array elements. - - Returns - ------- - out: Float16Array - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( 1.0, -1.0 ) - - > var len = arr.length - 2 - > var v = arr[ 0 ] - 1.0 - > v = arr[ 1 ] - -1.0 - - -{{alias}}.BYTES_PER_ELEMENT - The size of each array element in bytes. - - Examples - -------- - > var nbytes = {{alias}}.BYTES_PER_ELEMENT - 2 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > var str = {{alias}}.name - 'Float16Array' - - -{{alias}}.prototype.buffer - Pointer to the underlying data buffer. - - Examples - -------- - > var arr = new {{alias}}( 2 ) - - > var buf = arr.buffer - - - -{{alias}}.prototype.byteLength - Length of the array in bytes. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - - > var nbytes = arr.byteLength - 10 - - -{{alias}}.prototype.byteOffset - Offset (in bytes) of the array from the start of its underlying ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - - > var offset = arr.byteOffset - 0 - > var buf = new {{alias:@stdlib/array/buffer}}( 20 ); - > arr = new {{alias}}( buf, 10 ) - - > offset = arr.byteOffset - 10 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each array element. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - - > arr.BYTES_PER_ELEMENT - 2 - - -{{alias}}.prototype.length - The number of array elements. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - - > var len = arr.length - 5 - - -{{alias}}.prototype.at( i ) - Returns an array element located at integer position (index) `i`, with - support for both nonnegative and negative integer positions. - - If provided an index outside the array index range, the method returns - `undefined`. - - Parameters - ---------- - i: integer - Element index. - - Returns - ------- - out: float|void - An array element. - - Examples - -------- - > var arr = new {{alias}}( [ 10.0, 20.0, 30.0 ] ) - - > var v = arr.at( 0 ) - 10.0 - > v = arr.at( -1 ) - 30.0 - - -{{alias}}.prototype.copyWithin( target, start[, end] ) - Copies a sequence of elements within the array starting at `start` and - ending at `end` (non-inclusive) to the position starting at `target`. - - Parameters - ---------- - target: integer - Target start index position. - - start: integer - Source start index position. - - end: integer (optional) - Source end index position. Default: out.length. - - Returns - ------- - out: Float16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ) - - > arr.copyWithin( 0, 3 ) - - > var v = arr[ 0 ] - 4.0 - > v = arr[ 1 ] - 5.0 - - -{{alias}}.prototype.entries() - Returns an iterator for iterating over array key-value pairs. - - Returns - ------- - iterator: Iterator - Iterator for iterating over array key-value pairs. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var it = arr.entries(); - > var v = it.next().value - [ 0, 1.0 ] - > v = it.next().value - [ 1, 2.0 ] - > v = it.next().value - [ 2, 3.0 ] - > var bool = it.next().done - true - - -{{alias}}.prototype.every( predicate[, thisArg] ) - Returns a boolean indicating whether all elements in the array pass a test. - - A predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether all elements pass the test. - - Examples - -------- - > function predicate( v ) { return ( v > 0.0 ); }; - > var arr = new {{alias}}( [ 1.0, 2.0 ] ) - - > var bool = arr.every( predicate ) - true - - -{{alias}}.prototype.fill( value[, start[, end]] ) - Returns a modified typed array filled with a fill value. - - Parameters - ---------- - value: number - Fill value. - - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Float16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( 3 ) - - > arr.fill( 2.0 ); - > var v = arr[ 0 ] - 2.0 - > v = arr[ 1 ] - 2.0 - > v = arr[ 2 ] - 2.0 - - -{{alias}}.prototype.filter( predicate[, thisArg] ) - Returns a new array containing the elements of an array which pass a test - implemented by a predicate function. - - A predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - The returned array has the same data type as the host array. - - Parameters - ---------- - predicate: Function - Predicate function which filters array elements. If a predicate function - returns a truthy value, an array element is included in the output - array; otherwise, an array element is not included in the output array. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - out: Float16Array - A new typed array. - - Examples - -------- - > function predicate( v ) { return ( v > 1.0 ); }; - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var out = arr.filter( predicate ) - - > var len = out.length - 2 - > var v = out[ 0 ] - 2.0 - > v = out[ 1 ] - 3.0 - - -{{alias}}.prototype.find( predicate[, thisArg] ) - Returns the first element in an array for which a predicate function - returns a truthy value. - - A predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - out: number|void - Array element or `undefined`. - - Examples - -------- - > function predicate( v ) { return ( v > 1.0 ); }; - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var v = arr.find( predicate ) - 2.0 - - -{{alias}}.prototype.findIndex( predicate[, thisArg] ) - Returns the index of the first element in an array for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - out: integer - Array index or `-1`. - - Examples - -------- - > function predicate( v ) { return ( v > 2.0 ); }; - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var idx = arr.findIndex( predicate ) - 2 - - -{{alias}}.prototype.findLast( predicate[, thisArg] ) - Returns the last element in an array for which a predicate function returns - a truthy value. - - A predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - out: number|void - Array element or `undefined`. - - Examples - -------- - > function predicate( v ) { return ( v > 1.0 ); }; - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var v = arr.findLast( predicate ) - 3.0 - - -{{alias}}.prototype.findLastIndex( predicate[, thisArg] ) - Returns the index of the last element in an array for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - out: integer - Array index or `-1`. - - Examples - -------- - > function predicate( v ) { return ( v > 1.0 ); }; - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var idx = arr.findLastIndex( predicate ) - 2 - - -{{alias}}.prototype.forEach( clbk[, thisArg] ) - Invokes a function once for each array element. - - A callback function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - Parameters - ---------- - clbk: Function - Function to invoke for each array element. - - thisArg: Any (optional) - Execution context. - - Examples - -------- - > var str = '%'; - > function clbk( v ) { str += v.toString() + '%'; }; - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > arr.forEach( clbk ); - > str - '%1%2%3%' - - -{{alias}}.prototype.includes( searchElement[, fromIndex] ) - Returns a boolean indicating whether an array includes a provided value. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index at which to start the search. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - bool: boolean - Boolean indicating whether an array includes a search element. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var bool = arr.includes( 3.0 ) - true - > bool = arr.includes( 3.0, 3 ) - false - - -{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) - Returns the first index at which a given element can be found. - - If method does not find a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index at which to start the search. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - out: integer - Array index or `-1`. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var idx = arr.indexOf( 2.0 ) - 1 - > idx = arr.indexOf( 2.0, 2 ) - -1 - - -{{alias}}.prototype.join( [separator] ) - Returns a new string by concatenating all array elements separated by a - separator string. - - Parameters - ---------- - separator: string (optional) - Separator string. Default: ','. - - Returns - ------- - out: string - Array serialized as a string. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var str = arr.join() - '1,2,3' - > str = arr.join( '|' ) - '1|2|3' - - -{{alias}}.prototype.keys() - Returns an iterator for iterating over each index key in a typed array. - - Returns - ------- - iterator: Iterator - Iterator for iterating over array index keys. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0 ] ) - - > var it = arr.keys(); - > var v = it.next().value - 0 - > v = it.next().value - 1 - > v = it.next().done - true - - -{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) - Returns the last index at which a given element can be found. - - If method does not find a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index at which to start the search. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: out.length-1. - - Returns - ------- - out: integer - Array index or `-1`. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0, 1.0 ] ) - - > var idx = arr.lastIndexOf( 1.0 ) - 3 - > idx = arr.lastIndexOf( 1.0, 2 ) - 0 - - -{{alias}}.prototype.map( clbk[, thisArg] ) - Returns a new array with each element being the result of a provided - callback function. - - A callback function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - The returned array has the same data type as the host array. - - Parameters - ---------- - clbk: Function - Function which maps array elements to elements in the new array. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - out: Float16Array - A new typed array. - - Examples - -------- - > function clbk( v ) { return v * 2.0; }; - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var out = arr.map( clbk ) - - > var v = out[ 0 ] - 2.0 - > v = out[ 1 ] - 4.0 - > v = out[ 2 ] - 6.0 - - -{{alias}}.prototype.reduce( reducerFn[, initialValue] ) - Applies a provided function to each element of the array, in order, passing - in the return value from the calculation on the preceding element and - returning the accumulated result upon completion. - - A reducer function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the first array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the first array element as the first argument and the second array - element as the second argument. - - Parameters - ---------- - reducerFn: Function - Function to apply to each array element. - - initialValue: any (optional) - Initial accumulation value. - - Returns - ------- - out: any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > function reducerFn( acc, v ) { return acc + v; }; - > var v = arr.reduce( reducerFn, 0.0 ) - 6.0 - - -{{alias}}.prototype.reduceRight( reducerFn[, initialValue] ) - Applies a provided function to each element of the array, in reverse order, - passing in the return value from the calculation on the preceding element - and returning the accumulated result upon completion. - - A reducer function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the last array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the last array element as the first argument and the second-to-last - array element as the second argument. - - Parameters - ---------- - reducerFn: Function - Function to apply to each array element. - - initialValue: any (optional) - Initial accumulation value. - - Returns - ------- - out: any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > function reducerFn( acc, v ) { return acc + v; }; - > var v = arr.reduceRight( reducerFn, 0.0 ) - 6.0 - - -{{alias}}.prototype.reverse() - Reverses the array *in-place*. - - This method mutates the array on which the method is invoked. - - Returns - ------- - out: Float16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > arr.reverse(); - > var v = arr[ 0 ] - 3.0 - > v = arr[ 1 ] - 2.0 - > v = arr[ 2 ] - 1.0 - - -{{alias}}.prototype.set( arr[, offset] ) - Sets one or more array elements. - - If provided a single argument, the method sets array elements starting at - position (index) `i = 0`. To set elements starting elsewhere in the array, - provide an offset argument. - - Parameters - ---------- - arr: ArrayLike - Source array containing array values to set. - - offset: integer (optional) - Array index at which to start writing values. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > arr.set( [ 4.0, 5.0 ], 1 ); - > var v = arr[ 0 ] - 1.0 - > v = arr[ 1 ] - 4.0 - > v = arr[ 2 ] - 5.0 - - -{{alias}}.prototype.slice( [start[, end]] ) - Copies a portion of a typed array to a new typed array. - - Parameters - ---------- - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Float16Array - New typed array. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var out = arr.slice( 1 ) - - > var len = out.length - 2 - > var v = out[ 0 ] - 2.0 - > v = out[ 1 ] - 3.0 - - -{{alias}}.prototype.some( predicate[, thisArg] ) - Returns a boolean indicating whether at least one element passes a test. - - A predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether at least one element passes the test. - - Examples - -------- - > function predicate( v ) { return ( v > 2.0 ); }; - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var bool = arr.some( predicate ) - true - - -{{alias}}.prototype.sort( [compareFunction] ) - Sorts an array in-place. - - A comparison function determines the order of the array elements. The - function is provided two arguments: - - - a: first element for comparison. - - b: second element for comparison. - - The function should return a value less than zero if `a` comes before `b`, - a value greater than zero if `a` comes after `b`, and zero if `a` and `b` - are equivalent. - - Parameters - ---------- - compareFunction: Function (optional) - Comparison function. - - Returns - ------- - out: Float16Array - Modified array. - - Examples - -------- - > function compare( a, b ) { return a - b; }; - > var arr = new {{alias}}( [ 2.0, 3.0, 1.0 ] ) - - > arr.sort( compare ); - > var v = arr[ 0 ] - 1.0 - > v = arr[ 1 ] - 2.0 - > v = arr[ 2 ] - 3.0 - - -{{alias}}.prototype.subarray( [begin[, end]] ) - Creates a new typed array view over the same underlying `ArrayBuffer` and - with the same underlying data type as the host array. - - Parameters - ---------- - begin: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Float16Array - New typed array view. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ) - - > var out = arr.subarray( 1, 3 ) - - > var len = out.length - 2 - > var v = out[ 0 ] - 2.0 - > v = out[ 1 ] - 3.0 - - -{{alias}}.prototype.toLocaleString( [locales[, options]] ) - Serializes an array as a locale-specific string. - - Parameters - ---------- - locales: string|Array (optional) - Locale identifier(s). - - options: Object (optional) - An object containing serialization options. - - Returns - ------- - str: string - Local-specific string. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var str = arr.toLocaleString() - '1,2,3' - - -{{alias}}.prototype.toReversed() - Returns a new typed array containing the elements in reversed order. - - Returns - ------- - out: Float16Array - New typed array. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var out = arr.toReversed() - - > var v = out[ 0 ] - 3.0 - > v = out[ 1 ] - 2.0 - > v = out[ 2 ] - 1.0 - - -{{alias}}.prototype.toSorted( [compareFcn] ) - Returns a new typed array containing the elements in sorted order. - - A comparison function determines the order of the array elements. The - function is provided two arguments: - - - a: first element for comparison. - - b: second element for comparison. - - The function should return a value less than zero if `a` comes before `b`, - a value greater than zero if `a` comes after `b`, and zero if `a` and `b` - are equivalent. - - Parameters - ---------- - compareFcn: Function (optional) - Comparison function. - - Returns - ------- - out: Float16Array - New typed array. - - Examples - -------- - > function compare( a, b ) { return a - b; }; - > var arr = new {{alias}}( [ 2.0, 3.0, 1.0 ] ) - - > var out = arr.toSorted( compare ); - > var v = out[ 0 ] - 1.0 - > v = out[ 1 ] - 2.0 - > v = out[ 2 ] - 3.0 - - -{{alias}}.prototype.toString() - Serializes an array as a string. - - Returns - ------- - str: string - String serialization of the array. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var str = arr.toString() - '1,2,3' - - -{{alias}}.prototype.values() - Returns an iterator for iterating over each value in a typed array. - - Returns - ------- - iterator: Iterator - Iterator for iterating over array values. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0 ] ) - - > var it = arr.values(); - > var v = it.next().value - 1.0 - > v = it.next().value - 2.0 - > var bool = it.next().done - true - - -{{alias}}.prototype.with( index, value ) - Returns a new typed array with the element at a provided index replaced with - a provided value. - - Parameters - ---------- - index: integer - Element index. - - value: number - Element value. - - Returns - ------- - out: Float16Array - New typed array. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var out = arr.with( 1, 4.0 ) - - > var v = out[ 1 ] - 4.0 - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 033057e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,129 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2026 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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ArrayBuffer = require( '@stdlib/array-buffer' ); -import Float16Array = require( './index' ); - -/** -* Callback function. -* -* @param v - value -* @returns input value -*/ -function clbk( v: number ): number { - return v; -} - - -// TESTS // - -// The function returns a half-precision floating-point number array... -{ - new Float16Array(); // $ExpectType Float16Array - new Float16Array( 2 ); // $ExpectType Float16Array - new Float16Array( [ 1.0, -1.0 ] ); // $ExpectType Float16Array - - const buf = new ArrayBuffer( 16 ); - new Float16Array( buf ); // $ExpectType Float16Array - new Float16Array( buf, 8 ); // $ExpectType Float16Array - new Float16Array( buf, 8, 2 ); // $ExpectType Float16Array -} - -// The compiler throws an error if the function is provided a first argument that is not a number, typed array, array-like object, or array buffer... -{ - new Float16Array( true ); // $ExpectError - new Float16Array( false ); // $ExpectError - new Float16Array( null ); // $ExpectError - new Float16Array( 'abc' ); // $ExpectError - new Float16Array( {} ); // $ExpectError - new Float16Array( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument that is not a number... -{ - const buf = new ArrayBuffer( 16 ); - new Float16Array( buf, true ); // $ExpectError - new Float16Array( buf, false ); // $ExpectError - new Float16Array( buf, null ); // $ExpectError - new Float16Array( buf, 'abc' ); // $ExpectError - new Float16Array( buf, {} ); // $ExpectError - new Float16Array( buf, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument that is not a number... -{ - const buf = new ArrayBuffer( 16 ); - new Float16Array( buf, 8, true ); // $ExpectError - new Float16Array( buf, 8, false ); // $ExpectError - new Float16Array( buf, 8, null ); // $ExpectError - new Float16Array( buf, 8, 'abc' ); // $ExpectError - new Float16Array( buf, 8, {} ); // $ExpectError - new Float16Array( buf, 8, ( x: number ): number => x ); // $ExpectError -} - -// The `from` method returns a half-precision floating-point number array... -{ - Float16Array.from( [ 1.0, 1.0 ] ); // $ExpectType Float16Array - Float16Array.from( [ 1.0, 1.0 ], ( x: number ): number => x * x ); // $ExpectType Float16Array - Float16Array.from( [ 1.0 ], clbk, {} ); // $ExpectType Float16Array -} - -// The compiler throws an error if the `from` method is provided a first argument which is not array-like or iterable... -{ - Float16Array.from( true ); // $ExpectError - Float16Array.from( false ); // $ExpectError - Float16Array.from( 123 ); // $ExpectError - Float16Array.from( null ); // $ExpectError - Float16Array.from( {} ); // $ExpectError - - Float16Array.from( true, clbk ); // $ExpectError - Float16Array.from( false, clbk ); // $ExpectError - Float16Array.from( 123, clbk ); // $ExpectError - Float16Array.from( null, clbk ); // $ExpectError - Float16Array.from( {}, clbk ); // $ExpectError - - Float16Array.from( true, clbk, {} ); // $ExpectError - Float16Array.from( false, clbk, {} ); // $ExpectError - Float16Array.from( 123, clbk, {} ); // $ExpectError - Float16Array.from( null, clbk, {} ); // $ExpectError - Float16Array.from( {}, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the `from` method is provided a second argument which is not a function with a supported signature... -{ - Float16Array.from( [ 1.0, 1.0 ], true ); // $ExpectError - Float16Array.from( [ 1.0, 1.0 ], false ); // $ExpectError - Float16Array.from( [ 1.0, 1.0 ], 123 ); // $ExpectError - Float16Array.from( [ 1.0, 1.0 ], null ); // $ExpectError - Float16Array.from( [ 1.0, 1.0 ], {} ); // $ExpectError -} - -// The `of` method returns a half-precision floating-point number array... -{ - Float16Array.of( 1.0, 1.0, 1.0, 1.0 ); // $ExpectType Float16Array -} - -// The compiler throws an error if the `of` method is provided arguments that are not numbers... -{ - Float16Array.of( 'abc', 'def' ); // $ExpectError - Float16Array.of( true, false ); // $ExpectError - Float16Array.of( {}, [] ); // $ExpectError - Float16Array.of( null, null ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a5c84ca..0000000 --- a/examples/index.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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'; - -var Uint16Array = require( '@stdlib/array-uint16' ); -var logEach = require( '@stdlib/console-log-each' ); -var Float16Array = require( './../lib' ); - -// Create a half-precision floating-point number array by specifying a length: -var out = new Float16Array( 3 ); -logEach( '%s', out ); - -// Create a half-precision floating-point number array from an array of numbers: -var arr = [ 1.05, 2.05, 3.05 ]; -out = new Float16Array( arr ); -logEach( '%s', out ); - -// Create a half-precision floating-point number array from an array buffer: -arr = new Uint16Array( [ 1000, 2000, 3000, 4000 ] ); -out = new Float16Array( arr.buffer ); -logEach( '%s', out ); - -// Create a half-precision floating-point number array from an array buffer view: -arr = new Uint16Array( [ 1000, 2000, 3000, 4000 ] ); -out = new Float16Array( arr.buffer, 2, 2 ); -logEach( '%s', out ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 001159c..ed52b06 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { Iterator as Iter, IterableIterator, TypedIterator } from '@stdlib/types/iter'; import { ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..16ac68e --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-float16array-support@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.3-esm/index.mjs";import{isPrimitive as n}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.3-esm/index.mjs";import{primitives as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string-array@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.3-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.3-esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.3-esm/index.mjs";import{isPrimitive as h}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.3-esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.3-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-assert-is-nan@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.4-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.3-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@v0.2.4-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint16@v0.2.3-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-float16@v0.1.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float16-base-to-word@v0.1.1-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float16-base-from-word@v0.2.1-esm/index.mjs";import T from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-base-gcopy@v0.2.3-esm/index.mjs";function _(t){var r,n;for(r=[];!(n=t.next()).done;)r.push(b(m(n.value)));return r}var j=g.BYTES_PER_ELEMENT,x=r();function L(t){return"object"==typeof t&&null!==t&&"Float16Array"===t.constructor.name&&t.BYTES_PER_ELEMENT===j}function R(t){return t===A}function O(t,r){return function(){return t._get(r)}}function S(t,r){return function(n){t.set([n],r)}}function A(){var t,r,i,h,l,u;if(r=arguments.length,!(this instanceof A))return 0===r?new A:1===r?new A(arguments[0]):2===r?new A(arguments[0],arguments[1]):new A(arguments[0],arguments[1],arguments[2]);if(0===r)i=new g(0);else if(1===r)if(n(l=arguments[0]))i=new g(l);else if(e(l))L(l)?(i=new g(l.length),T.ndarray(l.length,new g(l.buffer,l.byteOffset,l.length),1,0,i,1,0)):i=function(t,r){var n,i;for(n=r.length,i=0;ii.byteLength-t)throw new RangeError(d("null2G",h*j));i=new g(i,t,h)}}for(y(this,"_buffer",i),y(this,"_length",i.length),u=0;u1){if(!s(i=arguments[1]))throw new TypeError(d("null2H",i));n>2&&(r=arguments[2])}if(e(t)){if(i){for(f=(o=new this(l=t.length))._buffer,u=0;u=this._length))return E(this._buffer[t])})),w(A.prototype,"buffer",(function(){return this._buffer.buffer})),w(A.prototype,"byteLength",(function(){return this._buffer.byteLength})),w(A.prototype,"byteOffset",(function(){return this._buffer.byteOffset})),y(A.prototype,"BYTES_PER_ELEMENT",A.BYTES_PER_ELEMENT),y(A.prototype,"copyWithin",(function(t,r){if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");return 2===arguments.length?this._buffer.copyWithin(t,r):this._buffer.copyWithin(t,r,arguments[2]),this})),y(A.prototype,"entries",(function(){var t,r,n,i,e,o;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");return t=this,i=this._buffer,n=this._length,o=-1,y(r={},"next",(function(){if(o+=1,e||o>=n)return{done:!0};return{value:[o,E(i[o])],done:!1}})),y(r,"return",(function(t){if(e=!0,arguments.length)return{value:t,done:!0};return{done:!0}})),p&&y(r,p,(function(){return t.entries()})),r})),y(A.prototype,"every",(function(t,r){var n,i;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!s(t))throw new TypeError(d("null3c",t));for(n=this._buffer,i=0;i1){if(!f(r))throw new TypeError(d("null7f",r));if(r<0&&(r+=e)<0&&(r=0),arguments.length>2){if(!f(n))throw new TypeError(d("null2z",n));n<0&&(n+=e)<0&&(n=0),n>e&&(n=e)}else n=e}else r=0,n=e;for(s=b(t),o=r;o=0;e--)if(i=E(n[e]),t.call(r,i,e,this))return i})),y(A.prototype,"findLastIndex",(function(t,r){var n,i,e;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!s(t))throw new TypeError(d("null3c",t));for(n=this._buffer,e=this._length-1;e>=0;e--)if(i=E(n[e]),t.call(r,i,e,this))return e;return-1})),y(A.prototype,"forEach",(function(t,r){var n,i;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!s(t))throw new TypeError(d("null3c",t));for(n=this._buffer,i=0;i=this._length))return E(this._buffer[t])})),y(A.prototype,"includes",(function(t,r){var n,i,e;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!h(t))throw new TypeError(d("null49",t));if(arguments.length>1){if(!f(r))throw new TypeError(d("null7f",r));r<0&&(r+=this._length)<0&&(r=0)}else r=0;for(n=this._buffer,e=b(t),i=r;i1){if(!f(r))throw new TypeError(d("null7f",r));r<0&&(r+=this._length)<0&&(r=0)}else r=0;for(n=this._buffer,e=b(t),i=r;i0){if(!l(t))throw new TypeError(d("null3F",t))}else t=",";for(r=this._buffer,n=[],i=0;i=n)return{done:!0};return{value:e,done:!1}})),y(r,"return",(function(t){if(i=!0,arguments.length)return{value:t,done:!0};return{done:!0}})),p&&y(r,p,(function(){return t.keys()})),r})),y(A.prototype,"lastIndexOf",(function(t,r){var n,i,e;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!h(t))throw new TypeError(d("null49",t));if(arguments.length>1){if(!f(r))throw new TypeError(d("null7f",r));r>=this._length?r=this._length-1:r<0&&(r+=this._length)}else r=this._length-1;for(n=this._buffer,e=b(t),i=r;i>=0;i--)if(e===n[i])return i;return-1})),w(A.prototype,"length",(function(){return this._length})),y(A.prototype,"map",(function(t,r){var n,i,e,o;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!s(t))throw new TypeError(d("null3c"),t);for(e=this._buffer,n=(i=new this.constructor(this._length))._buffer,o=0;o1)e=r,o=0;else{if(0===i)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");e=E(n[0]),o=1}for(;o1)e=r,o=i-1;else{if(0===i)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");e=E(n[i-1]),o=i-2}for(;o>=0;o--)e=t(e,E(n[o]),o,this);return e})),y(A.prototype,"reverse",(function(){var t,r,n,i,e,o;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");for(t=this._buffer,n=this._length,i=v(n/2),e=0;e1){if(!n(i=arguments[1]))throw new TypeError(d("null2L",i))}else i=0;if(i+(h=t.length)>this._length)throw new RangeError(d("null03"));if(L(t)?(r=t._buffer,f=!0):(r=t,f=!1),a=o.byteOffset+i*j,r.buffer===o.buffer&&r.byteOffseta){for(s=new g(r.length),l=0;ls&&(r=s)}}for(n=ti)return 1;return 0})),this;if(!s(t))throw new TypeError(d("null3c",t));return r.sort((function(r,n){return t(E(r),E(n))})),this})),y(A.prototype,"subarray",(function(t,r){var n,i,e;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(i=this._buffer,e=this._length,0===arguments.length)t=0,r=e;else{if(!f(t))throw new TypeError(d("null7e",t));if(t<0&&(t+=e)<0&&(t=0),1===arguments.length)r=e;else{if(!f(r))throw new TypeError(d("null7f",r));r<0?(r+=e)<0&&(r=0):r>e&&(r=e)}}return t>=e?(e=0,n=i.byteLength):t>=r?(e=0,n=i.byteOffset+t*j):(e=r-t,n=i.byteOffset+t*j),new this.constructor(i.buffer,n,e<0?0:e)})),y(A.prototype,"toLocaleString",(function(t,r){var n,e,o,s,f;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(0===arguments.length)e=[];else{if(!l(t)&&!i(t))throw new TypeError(d("invalid argument. First argument must be a string or an array of strings. Value: `%s`.",t));e=t}if(arguments.length<2)n={};else{if(!a(r))throw new TypeError(d("null2V",r));n=r}for(s=this._buffer,o=[],f=0;f=n)return{done:!0};return{value:E(e[o]),done:!1}})),y(t,"return",(function(t){if(i=!0,arguments.length)return{value:t,done:!0};return{done:!0}})),p&&y(t,p,(function(){return r.values()})),t})),y(A.prototype,"with",(function(t,r){var n,i;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!f(t))throw new TypeError(d("null7e",t));if(i=this._length,t<0&&(t+=i),t<0||t>=i)throw new RangeError(d("nullFP",t));if(!h(r))throw new TypeError(d("invalid argument. Second argument must be a floating-point number. Value: `%s`.",r));return(n=new this.constructor(this))[t]=r,n}));var P="function"==typeof Float16Array?Float16Array:void 0,F=t()?P:A;export{F as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..d0d8a32 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/polyfill/from_iterator.js","../lib/polyfill/index.js","../lib/polyfill/from_array.js","../lib/polyfill/from_iterator_map.js","../lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport f16 from '@stdlib/number-float64-base-to-float16';\nimport toWord from '@stdlib/number-float16-base-to-word';\n\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @returns {Array} output array\n*/\nfunction fromIterator( it ) {\n\tvar out;\n\tvar v;\n\n\tout = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tout.push( toWord( f16( v.value ) ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIterator;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this, stdlib/jsdoc-typedef-typos, max-lines */\n\n'use strict';\n\n// MODULES //\n\nimport hasIteratorSymbolSupport from '@stdlib/assert-has-iterator-symbol-support';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport { primitives as isStringArray } from '@stdlib/assert-is-string-array';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isFunction from '@stdlib/assert-is-function';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isObject from '@stdlib/assert-is-object';\nimport isnan from '@stdlib/math-base-assert-is-nan';\nimport ITERATOR_SYMBOL from '@stdlib/symbol-iterator';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadWriteAccessor from '@stdlib/utils-define-read-write-accessor';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport Uint16Array from '@stdlib/array-uint16';\nimport f16 from '@stdlib/number-float64-base-to-float16';\nimport toWord from '@stdlib/number-float16-base-to-word';\nimport fromWord from '@stdlib/number-float16-base-from-word';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport fromArray from './from_array.js';\nimport fromIterator from './from_iterator.js';\nimport fromIteratorMap from './from_iterator_map.js';\n\n\n// VARIABLES //\n\nvar BYTES_PER_ELEMENT = Uint16Array.BYTES_PER_ELEMENT;\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\n\n\n// FUNCTIONS //\n\n/**\n* Returns a boolean indicating if a value is a `Float16Array`.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `Float16Array`\n*/\nfunction isFloat16Array( value ) {\n\treturn (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\tvalue.constructor.name === 'Float16Array' &&\n\t\tvalue.BYTES_PER_ELEMENT === BYTES_PER_ELEMENT\n\t);\n}\n\n/**\n* Returns a boolean indicating if a value is a floating-point typed array constructor.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a floating-point typed array constructor\n*/\nfunction isFloatingPointArrayConstructor( value ) { // eslint-disable-line id-length\n\treturn ( value === Float16Array );\n}\n\n/**\n* Returns a getter.\n*\n* @private\n* @param {Float16Array} ctx - typed array instance\n* @param {NonNegativeInteger} idx - element index\n* @returns {Function} getter\n*/\nfunction getter( ctx, idx ) {\n\treturn get;\n\n\t/**\n\t* Returns an array element.\n\t*\n\t* @private\n\t* @returns {(number|void)} array element\n\t*/\n\tfunction get() {\n\t\treturn ctx._get( idx ); // eslint-disable-line no-underscore-dangle\n\t}\n}\n\n/**\n* Returns a setter.\n*\n* @private\n* @param {Float16Array} ctx - typed array instance\n* @param {NonNegativeInteger} idx - element index\n* @returns {Function} setter\n*/\nfunction setter( ctx, idx ) {\n\treturn set;\n\n\t/**\n\t* Sets an array element.\n\t*\n\t* @private\n\t* @param {number} value - value to set\n\t*/\n\tfunction set( value ) {\n\t\tctx.set( [ value ], idx );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* 16-bit floating-point number array constructor.\n*\n* @constructor\n* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable\n* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n* @param {NonNegativeInteger} [length] - view length\n* @throws {RangeError} ArrayBuffer byte length must be a multiple of `2`\n* @throws {TypeError} if provided only a single argument, must provide a valid argument\n* @throws {TypeError} byte offset must be a nonnegative integer\n* @throws {RangeError} byte offset must be a multiple of `2`\n* @throws {TypeError} view length must be a positive multiple of `2`\n* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n* @returns {Float16Array} half-precision floating-point number array\n*\n* @example\n* var arr = new Float16Array();\n* // returns \n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var arr = new Float16Array( 5 );\n* // returns \n*\n* var len = arr.length;\n* // returns 5\n*\n* @example\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 5\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float16Array( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 8\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float16Array( buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 4\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Float16Array( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nfunction Float16Array() {\n\tvar byteOffset;\n\tvar nargs;\n\tvar buf;\n\tvar len;\n\tvar arg;\n\tvar i;\n\n\tnargs = arguments.length;\n\tif ( !(this instanceof Float16Array) ) {\n\t\tif ( nargs === 0 ) {\n\t\t\treturn new Float16Array();\n\t\t}\n\t\tif ( nargs === 1 ) {\n\t\t\treturn new Float16Array( arguments[0] );\n\t\t}\n\t\tif ( nargs === 2 ) {\n\t\t\treturn new Float16Array( arguments[0], arguments[1] );\n\t\t}\n\t\treturn new Float16Array( arguments[0], arguments[1], arguments[2] );\n\t}\n\t// Create the underlying data buffer...\n\tif ( nargs === 0 ) {\n\t\tbuf = new Uint16Array( 0 ); // backward-compatibility\n\t} else if ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\t\tif ( isNonNegativeInteger( arg ) ) {\n\t\t\tbuf = new Uint16Array( arg );\n\t\t} else if ( isCollection( arg ) ) {\n\t\t\tif ( isFloat16Array( arg ) ) {\n\t\t\t\tbuf = new Uint16Array( arg.length );\n\t\t\t\tgcopy.ndarray( arg.length, new Uint16Array( arg.buffer, arg.byteOffset, arg.length ), 1, 0, buf, 1, 0 ); // eslint-disable-line max-len\n\t\t\t} else {\n\t\t\t\tbuf = fromArray( new Uint16Array( arg.length ), arg );\n\t\t\t}\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tif ( !isInteger( arg.byteLength/BYTES_PER_ELEMENT ) ) {\n\t\t\t\tthrow new RangeError( format( 'nullE9', BYTES_PER_ELEMENT, arg.byteLength ) );\n\t\t\t}\n\t\t\tbuf = new Uint16Array( arg );\n\t\t} else if ( isObject( arg ) ) {\n\t\t\tif ( HAS_ITERATOR_SYMBOL === false ) {\n\t\t\t\tthrow new TypeError( format( 'null29', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2A', arg ) );\n\t\t\t}\n\t\t\tbuf = arg[ ITERATOR_SYMBOL ]();\n\t\t\tif ( !isFunction( buf.next ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2A', arg ) );\n\t\t\t}\n\t\t\tbuf = new Uint16Array( fromIterator( buf ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( 'null2A', arg ) );\n\t\t}\n\t} else {\n\t\tbuf = arguments[ 0 ];\n\t\tif ( !isArrayBuffer( buf ) ) {\n\t\t\tthrow new TypeError( format( 'null2B', buf ) );\n\t\t}\n\t\tbyteOffset = arguments[ 1 ];\n\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\tthrow new TypeError( format( 'null2C', byteOffset ) );\n\t\t}\n\t\tif ( !isInteger( byteOffset/BYTES_PER_ELEMENT ) ) {\n\t\t\tthrow new RangeError( format( 'nullEA', BYTES_PER_ELEMENT, byteOffset ) );\n\t\t}\n\t\tif ( nargs === 2 ) {\n\t\t\tlen = buf.byteLength - byteOffset;\n\t\t\tif ( !isInteger( len/BYTES_PER_ELEMENT ) ) {\n\t\t\t\tthrow new RangeError( format( 'null2E', BYTES_PER_ELEMENT, len ) );\n\t\t\t}\n\t\t\tbuf = new Uint16Array( buf, byteOffset );\n\t\t} else {\n\t\t\tlen = arguments[ 2 ];\n\t\t\tif ( !isNonNegativeInteger( len ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2F', len ) );\n\t\t\t}\n\t\t\tif ( (len*BYTES_PER_ELEMENT) > (buf.byteLength-byteOffset) ) {\n\t\t\t\tthrow new RangeError( format( 'null2G', len*BYTES_PER_ELEMENT ) );\n\t\t\t}\n\t\t\tbuf = new Uint16Array( buf, byteOffset, len );\n\t\t}\n\t}\n\tsetReadOnly( this, '_buffer', buf );\n\tsetReadOnly( this, '_length', buf.length );\n\tfor ( i = 0; i < buf.length; i++ ) {\n\t\tsetReadWriteAccessor( this, i, getter( this, i ), setter( this, i ) );\n\t}\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each array element.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Float16Array\n* @readonly\n* @type {PositiveInteger}\n* @default 2\n*\n* @example\n* var nbytes = Float16Array.BYTES_PER_ELEMENT;\n* // returns 2\n*/\nsetReadOnly( Float16Array, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT );\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof Float16Array\n* @readonly\n* @type {string}\n* @default 'Float16Array'\n*\n* @example\n* var str = Float16Array.name;\n* // returns 'Float16Array'\n*/\nsetReadOnly( Float16Array, 'name', 'Float16Array' );\n\n/**\n* Creates a new 16-bit floating-point number array from an array-like object or an iterable.\n*\n* @name from\n* @memberof Float16Array\n* @type {Function}\n* @param {(Collection|Iterable)} src - array-like object or iterable\n* @param {Function} [clbk] - callback to invoke for each source element\n* @param {*} [thisArg] - context\n* @throws {TypeError} `this` context must be a constructor\n* @throws {TypeError} `this` must be a floating-point array\n* @throws {TypeError} first argument must be an array-like object or an iterable\n* @throws {TypeError} second argument must be a function\n* @returns {Float16Array} half-precision floating-point number array\n*\n* @example\n* var arr = Float16Array.from( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* function clbk( v ) {\n* return v * 2.0;\n* }\n*\n* var arr = Float16Array.from( [ 1.0, 2.0 ], clbk );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nsetReadOnly( Float16Array, 'from', function from( src ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar clbk;\n\tvar out;\n\tvar buf;\n\tvar tmp;\n\tvar len;\n\tvar i;\n\tif ( !isFunction( this ) ) {\n\t\tthrow new TypeError( format('null01') );\n\t}\n\tif ( !isFloatingPointArrayConstructor( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point array.' );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs > 1 ) {\n\t\tclbk = arguments[ 1 ];\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'null2H', clbk ) );\n\t\t}\n\t\tif ( nargs > 2 ) {\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( isCollection( src ) ) {\n\t\tif ( clbk ) {\n\t\t\tlen = src.length;\n\t\t\tout = new this( len );\n\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tbuf[ i ] = toWord( f16( clbk.call( thisArg, src[ i ], i ) ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\treturn new this( src );\n\t}\n\tif ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) { // eslint-disable-line max-len\n\t\tbuf = src[ ITERATOR_SYMBOL ]();\n\t\tif ( !isFunction( buf.next ) ) {\n\t\t\tthrow new TypeError( format( 'null2J', src ) );\n\t\t}\n\t\tif ( clbk ) {\n\t\t\ttmp = fromIteratorMap( buf, clbk, thisArg );\n\t\t} else {\n\t\t\ttmp = fromIterator( buf );\n\t\t}\n\t\tif ( tmp instanceof Error ) {\n\t\t\tthrow tmp;\n\t\t}\n\t\tlen = tmp.length;\n\t\tout = new this( len );\n\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tbuf[ i ] = tmp[ i ];\n\t\t}\n\t\treturn out;\n\t}\n\tthrow new TypeError( format( 'null2J', src ) );\n});\n\n/**\n* Creates a new 16-bit floating-point number array from a variable number of arguments.\n*\n* @name of\n* @memberof Float16Array\n* @type {Function}\n* @param {...*} element - array elements\n* @throws {TypeError} `this` context must be a constructor\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Float16Array} half-precision floating-point number array\n*\n* @example\n* var arr = Float16Array.of( 1.0, 1.0, 1.0, 1.0 );\n* // returns \n*\n* var x = arr[ 0 ];\n* // returns 1.0\n*\n* var len = arr.length;\n* // returns 4\n*/\nsetReadOnly( Float16Array, 'of', function of() {\n\tvar args;\n\tvar i;\n\tif ( !isFunction( this ) ) {\n\t\tthrow new TypeError( format('null01') );\n\t}\n\tif ( !isFloatingPointArrayConstructor( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\targs = [];\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\targs.push( arguments[ i ] );\n\t}\n\treturn new this( args );\n});\n\n/**\n* Returns an array element with support for both nonnegative and negative integer indices.\n*\n* @name at\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} must provide an integer\n* @returns {(number|void)} array element\n*\n* @example\n* var arr = new Float16Array( [ 10.0, 20.0, 30.0 ] );\n*\n* var v = arr.at( 0 );\n* // returns 10.0\n*\n* v = arr.at( -1 );\n* // returns 30.0\n*\n* v = arr.at( 100 );\n* // returns undefined\n*/\nsetReadOnly( Float16Array.prototype, 'at', function at( idx ) {\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'null8A', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += this._length;\n\t}\n\tif ( idx < 0 || idx >= this._length ) {\n\t\treturn;\n\t}\n\treturn fromWord( this._buffer[ idx ] );\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name buffer\n* @memberof Float16Array.prototype\n* @readonly\n* @type {ArrayBuffer}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var buf = arr.buffer;\n* // returns \n*/\nsetReadOnlyAccessor( Float16Array.prototype, 'buffer', function get() {\n\treturn this._buffer.buffer;\n});\n\n/**\n* Size (in bytes) of the array.\n*\n* @name byteLength\n* @memberof Float16Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var byteLength = arr.byteLength;\n* // returns 20\n*/\nsetReadOnlyAccessor( Float16Array.prototype, 'byteLength', function get() {\n\treturn this._buffer.byteLength;\n});\n\n/**\n* Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`.\n*\n* @name byteOffset\n* @memberof Float16Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var byteOffset = arr.byteOffset;\n* // returns 0\n*/\nsetReadOnlyAccessor( Float16Array.prototype, 'byteOffset', function get() {\n\treturn this._buffer.byteOffset;\n});\n\n/**\n* Size (in bytes) of each array element.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Float16Array.prototype\n* @readonly\n* @type {PositiveInteger}\n* @default 2\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var nbytes = arr.BYTES_PER_ELEMENT;\n* // returns 2\n*/\nsetReadOnly( Float16Array.prototype, 'BYTES_PER_ELEMENT', Float16Array.BYTES_PER_ELEMENT );\n\n/**\n* Copies a sequence of elements within the array to the position starting at `target`.\n*\n* @name copyWithin\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} target - index at which to start copying elements\n* @param {integer} start - source index at which to copy elements from\n* @param {integer} [end] - source index at which to stop copying elements from\n* @throws {TypeError} `this` must be a floating-point array\n* @returns {Float16Array} modified array\n*\n* @example\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0 ] );\n*\n* // Copy the first two elements to the last two elements:\n* arr.copyWithin( 2, 0, 2 );\n*\n* var v = arr[ 2 ];\n* // returns 1.0\n*\n* v = arr[ 3 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'copyWithin', function copyWithin( target, start ) {\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\t// FIXME: prefer a functional `copyWithin` implementation which addresses lack of universal browser support (e.g., IE11 and Safari) or ensure that typed arrays are polyfilled\n\tif ( arguments.length === 2 ) {\n\t\tthis._buffer.copyWithin( target, start );\n\t} else {\n\t\tthis._buffer.copyWithin( target, start, arguments[2] );\n\t}\n\treturn this;\n});\n\n/**\n* Returns an iterator for iterating over array key-value pairs.\n*\n* @name entries\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] );\n*\n* var it = arr.entries();\n*\n* var v = it.next().value;\n* // returns [ 0, 1.0 ]\n*\n* v = it.next().value;\n* // returns [ 1, 2.0 ]\n*\n* v = it.next().value;\n* // returns [ 2, 3.0 ]\n*\n* var bool = it.next().done;\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'entries', function entries() {\n\tvar self;\n\tvar iter;\n\tvar len;\n\tvar buf;\n\tvar FLG;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tself = this;\n\tbuf = this._buffer;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': [ i, fromWord( buf[ i ] ) ],\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.entries();\n\t}\n});\n\n/**\n* Tests whether all elements in an array pass a test implemented by a predicate function.\n*\n* @name every\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {boolean} boolean indicating whether all elements pass a test\n*\n* @example\n* function predicate( v ) {\n* return v === 0.0;\n* }\n*\n* var arr = new Float16Array( 3 );\n*\n* var bool = arr.every( predicate );\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'every', function every( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( !predicate.call( thisArg, fromWord( buf[ i ] ), i, this ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n});\n\n/**\n* Returns a modified typed array filled with a fill value.\n*\n* @name fill\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {number} value - fill value\n* @param {integer} [start=0] - starting index (inclusive)\n* @param {integer} [end] - ending index (exclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a floating-point number\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be an integer\n* @returns {Float16Array} modified array\n*\n* @example\n* var arr = new Float16Array( 3 );\n*\n* arr.fill( 1.0, 1 );\n*\n* var v = arr[ 0 ];\n* // returns 0.0\n*\n* v = arr[ 1 ];\n* // returns 1.0\n*\n* v = arr[ 2 ];\n* // returns 1.0\n*/\nsetReadOnly( Float16Array.prototype, 'fill', function fill( value, start, end ) {\n\tvar buf;\n\tvar len;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNumber( value ) ) {\n\t\tthrow new TypeError( format( 'null49', value ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( start ) ) {\n\t\t\tthrow new TypeError( format( 'null7f', start ) );\n\t\t}\n\t\tif ( start < 0 ) {\n\t\t\tstart += len;\n\t\t\tif ( start < 0 ) {\n\t\t\t\tstart = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length > 2 ) {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2z', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t} else {\n\t\t\tend = len;\n\t\t}\n\t} else {\n\t\tstart = 0;\n\t\tend = len;\n\t}\n\tv = toWord( value );\n\tfor ( i = start; i < end; i++ ) {\n\t\tbuf[ i ] = v;\n\t}\n\treturn this;\n});\n\n/**\n* Returns a new array containing the elements of an array which pass a test implemented by a predicate function.\n*\n* @name filter\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {Float16Array} floating-point number array\n*\n* @example\n* function predicate( v ) {\n* return ( v === 0.0 );\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] );\n*\n* var out = arr.filter( predicate );\n* // returns \n*\n* var len = out.length;\n* // returns 2\n*\n* var v = out[ 0 ];\n* // returns 0.0\n*\n* v = out[ 1 ];\n* // returns 0.0\n*/\nsetReadOnly( Float16Array.prototype, 'filter', function filter( predicate, thisArg ) {\n\tvar buf;\n\tvar out;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\tout.push( v );\n\t\t}\n\t}\n\treturn new this.constructor( out );\n});\n\n/**\n* Returns the first element in an array for which a predicate function returns a truthy value.\n*\n* @name find\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {(boolean|void)} array element or undefined\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] );\n*\n* var v = arr.find( predicate );\n* // returns 1.0\n*/\nsetReadOnly( Float16Array.prototype, 'find', function find( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn v;\n\t\t}\n\t}\n});\n\n/**\n* Returns the index of the first element in an array for which a predicate function returns a truthy value.\n*\n* @name findIndex\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {integer} index or -1\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var v = arr.findIndex( predicate );\n* // returns 1\n*/\nsetReadOnly( Float16Array.prototype, 'findIndex', function findIndex( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Returns the last element in an array for which a predicate function returns a truthy value.\n*\n* @name findLast\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {(boolean|void)} array element or undefined\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] );\n*\n* var v = arr.findLast( predicate );\n* // returns 1.0\n*/\nsetReadOnly( Float16Array.prototype, 'findLast', function findLast( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = this._length-1; i >= 0; i-- ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn v;\n\t\t}\n\t}\n});\n\n/**\n* Returns the index of the last element in an array for which a predicate function returns a truthy value.\n*\n* @name findLastIndex\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {integer} index or -1\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] );\n*\n* var v = arr.findLastIndex( predicate );\n* // returns 1\n*/\nsetReadOnly( Float16Array.prototype, 'findLastIndex', function findLastIndex( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = this._length-1; i >= 0; i-- ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Invokes a function once for each array element.\n*\n* @name forEach\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} fcn - function to invoke\n* @param {*} [thisArg] - function invocation context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n*\n* @example\n* function log( v, i ) {\n* console.log( '%s: %s', i, v.toString() );\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* arr.forEach( log );\n*/\nsetReadOnly( Float16Array.prototype, 'forEach', function forEach( fcn, thisArg ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( fcn ) ) {\n\t\tthrow new TypeError( format( 'null3c', fcn ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tfcn.call( thisArg, fromWord( buf[ i ] ), i, this );\n\t}\n});\n\n/**\n* Returns an array element.\n*\n* @private\n* @name _get\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {NonNegativeInteger} idx - element index\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} must provide a nonnegative integer\n* @returns {(number|void)} array element\n*/\nsetReadOnly( Float16Array.prototype, '_get', function get( idx ) {\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNonNegativeInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'null2K', idx ) );\n\t}\n\tif ( idx >= this._length ) {\n\t\treturn;\n\t}\n\treturn fromWord( this._buffer[ idx ] );\n});\n\n/**\n* Returns a boolean indicating whether an array includes a provided value.\n*\n* @name includes\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {number} searchElement - search element\n* @param {integer} [fromIndex=0] - starting index (inclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a floating-point number\n* @throws {TypeError} second argument must be an integer\n* @returns {boolean} boolean indicating whether an array includes a value\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] );\n*\n* var bool = arr.includes( 1.0 );\n* // returns true\n*\n* bool = arr.includes( 1.0, 2 );\n* // returns false\n*\n* bool = arr.includes( 5.0 );\n* // returns false\n*/\nsetReadOnly( Float16Array.prototype, 'includes', function includes( searchElement, fromIndex ) {\n\tvar buf;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNumber( searchElement ) ) {\n\t\tthrow new TypeError( format( 'null49', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'null7f', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\tfromIndex = 0;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfromIndex = 0;\n\t}\n\tbuf = this._buffer;\n\tv = toWord( searchElement );\n\tfor ( i = fromIndex; i < this._length; i++ ) {\n\t\tif ( v === buf[ i ] ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n});\n\n/**\n* Returns the first index at which a given element can be found.\n*\n* @name indexOf\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {float16} searchElement - element to find\n* @param {integer} [fromIndex=0] - starting index (inclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a floating-point number\n* @throws {TypeError} second argument must be an integer\n* @returns {integer} index or -1\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] );\n*\n* var idx = arr.indexOf( 2.0 );\n* // returns 2\n*\n* idx = arr.indexOf( 2.0, 3 );\n* // returns -1\n*\n* idx = arr.indexOf( 3.0, 3 );\n* // returns 3\n*/\nsetReadOnly( Float16Array.prototype, 'indexOf', function indexOf( searchElement, fromIndex ) {\n\tvar buf;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNumber( searchElement ) ) {\n\t\tthrow new TypeError( format( 'null49', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'null7f', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\tfromIndex = 0;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfromIndex = 0;\n\t}\n\tbuf = this._buffer;\n\tv = toWord( searchElement );\n\tfor ( i = fromIndex; i < this._length; i++ ) {\n\t\tif ( v === buf[ i ] ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Returns a new string by concatenating all array elements.\n*\n* @name join\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {string} [separator=','] - element separator\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a string\n* @returns {string} string representation\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var str = arr.join();\n* // returns '0,1,2'\n*\n* str = arr.join( '|' );\n* // returns '0|1|2'\n*/\nsetReadOnly( Float16Array.prototype, 'join', function join( separator ) {\n\tvar buf;\n\tvar out;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( arguments.length > 0 ) {\n\t\tif ( !isString( separator ) ) {\n\t\t\tthrow new TypeError( format( 'null3F', separator ) );\n\t\t}\n\t} else {\n\t\tseparator = ',';\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( fromWord( buf[ i ] ) );\n\t}\n\treturn out.join( separator );\n});\n\n/**\n* Returns an iterator for iterating over each index key in a typed array.\n*\n* @name keys\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new Float16Array( [ 1.0, 2.0 ] );\n*\n* var iter = arr.keys();\n*\n* var v = iter.next().value;\n* // returns 0\n*\n* v = iter.next().value;\n* // returns 1\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'keys', function keys() {\n\tvar self;\n\tvar iter;\n\tvar len;\n\tvar FLG;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tself = this;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': i,\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.keys();\n\t}\n});\n\n/**\n* Returns the last index at which a given element can be found.\n*\n* @name lastIndexOf\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {number} searchElement - element to find\n* @param {integer} [fromIndex] - starting index (inclusive)\n* @throws {TypeError} `this` must be a floating-point number\n* @throws {TypeError} first argument must be a numeric value\n* @throws {TypeError} second argument must be an integer\n* @returns {integer} index or -1\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 2.0 ] );\n*\n* var idx = arr.lastIndexOf( 2.0 );\n* // returns 4\n*\n* idx = arr.lastIndexOf( 2.0, 3 );\n* // returns 2\n*\n* idx = arr.lastIndexOf( 4.0, 3 );\n* // returns -1\n*\n* idx = arr.lastIndexOf( 1.0, -3 );\n* // returns 1\n*/\nsetReadOnly( Float16Array.prototype, 'lastIndexOf', function lastIndexOf( searchElement, fromIndex ) {\n\tvar buf;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNumber( searchElement ) ) {\n\t\tthrow new TypeError( format( 'null49', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'null7f', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex >= this._length ) {\n\t\t\tfromIndex = this._length - 1;\n\t\t} else if ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t}\n\t} else {\n\t\tfromIndex = this._length - 1;\n\t}\n\tbuf = this._buffer;\n\tv = toWord( searchElement );\n\tfor ( i = fromIndex; i >= 0; i-- ) {\n\t\tif ( v === buf[ i ] ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Number of array elements.\n*\n* @name length\n* @memberof Float16Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var len = arr.length;\n* // returns 10\n*/\nsetReadOnlyAccessor( Float16Array.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Returns a new array with each element being the result of a provided callback function.\n*\n* @name map\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} fcn - callback function\n* @param {*} [thisArg] - callback function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {Float16Array} new floating-point number array\n*\n* @example\n* function scale( v ) {\n* return v * 2.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var out = arr.map( scale );\n* // returns \n*\n* var z = out[ 0 ];\n* // returns 0.0\n*\n* z = out[ 1 ];\n* // returns 2.0\n*\n* z = out[ 2 ];\n* // returns 4.0\n*/\nsetReadOnly( Float16Array.prototype, 'map', function map( fcn, thisArg ) {\n\tvar outbuf;\n\tvar out;\n\tvar buf;\n\tvar i;\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( fcn ) ) {\n\t\tthrow new TypeError( format('null3c'), fcn );\n\t}\n\tbuf = this._buffer;\n\tout = new this.constructor( this._length );\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\toutbuf[ i ] = toWord( fcn.call( thisArg, fromWord( buf[ i ] ), i, this ) ); // eslint-disable-line max-len\n\t}\n\treturn out;\n});\n\n/**\n* Applies a provided callback function to each element of the array, in order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion.\n*\n* @name reduce\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} reducer - callback function\n* @param {*} [initialValue] - initial value\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {Error} if not provided an initial value, the array must have at least one element\n* @returns {*} accumulated result\n*\n* @example\n* function add( acc, v ) {\n* return acc + v;\n* }\n*\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] );\n*\n* var out = arr.reduce( add, 0 );\n* // returns 6.0\n*/\nsetReadOnly( Float16Array.prototype, 'reduce', function reduce( reducer, initialValue ) {\n\tvar buf;\n\tvar len;\n\tvar acc;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( reducer ) ) {\n\t\tthrow new TypeError( format( 'null3c', reducer ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tacc = initialValue;\n\t\ti = 0;\n\t} else {\n\t\tif ( len === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' );\n\t\t}\n\t\tacc = fromWord( buf[ 0 ] );\n\t\ti = 1;\n\t}\n\tfor ( ; i < len; i++ ) {\n\t\tacc = reducer( acc, fromWord( buf[ i ] ), i, this );\n\t}\n\treturn acc;\n});\n\n/**\n* Applies a provided callback function to each element of the array, in reverse order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion.\n*\n* @name reduceRight\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} reducer - callback function\n* @param {*} [initialValue] - initial value\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {Error} if not provided an initial value, the array must have at least one element\n* @returns {*} accumulated result\n*\n* @example\n* function add( acc, v ) {\n* return acc + v;\n* }\n*\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] );\n*\n* var out = arr.reduceRight( add, 0 );\n* // returns 6.0\n*/\nsetReadOnly( Float16Array.prototype, 'reduceRight', function reduceRight( reducer, initialValue ) {\n\tvar buf;\n\tvar len;\n\tvar acc;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( reducer ) ) {\n\t\tthrow new TypeError( format( 'null3c', reducer ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tacc = initialValue;\n\t\ti = len - 1;\n\t} else {\n\t\tif ( len === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' );\n\t\t}\n\t\tacc = fromWord( buf[ len-1 ] );\n\t\ti = len - 2;\n\t}\n\tfor ( ; i >= 0; i-- ) {\n\t\tacc = reducer( acc, fromWord( buf[ i ] ), i, this );\n\t}\n\treturn acc;\n});\n\n/**\n* Reverses an array in-place.\n*\n* @name reverse\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Float16Array} reversed array\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var out = arr.reverse();\n* // returns \n*\n* var v = out[ 0 ];\n* // returns 2.0\n*\n* v = out[ 1 ];\n* // returns 1.0\n*\n* v = out[ 2 ];\n* // returns 0.0\n*/\nsetReadOnly( Float16Array.prototype, 'reverse', function reverse() {\n\tvar buf;\n\tvar tmp;\n\tvar len;\n\tvar N;\n\tvar i;\n\tvar j;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tN = floor( len / 2 );\n\tfor ( i = 0; i < N; i++ ) {\n\t\tj = len - i - 1;\n\t\ttmp = buf[ i ];\n\t\tbuf[ i ] = buf[ j ];\n\t\tbuf[ j ] = tmp;\n\t}\n\treturn this;\n});\n\n/**\n* Sets one or more array elements.\n*\n* ## Notes\n*\n* - When provided a typed array, we must check whether the source array shares the same buffer as the target array and whether the underlying memory overlaps. In particular, we are concerned with the following scenario:\n*\n* ```text\n* buf: ---------------------\n* src: ---------------------\n* ```\n*\n* In the above, as we copy values from `src`, we will overwrite values in the `src` view, resulting in duplicated values copied into the end of `buf`, which is not intended. Hence, to avoid overwriting source values, we must **copy** source values to a temporary array.\n*\n* In the other overlapping scenario,\n*\n* ```text\n* buf: ---------------------\n* src: ---------------------\n* ```\n*\n* by the time we begin copying into the overlapping region, we are copying from the end of `src`, a non-overlapping region, which means we don't run the risk of copying copied values, rather than the original `src` values, as intended.\n*\n* @name set\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {(Collection|Float16Array)} value - value(s)\n* @param {NonNegativeInteger} [i=0] - element index at which to start writing values\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a collection\n* @throws {TypeError} index argument must be a nonnegative integer\n* @throws {RangeError} index argument is out-of-bounds\n* @throws {RangeError} target array lacks sufficient storage to accommodate source values\n* @returns {void}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var v = arr[ 0 ];\n* // returns 0.0\n*\n* arr.set( [ 1.0, 2.0 ], 0 );\n*\n* v = arr[ 0 ];\n* // returns 1.0\n*/\nsetReadOnly( Float16Array.prototype, 'set', function set( value ) {\n\tvar sbuf;\n\tvar idx;\n\tvar buf;\n\tvar tmp;\n\tvar flg;\n\tvar N;\n\tvar i;\n\tvar j;\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isCollection( value ) ) {\n\t\tthrow new TypeError( format( 'null2O', value ) );\n\t}\n\tbuf = this._buffer;\n\tif ( arguments.length > 1 ) {\n\t\tidx = arguments[ 1 ];\n\t\tif ( !isNonNegativeInteger( idx ) ) {\n\t\t\tthrow new TypeError( format( 'null2L', idx ) );\n\t\t}\n\t} else {\n\t\tidx = 0;\n\t}\n\tN = value.length;\n\tif ( idx+N > this._length ) {\n\t\tthrow new RangeError( format('null03') );\n\t}\n\tif ( isFloat16Array( value ) ) {\n\t\tsbuf = value._buffer; // eslint-disable-line no-underscore-dangle\n\t\tflg = true;\n\t} else {\n\t\tsbuf = value;\n\t\tflg = false;\n\t}\n\t// Check for overlapping memory...\n\tj = buf.byteOffset + (idx*BYTES_PER_ELEMENT);\n\tif (\n\t\tsbuf.buffer === buf.buffer &&\n\t\t(\n\t\t\tsbuf.byteOffset < j &&\n\t\t\tsbuf.byteOffset+sbuf.byteLength > j\n\t\t)\n\t) {\n\t\t// We need to copy source values...\n\t\ttmp = new Uint16Array( sbuf.length );\n\t\tfor ( i = 0; i < sbuf.length; i++ ) {\n\t\t\ttmp[ i ] = sbuf[ i ];\n\t\t}\n\t\tsbuf = tmp;\n\t}\n\tif ( flg ) {\n\t\tfor ( i = 0; i < N; idx++, i++ ) {\n\t\t\tbuf[ idx ] = sbuf[ i ];\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < N; idx++, i++ ) {\n\t\t\tbuf[ idx ] = toWord( sbuf[ i ] );\n\t\t}\n\t}\n});\n\n/**\n* Copies a portion of a typed array to a new typed array.\n*\n* @name slice\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} [begin] - start index (inclusive)\n* @param {integer} [end] - end index (exclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be integer\n* @throws {TypeError} second argument must be integer\n* @returns {Float16Array} floating-point number array\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] );\n*\n* var out = arr.slice();\n* // returns \n*\n* var len = out.length;\n* // returns 5\n*\n* var v = out[ 0 ];\n* // returns 0.0\n*\n* v = out[ len-1 ];\n* // returns 4.0\n*\n* out = arr.slice( 1, -2 );\n* // returns \n*\n* len = out.length;\n* // returns 2\n*\n* v = out[ 0 ];\n* // returns 1.0\n*\n* v = out[ len-1 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'slice', function slice( begin, end ) {\n\tvar outlen;\n\tvar outbuf;\n\tvar out;\n\tvar buf;\n\tvar len;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length === 0 ) {\n\t\tbegin = 0;\n\t\tend = len;\n\t} else {\n\t\tif ( !isInteger( begin ) ) {\n\t\t\tthrow new TypeError( format( 'null7e', begin ) );\n\t\t}\n\t\tif ( begin < 0 ) {\n\t\t\tbegin += len;\n\t\t\tif ( begin < 0 ) {\n\t\t\t\tbegin = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\tend = len;\n\t\t} else {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'null7f', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t} else if ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t}\n\t}\n\tif ( begin < end ) {\n\t\toutlen = end - begin;\n\t} else {\n\t\toutlen = 0;\n\t}\n\tout = new this.constructor( outlen );\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < outlen; i++ ) {\n\t\toutbuf[ i ] = buf[ i+begin ];\n\t}\n\treturn out;\n});\n\n/**\n* Tests whether at least one element in an array passes a test implemented by a predicate function.\n*\n* @name some\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {boolean} boolean indicating whether at least one element passes a test\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var bool = arr.some( predicate );\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'some', function some( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( predicate.call( thisArg, fromWord( buf[ i ] ), i, this ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n});\n\n/**\n* Sorts an array in-place.\n*\n* @name sort\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} [compareFcn] - comparison function\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {Float16Array} sorted array\n*\n* @example\n* function compare( a, b ) {\n* if ( a < b ) {\n* return -1;\n* }\n* if ( a > b ) {\n* return 1;\n* }\n* return 0;\n* }\n*\n* var arr = new Float16Array( [ 1.0, 0.0, 2.0 ] );\n*\n* arr.sort( compare );\n*\n* var v = arr[ 0 ];\n* // returns 0.0\n*\n* v = arr[ 1 ];\n* // returns 1.0\n*\n* v = arr[ 2 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'sort', function sort( compareFcn ) {\n\tvar buf;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tif ( arguments.length === 0 ) {\n\t\tbuf.sort( defaultCompare );\n\t\treturn this;\n\t}\n\tif ( !isFunction( compareFcn ) ) {\n\t\tthrow new TypeError( format( 'null3c', compareFcn ) );\n\t}\n\tbuf.sort( compare );\n\treturn this;\n\n\t/**\n\t* Default comparison function for float16 values.\n\t*\n\t* @private\n\t* @param {unsigned16} a - unsigned 16-bit integer for comparison\n\t* @param {unsigned16} b - unsigned 16-bit integer for comparison\n\t* @returns {number} comparison result\n\t*/\n\tfunction defaultCompare( a, b ) { // eslint-disable-line stdlib/no-unnecessary-nested-functions\n\t\tvar x = fromWord( a );\n\t\tvar y = fromWord( b );\n\n\t\t// Handle NaN...\n\t\tif ( isnan( x ) && isnan( y ) ) {\n\t\t\treturn 0;\n\t\t}\n\t\tif ( isnan( x ) ) {\n\t\t\treturn 1;\n\t\t}\n\t\tif ( isnan( y ) ) {\n\t\t\treturn -1;\n\t\t}\n\t\t// Normal comparison\n\t\tif ( x < y ) {\n\t\t\treturn -1;\n\t\t}\n\t\tif ( x > y ) {\n\t\t\treturn 1;\n\t\t}\n\t\treturn 0;\n\t}\n\n\t/**\n\t* Comparison function wrapper.\n\t*\n\t* @private\n\t* @param {unsigned16} a - unsigned 16-bit integer for comparison\n\t* @param {unsigned16} b - unsigned 16-bit integer for comparison\n\t* @returns {number} comparison result\n\t*/\n\tfunction compare( a, b ) {\n\t\treturn compareFcn( fromWord( a ), fromWord( b ) );\n\t}\n});\n\n/**\n* Creates a new typed array view over the same underlying `ArrayBuffer` and with the same underlying data type as the host array.\n*\n* @name subarray\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} [begin] - start index (inclusive)\n* @param {integer} [end] - end index (exclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be an integer\n* @throws {TypeError} second argument must be an integer\n* @returns {Float16Array} subarray\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] );\n*\n* var subarr = arr.subarray();\n* // returns \n*\n* var len = subarr.length;\n* // returns 5\n*\n* var bool = subarr[ 0 ];\n* // returns 0.0\n*\n* bool = subarr[ len-1 ];\n* // returns 4.0\n*\n* subarr = arr.subarray( 1, -2 );\n* // returns \n*\n* len = subarr.length;\n* // returns 2\n*\n* bool = subarr[ 0 ];\n* // returns 1.0\n*\n* bool = subarr[ len-1 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'subarray', function subarray( begin, end ) {\n\tvar offset;\n\tvar buf;\n\tvar len;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length === 0 ) {\n\t\tbegin = 0;\n\t\tend = len;\n\t} else {\n\t\tif ( !isInteger( begin ) ) {\n\t\t\tthrow new TypeError( format( 'null7e', begin ) );\n\t\t}\n\t\tif ( begin < 0 ) {\n\t\t\tbegin += len;\n\t\t\tif ( begin < 0 ) {\n\t\t\t\tbegin = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\tend = len;\n\t\t} else {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'null7f', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t} else if ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t}\n\t}\n\tif ( begin >= len ) {\n\t\tlen = 0;\n\t\toffset = buf.byteLength;\n\t} else if ( begin >= end ) {\n\t\tlen = 0;\n\t\toffset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT );\n\t} else {\n\t\tlen = end - begin;\n\t\toffset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT );\n\t}\n\treturn new this.constructor( buf.buffer, offset, ( len < 0 ) ? 0 : len );\n});\n\n/**\n* Serializes an array as a locale-specific string.\n*\n* @name toLocaleString\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {(string|Array)} [locales] - locale identifier(s)\n* @param {Object} [options] - configuration options\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a string or an array of strings\n* @throws {TypeError} options argument must be an object\n* @returns {string} string representation\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var str = arr.toLocaleString();\n* // returns '0,1,2'\n*/\nsetReadOnly( Float16Array.prototype, 'toLocaleString', function toLocaleString( locales, options ) {\n\tvar opts;\n\tvar loc;\n\tvar out;\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( arguments.length === 0 ) {\n\t\tloc = [];\n\t} else if ( isString( locales ) || isStringArray( locales ) ) {\n\t\tloc = locales;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a string or an array of strings. Value: `%s`.', locales ) );\n\t}\n\tif ( arguments.length < 2 ) {\n\t\topts = {};\n\t} else if ( isObject( options ) ) {\n\t\topts = options;\n\t} else {\n\t\tthrow new TypeError( format( 'null2V', options ) );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( fromWord( buf[ i ] ) );\n\t}\n\treturn out.toLocaleString( loc, opts );\n});\n\n/**\n* Returns a new typed array containing the elements in reversed order.\n*\n* @name toReversed\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Float16Array} reversed array\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var out = arr.toReversed();\n* // returns \n*\n* var v = out[ 0 ];\n* // returns 2.0\n*\n* v = out[ 1 ];\n* // returns 1.0\n*\n* v = out[ 2 ];\n* // returns 0.0\n*/\nsetReadOnly( Float16Array.prototype, 'toReversed', function toReversed() {\n\tvar outbuf;\n\tvar out;\n\tvar len;\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tlen = this._length;\n\tout = new this.constructor( len );\n\tbuf = this._buffer;\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < len; i++ ) {\n\t\toutbuf[ i ] = buf[ len - i - 1 ];\n\t}\n\treturn out;\n});\n\n/**\n* Returns a new typed array containing the elements in sorted order.\n*\n* @name toSorted\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} [compareFcn] - comparison function\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {Float16Array} sorted array\n*\n* @example\n* function compare( a, b ) {\n* if ( a > b ) {\n* return 1;\n* }\n* if ( a < b ) {\n* return -1;\n* }\n* return 0;\n* }\n*\n* var arr = new Float16Array( [ 2.0, 0.0, 1.0 ] );\n*\n* var out = arr.toSorted( compare );\n* // returns \n*\n* var v = out[ 0 ];\n* // returns 0.0\n*\n* v = out[ 1 ];\n* // returns 1.0\n*\n* v = out[ 2 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'toSorted', function toSorted( compareFcn ) {\n\tvar out;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tout = new this.constructor( this );\n\tif ( arguments.length === 0 ) {\n\t\treturn out.sort();\n\t}\n\treturn out.sort( compareFcn );\n});\n\n/**\n* Serializes an array as a string.\n*\n* @name toString\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {string} string representation\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var str = arr.toString();\n* // returns '0,1,2'\n*/\nsetReadOnly( Float16Array.prototype, 'toString', function toString() {\n\tvar out;\n\tvar buf;\n\tvar i;\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( fromWord( buf[ i ] ) );\n\t}\n\treturn out.join( ',' );\n});\n\n/**\n* Returns an iterator for iterating over each value in a typed array.\n*\n* @name values\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0 ] );\n*\n* var iter = arr.values();\n*\n* var v = iter.next().value;\n* // returns 0.0\n*\n* v = iter.next().value;\n* // returns 1.0\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'values', function values() {\n\tvar iter;\n\tvar self;\n\tvar len;\n\tvar FLG;\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tself = this;\n\tbuf = this._buffer;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': fromWord( buf[ i ] ),\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.values();\n\t}\n});\n\n/**\n* Returns a new typed array with the element at a provided index replaced with a provided value.\n*\n* @name with\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} index - element index\n* @param {number} value - new value\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be an integer\n* @throws {RangeError} index argument is out-of-bounds\n* @throws {TypeError} second argument must be a floating-point number\n* @returns {Float16Array} new typed array\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var out = arr.with( 0, 3.0 );\n* // returns \n*\n* var v = out[ 0 ];\n* // returns 3.0\n*/\nsetReadOnly( Float16Array.prototype, 'with', function copyWith( index, value ) {\n\tvar out;\n\tvar len;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isInteger( index ) ) {\n\t\tthrow new TypeError( format( 'null7e', index ) );\n\t}\n\tlen = this._length;\n\tif ( index < 0 ) {\n\t\tindex += len;\n\t}\n\tif ( index < 0 || index >= len ) {\n\t\tthrow new RangeError( format( 'nullFP', index ) );\n\t}\n\tif ( !isNumber( value ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a floating-point number. Value: `%s`.', value ) );\n\t}\n\tout = new this.constructor( this );\n\tout[ index ] = value;\n\treturn out;\n});\n\n\n// EXPORTS //\n\nexport default Float16Array;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport f16 from '@stdlib/number-float64-base-to-float16';\nimport toWord from '@stdlib/number-float16-base-to-word';\n\n\n// MAIN //\n\n/**\n* Fills an output array with unsigned 16-bit integers corresponding to the IEEE 754 binary representation of respective half-precision floating-point numbers.\n*\n* @private\n* @param {Uint16Array} buf - output array\n* @param {Array} arr - input array\n* @returns {Uint16Array} output array\n*/\nfunction fromArray( buf, arr ) {\n\tvar len;\n\tvar i;\n\n\tlen = arr.length;\n\tfor ( i = 0; i < len; i++ ) {\n\t\tbuf[ i ] = toWord( f16( arr[ i ] ) );\n\t}\n\treturn buf;\n}\n\n\n// EXPORTS //\n\nexport default fromArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport f16 from '@stdlib/number-float64-base-to-float16';\nimport toWord from '@stdlib/number-float16-base-to-word';\n\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @param {Function} clbk - callback to invoke for each iterated value\n* @param {*} thisArg - invocation context\n* @returns {Array} output array\n*/\nfunction fromIteratorMap( it, clbk, thisArg ) {\n\tvar out;\n\tvar v;\n\tvar i;\n\n\tout = [];\n\ti = -1;\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\ti += 1;\n\t\tout.push( toWord( f16( clbk.call( thisArg, v.value, i ) ) ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIteratorMap;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Float16Array === 'function' ) ? Float16Array : void 0; // eslint-disable-line no-undef, stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* 16-bit floating-point number array constructor.\n*\n* @module @stdlib/array-float16\n*\n* @example\n* import Float16Array from '@stdlib/array-float16';\n*\n* var arr = new Float16Array();\n* // returns \n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* import Float16Array from '@stdlib/array-float16';\n*\n* var arr = new Float16Array( 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import Float16Array from '@stdlib/array-float16';\n*\n* var arr = new Float16Array( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n* import Float16Array from '@stdlib/array-float16';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float16Array( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 8\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n* import Float16Array from '@stdlib/array-float16';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float16Array( buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 4\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n* import Float16Array from '@stdlib/array-float16';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Float16Array( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\n\n// MODULES //\n\nimport hasFloat16ArraySupport from '@stdlib/assert-has-float16array-support';\nimport polyfill from './polyfill';\nimport builtin from './main.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasFloat16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n"],"names":["fromIterator","it","out","v","next","done","push","toWord","f16","value","BYTES_PER_ELEMENT","Uint16Array","HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","isFloat16Array","constructor","name","isFloatingPointArrayConstructor","Float16Array","getter","ctx","idx","_get","setter","set","byteOffset","nargs","buf","len","arg","i","arguments","length","this","isNonNegativeInteger","isCollection","gcopy","ndarray","buffer","arr","fromArray","isArrayBuffer","isInteger","byteLength","RangeError","format","isObject","TypeError","isFunction","ITERATOR_SYMBOL","setReadOnly","setReadWriteAccessor","src","thisArg","clbk","tmp","_buffer","call","fromIteratorMap","Error","args","prototype","_length","fromWord","setReadOnlyAccessor","target","start","copyWithin","self","iter","FLG","entries","predicate","end","isNumber","fcn","searchElement","fromIndex","separator","isString","join","keys","outbuf","reducer","initialValue","acc","N","j","floor","sbuf","flg","begin","outlen","compareFcn","sort","a","b","x","y","isnan","offset","locales","options","opts","loc","isStringArray","toLocaleString","values","index","ctor","ctor$1","hasFloat16ArraySupport","builtin","polyfill"],"mappings":"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"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 662979c..0000000 --- a/lib/index.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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'; - -/** -* 16-bit floating-point number array constructor. -* -* @module @stdlib/array-float16 -* -* @example -* var Float16Array = require( '@stdlib/array-float16' ); -* -* var arr = new Float16Array(); -* // returns -* -* var len = arr.length; -* // returns 0 -* -* @example -* var Float16Array = require( '@stdlib/array-float16' ); -* -* var arr = new Float16Array( 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var Float16Array = require( '@stdlib/array-float16' ); -* -* var arr = new Float16Array( [ 1.0, 2.0 ] ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var Float16Array = require( '@stdlib/array-float16' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float16Array( buf ); -* // returns -* -* var len = arr.length; -* // returns 8 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var Float16Array = require( '@stdlib/array-float16' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float16Array( buf, 8 ); -* // returns -* -* var len = arr.length; -* // returns 4 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var Float16Array = require( '@stdlib/array-float16' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = new Float16Array( buf, 8, 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -*/ - -// MODULES // - -var hasFloat16ArraySupport = require( '@stdlib/assert-has-float16array-support' ); -var polyfill = require( './polyfill' ); -var builtin = require( './main.js' ); - - -// MAIN // - -var ctor; -if ( hasFloat16ArraySupport() ) { - ctor = builtin; -} else { - ctor = polyfill; -} - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 90c9924..0000000 --- a/lib/main.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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'; - -// MAIN // - -var ctor = ( typeof Float16Array === 'function' ) ? Float16Array : void 0; // eslint-disable-line no-undef, stdlib/require-globals - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/polyfill/from_array.js b/lib/polyfill/from_array.js deleted file mode 100644 index b5894dc..0000000 --- a/lib/polyfill/from_array.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 f16 = require( '@stdlib/number-float64-base-to-float16' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); - - -// MAIN // - -/** -* Fills an output array with unsigned 16-bit integers corresponding to the IEEE 754 binary representation of respective half-precision floating-point numbers. -* -* @private -* @param {Uint16Array} buf - output array -* @param {Array} arr - input array -* @returns {Uint16Array} output array -*/ -function fromArray( buf, arr ) { - var len; - var i; - - len = arr.length; - for ( i = 0; i < len; i++ ) { - buf[ i ] = toWord( f16( arr[ i ] ) ); - } - return buf; -} - - -// EXPORTS // - -module.exports = fromArray; diff --git a/lib/polyfill/from_iterator.js b/lib/polyfill/from_iterator.js deleted file mode 100644 index 37a2c7c..0000000 --- a/lib/polyfill/from_iterator.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 f16 = require( '@stdlib/number-float64-base-to-float16' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); - - -// MAIN // - -/** -* Returns an array of iterated values. -* -* @private -* @param {Object} it - iterator -* @returns {Array} output array -*/ -function fromIterator( it ) { - var out; - var v; - - out = []; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - out.push( toWord( f16( v.value ) ) ); - } - return out; -} - - -// EXPORTS // - -module.exports = fromIterator; diff --git a/lib/polyfill/from_iterator_map.js b/lib/polyfill/from_iterator_map.js deleted file mode 100644 index 265e59d..0000000 --- a/lib/polyfill/from_iterator_map.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 f16 = require( '@stdlib/number-float64-base-to-float16' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); - - -// MAIN // - -/** -* Returns an array of iterated values. -* -* @private -* @param {Object} it - iterator -* @param {Function} clbk - callback to invoke for each iterated value -* @param {*} thisArg - invocation context -* @returns {Array} output array -*/ -function fromIteratorMap( it, clbk, thisArg ) { - var out; - var v; - var i; - - out = []; - i = -1; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - i += 1; - out.push( toWord( f16( clbk.call( thisArg, v.value, i ) ) ) ); - } - return out; -} - - -// EXPORTS // - -module.exports = fromIteratorMap; diff --git a/lib/polyfill/index.js b/lib/polyfill/index.js deleted file mode 100644 index 063db06..0000000 --- a/lib/polyfill/index.js +++ /dev/null @@ -1,2410 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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. -*/ - -/* eslint-disable no-restricted-syntax, no-invalid-this, stdlib/jsdoc-typedef-typos, max-lines */ - -'use strict'; - -// MODULES // - -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isObject = require( '@stdlib/assert-is-object' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var f16 = require( '@stdlib/number-float64-base-to-float16' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var fromWord = require( '@stdlib/number-float16-base-from-word' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var fromArray = require( './from_array.js' ); -var fromIterator = require( './from_iterator.js' ); -var fromIteratorMap = require( './from_iterator_map.js' ); - - -// VARIABLES // - -var BYTES_PER_ELEMENT = Uint16Array.BYTES_PER_ELEMENT; -var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport(); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating if a value is a `Float16Array`. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating if a value is a `Float16Array` -*/ -function isFloat16Array( value ) { - return ( - typeof value === 'object' && - value !== null && - value.constructor.name === 'Float16Array' && - value.BYTES_PER_ELEMENT === BYTES_PER_ELEMENT - ); -} - -/** -* Returns a boolean indicating if a value is a floating-point typed array constructor. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating if a value is a floating-point typed array constructor -*/ -function isFloatingPointArrayConstructor( value ) { // eslint-disable-line id-length - return ( value === Float16Array ); -} - -/** -* Returns a getter. -* -* @private -* @param {Float16Array} ctx - typed array instance -* @param {NonNegativeInteger} idx - element index -* @returns {Function} getter -*/ -function getter( ctx, idx ) { - return get; - - /** - * Returns an array element. - * - * @private - * @returns {(number|void)} array element - */ - function get() { - return ctx._get( idx ); // eslint-disable-line no-underscore-dangle - } -} - -/** -* Returns a setter. -* -* @private -* @param {Float16Array} ctx - typed array instance -* @param {NonNegativeInteger} idx - element index -* @returns {Function} setter -*/ -function setter( ctx, idx ) { - return set; - - /** - * Sets an array element. - * - * @private - * @param {number} value - value to set - */ - function set( value ) { - ctx.set( [ value ], idx ); - } -} - - -// MAIN // - -/** -* 16-bit floating-point number array constructor. -* -* @constructor -* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable -* @param {NonNegativeInteger} [byteOffset=0] - byte offset -* @param {NonNegativeInteger} [length] - view length -* @throws {RangeError} ArrayBuffer byte length must be a multiple of `2` -* @throws {TypeError} if provided only a single argument, must provide a valid argument -* @throws {TypeError} byte offset must be a nonnegative integer -* @throws {RangeError} byte offset must be a multiple of `2` -* @throws {TypeError} view length must be a positive multiple of `2` -* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements -* @returns {Float16Array} half-precision floating-point number array -* -* @example -* var arr = new Float16Array(); -* // returns -* -* var len = arr.length; -* // returns 0 -* -* @example -* var arr = new Float16Array( 5 ); -* // returns -* -* var len = arr.length; -* // returns 5 -* -* @example -* var arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns -* -* var len = arr.length; -* // returns 5 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float16Array( buf ); -* // returns -* -* var len = arr.length; -* // returns 8 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float16Array( buf, 8 ); -* // returns -* -* var len = arr.length; -* // returns 4 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = new Float16Array( buf, 8, 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -*/ -function Float16Array() { - var byteOffset; - var nargs; - var buf; - var len; - var arg; - var i; - - nargs = arguments.length; - if ( !(this instanceof Float16Array) ) { - if ( nargs === 0 ) { - return new Float16Array(); - } - if ( nargs === 1 ) { - return new Float16Array( arguments[0] ); - } - if ( nargs === 2 ) { - return new Float16Array( arguments[0], arguments[1] ); - } - return new Float16Array( arguments[0], arguments[1], arguments[2] ); - } - // Create the underlying data buffer... - if ( nargs === 0 ) { - buf = new Uint16Array( 0 ); // backward-compatibility - } else if ( nargs === 1 ) { - arg = arguments[ 0 ]; - if ( isNonNegativeInteger( arg ) ) { - buf = new Uint16Array( arg ); - } else if ( isCollection( arg ) ) { - if ( isFloat16Array( arg ) ) { - buf = new Uint16Array( arg.length ); - gcopy.ndarray( arg.length, new Uint16Array( arg.buffer, arg.byteOffset, arg.length ), 1, 0, buf, 1, 0 ); // eslint-disable-line max-len - } else { - buf = fromArray( new Uint16Array( arg.length ), arg ); - } - } else if ( isArrayBuffer( arg ) ) { - if ( !isInteger( arg.byteLength/BYTES_PER_ELEMENT ) ) { - throw new RangeError( format( 'nullE9', BYTES_PER_ELEMENT, arg.byteLength ) ); - } - buf = new Uint16Array( arg ); - } else if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'null29', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'null2A', arg ) ); - } - buf = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( buf.next ) ) { - throw new TypeError( format( 'null2A', arg ) ); - } - buf = new Uint16Array( fromIterator( buf ) ); - } else { - throw new TypeError( format( 'null2A', arg ) ); - } - } else { - buf = arguments[ 0 ]; - if ( !isArrayBuffer( buf ) ) { - throw new TypeError( format( 'null2B', buf ) ); - } - byteOffset = arguments[ 1 ]; - if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'null2C', byteOffset ) ); - } - if ( !isInteger( byteOffset/BYTES_PER_ELEMENT ) ) { - throw new RangeError( format( 'nullEA', BYTES_PER_ELEMENT, byteOffset ) ); - } - if ( nargs === 2 ) { - len = buf.byteLength - byteOffset; - if ( !isInteger( len/BYTES_PER_ELEMENT ) ) { - throw new RangeError( format( 'null2E', BYTES_PER_ELEMENT, len ) ); - } - buf = new Uint16Array( buf, byteOffset ); - } else { - len = arguments[ 2 ]; - if ( !isNonNegativeInteger( len ) ) { - throw new TypeError( format( 'null2F', len ) ); - } - if ( (len*BYTES_PER_ELEMENT) > (buf.byteLength-byteOffset) ) { - throw new RangeError( format( 'null2G', len*BYTES_PER_ELEMENT ) ); - } - buf = new Uint16Array( buf, byteOffset, len ); - } - } - setReadOnly( this, '_buffer', buf ); - setReadOnly( this, '_length', buf.length ); - for ( i = 0; i < buf.length; i++ ) { - setReadWriteAccessor( this, i, getter( this, i ), setter( this, i ) ); - } - return this; -} - -/** -* Size (in bytes) of each array element. -* -* @name BYTES_PER_ELEMENT -* @memberof Float16Array -* @readonly -* @type {PositiveInteger} -* @default 2 -* -* @example -* var nbytes = Float16Array.BYTES_PER_ELEMENT; -* // returns 2 -*/ -setReadOnly( Float16Array, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT ); - -/** -* Constructor name. -* -* @name name -* @memberof Float16Array -* @readonly -* @type {string} -* @default 'Float16Array' -* -* @example -* var str = Float16Array.name; -* // returns 'Float16Array' -*/ -setReadOnly( Float16Array, 'name', 'Float16Array' ); - -/** -* Creates a new 16-bit floating-point number array from an array-like object or an iterable. -* -* @name from -* @memberof Float16Array -* @type {Function} -* @param {(Collection|Iterable)} src - array-like object or iterable -* @param {Function} [clbk] - callback to invoke for each source element -* @param {*} [thisArg] - context -* @throws {TypeError} `this` context must be a constructor -* @throws {TypeError} `this` must be a floating-point array -* @throws {TypeError} first argument must be an array-like object or an iterable -* @throws {TypeError} second argument must be a function -* @returns {Float16Array} half-precision floating-point number array -* -* @example -* var arr = Float16Array.from( [ 1.0, 2.0 ] ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* function clbk( v ) { -* return v * 2.0; -* } -* -* var arr = Float16Array.from( [ 1.0, 2.0 ], clbk ); -* // returns -* -* var len = arr.length; -* // returns 2 -*/ -setReadOnly( Float16Array, 'from', function from( src ) { - var thisArg; - var nargs; - var clbk; - var out; - var buf; - var tmp; - var len; - var i; - if ( !isFunction( this ) ) { - throw new TypeError( format('null01') ); - } - if ( !isFloatingPointArrayConstructor( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point array.' ); - } - nargs = arguments.length; - if ( nargs > 1 ) { - clbk = arguments[ 1 ]; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'null2H', clbk ) ); - } - if ( nargs > 2 ) { - thisArg = arguments[ 2 ]; - } - } - if ( isCollection( src ) ) { - if ( clbk ) { - len = src.length; - out = new this( len ); - buf = out._buffer; // eslint-disable-line no-underscore-dangle - for ( i = 0; i < len; i++ ) { - buf[ i ] = toWord( f16( clbk.call( thisArg, src[ i ], i ) ) ); - } - return out; - } - return new this( src ); - } - if ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) { // eslint-disable-line max-len - buf = src[ ITERATOR_SYMBOL ](); - if ( !isFunction( buf.next ) ) { - throw new TypeError( format( 'null2J', src ) ); - } - if ( clbk ) { - tmp = fromIteratorMap( buf, clbk, thisArg ); - } else { - tmp = fromIterator( buf ); - } - if ( tmp instanceof Error ) { - throw tmp; - } - len = tmp.length; - out = new this( len ); - buf = out._buffer; // eslint-disable-line no-underscore-dangle - for ( i = 0; i < len; i++ ) { - buf[ i ] = tmp[ i ]; - } - return out; - } - throw new TypeError( format( 'null2J', src ) ); -}); - -/** -* Creates a new 16-bit floating-point number array from a variable number of arguments. -* -* @name of -* @memberof Float16Array -* @type {Function} -* @param {...*} element - array elements -* @throws {TypeError} `this` context must be a constructor -* @throws {TypeError} `this` must be a floating-point number array -* @returns {Float16Array} half-precision floating-point number array -* -* @example -* var arr = Float16Array.of( 1.0, 1.0, 1.0, 1.0 ); -* // returns -* -* var x = arr[ 0 ]; -* // returns 1.0 -* -* var len = arr.length; -* // returns 4 -*/ -setReadOnly( Float16Array, 'of', function of() { - var args; - var i; - if ( !isFunction( this ) ) { - throw new TypeError( format('null01') ); - } - if ( !isFloatingPointArrayConstructor( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - args = []; - for ( i = 0; i < arguments.length; i++ ) { - args.push( arguments[ i ] ); - } - return new this( args ); -}); - -/** -* Returns an array element with support for both nonnegative and negative integer indices. -* -* @name at -* @memberof Float16Array.prototype -* @type {Function} -* @param {integer} idx - element index -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} must provide an integer -* @returns {(number|void)} array element -* -* @example -* var arr = new Float16Array( [ 10.0, 20.0, 30.0 ] ); -* -* var v = arr.at( 0 ); -* // returns 10.0 -* -* v = arr.at( -1 ); -* // returns 30.0 -* -* v = arr.at( 100 ); -* // returns undefined -*/ -setReadOnly( Float16Array.prototype, 'at', function at( idx ) { - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isInteger( idx ) ) { - throw new TypeError( format( 'null8A', idx ) ); - } - if ( idx < 0 ) { - idx += this._length; - } - if ( idx < 0 || idx >= this._length ) { - return; - } - return fromWord( this._buffer[ idx ] ); -}); - -/** -* Pointer to the underlying data buffer. -* -* @name buffer -* @memberof Float16Array.prototype -* @readonly -* @type {ArrayBuffer} -* -* @example -* var arr = new Float16Array( 10 ); -* -* var buf = arr.buffer; -* // returns -*/ -setReadOnlyAccessor( Float16Array.prototype, 'buffer', function get() { - return this._buffer.buffer; -}); - -/** -* Size (in bytes) of the array. -* -* @name byteLength -* @memberof Float16Array.prototype -* @readonly -* @type {NonNegativeInteger} -* -* @example -* var arr = new Float16Array( 10 ); -* -* var byteLength = arr.byteLength; -* // returns 20 -*/ -setReadOnlyAccessor( Float16Array.prototype, 'byteLength', function get() { - return this._buffer.byteLength; -}); - -/** -* Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`. -* -* @name byteOffset -* @memberof Float16Array.prototype -* @readonly -* @type {NonNegativeInteger} -* -* @example -* var arr = new Float16Array( 10 ); -* -* var byteOffset = arr.byteOffset; -* // returns 0 -*/ -setReadOnlyAccessor( Float16Array.prototype, 'byteOffset', function get() { - return this._buffer.byteOffset; -}); - -/** -* Size (in bytes) of each array element. -* -* @name BYTES_PER_ELEMENT -* @memberof Float16Array.prototype -* @readonly -* @type {PositiveInteger} -* @default 2 -* -* @example -* var arr = new Float16Array( 10 ); -* -* var nbytes = arr.BYTES_PER_ELEMENT; -* // returns 2 -*/ -setReadOnly( Float16Array.prototype, 'BYTES_PER_ELEMENT', Float16Array.BYTES_PER_ELEMENT ); - -/** -* Copies a sequence of elements within the array to the position starting at `target`. -* -* @name copyWithin -* @memberof Float16Array.prototype -* @type {Function} -* @param {integer} target - index at which to start copying elements -* @param {integer} start - source index at which to copy elements from -* @param {integer} [end] - source index at which to stop copying elements from -* @throws {TypeError} `this` must be a floating-point array -* @returns {Float16Array} modified array -* -* @example -* var arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0 ] ); -* -* // Copy the first two elements to the last two elements: -* arr.copyWithin( 2, 0, 2 ); -* -* var v = arr[ 2 ]; -* // returns 1.0 -* -* v = arr[ 3 ]; -* // returns 2.0 -*/ -setReadOnly( Float16Array.prototype, 'copyWithin', function copyWithin( target, start ) { - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - // FIXME: prefer a functional `copyWithin` implementation which addresses lack of universal browser support (e.g., IE11 and Safari) or ensure that typed arrays are polyfilled - if ( arguments.length === 2 ) { - this._buffer.copyWithin( target, start ); - } else { - this._buffer.copyWithin( target, start, arguments[2] ); - } - return this; -}); - -/** -* Returns an iterator for iterating over array key-value pairs. -* -* @name entries -* @memberof Float16Array.prototype -* @type {Function} -* @throws {TypeError} `this` must be a floating-point number array -* @returns {Iterator} iterator -* -* @example -* var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); -* -* var it = arr.entries(); -* -* var v = it.next().value; -* // returns [ 0, 1.0 ] -* -* v = it.next().value; -* // returns [ 1, 2.0 ] -* -* v = it.next().value; -* // returns [ 2, 3.0 ] -* -* var bool = it.next().done; -* // returns true -*/ -setReadOnly( Float16Array.prototype, 'entries', function entries() { - var self; - var iter; - var len; - var buf; - var FLG; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - self = this; - buf = this._buffer; - len = this._length; - - // Initialize an iteration index: - i = -1; - - // Create an iterator protocol-compliant object: - iter = {}; - setReadOnly( iter, 'next', next ); - setReadOnly( iter, 'return', end ); - - if ( ITERATOR_SYMBOL ) { - setReadOnly( iter, ITERATOR_SYMBOL, factory ); - } - return iter; - - /** - * Returns an iterator protocol-compliant object containing the next iterated value. - * - * @private - * @returns {Object} iterator protocol-compliant object - */ - function next() { - i += 1; - if ( FLG || i >= len ) { - return { - 'done': true - }; - } - return { - 'value': [ i, fromWord( buf[ i ] ) ], - 'done': false - }; - } - - /** - * Finishes an iterator. - * - * @private - * @param {*} [value] - value to return - * @returns {Object} iterator protocol-compliant object - */ - function end( value ) { - FLG = true; - if ( arguments.length ) { - return { - 'value': value, - 'done': true - }; - } - return { - 'done': true - }; - } - - /** - * Returns a new iterator. - * - * @private - * @returns {Iterator} iterator - */ - function factory() { - return self.entries(); - } -}); - -/** -* Tests whether all elements in an array pass a test implemented by a predicate function. -* -* @name every -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - predicate function execution context -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a function -* @returns {boolean} boolean indicating whether all elements pass a test -* -* @example -* function predicate( v ) { -* return v === 0.0; -* } -* -* var arr = new Float16Array( 3 ); -* -* var bool = arr.every( predicate ); -* // returns true -*/ -setReadOnly( Float16Array.prototype, 'every', function every( predicate, thisArg ) { - var buf; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'null3c', predicate ) ); - } - buf = this._buffer; - for ( i = 0; i < this._length; i++ ) { - if ( !predicate.call( thisArg, fromWord( buf[ i ] ), i, this ) ) { - return false; - } - } - return true; -}); - -/** -* Returns a modified typed array filled with a fill value. -* -* @name fill -* @memberof Float16Array.prototype -* @type {Function} -* @param {number} value - fill value -* @param {integer} [start=0] - starting index (inclusive) -* @param {integer} [end] - ending index (exclusive) -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a floating-point number -* @throws {TypeError} second argument must be an integer -* @throws {TypeError} third argument must be an integer -* @returns {Float16Array} modified array -* -* @example -* var arr = new Float16Array( 3 ); -* -* arr.fill( 1.0, 1 ); -* -* var v = arr[ 0 ]; -* // returns 0.0 -* -* v = arr[ 1 ]; -* // returns 1.0 -* -* v = arr[ 2 ]; -* // returns 1.0 -*/ -setReadOnly( Float16Array.prototype, 'fill', function fill( value, start, end ) { - var buf; - var len; - var i; - var v; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isNumber( value ) ) { - throw new TypeError( format( 'null49', value ) ); - } - buf = this._buffer; - len = this._length; - if ( arguments.length > 1 ) { - if ( !isInteger( start ) ) { - throw new TypeError( format( 'null7f', start ) ); - } - if ( start < 0 ) { - start += len; - if ( start < 0 ) { - start = 0; - } - } - if ( arguments.length > 2 ) { - if ( !isInteger( end ) ) { - throw new TypeError( format( 'null2z', end ) ); - } - if ( end < 0 ) { - end += len; - if ( end < 0 ) { - end = 0; - } - } - if ( end > len ) { - end = len; - } - } else { - end = len; - } - } else { - start = 0; - end = len; - } - v = toWord( value ); - for ( i = start; i < end; i++ ) { - buf[ i ] = v; - } - return this; -}); - -/** -* Returns a new array containing the elements of an array which pass a test implemented by a predicate function. -* -* @name filter -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} predicate - test function -* @param {*} [thisArg] - predicate function execution context -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a function -* @returns {Float16Array} floating-point number array -* -* @example -* function predicate( v ) { -* return ( v === 0.0 ); -* } -* -* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] ); -* -* var out = arr.filter( predicate ); -* // returns -* -* var len = out.length; -* // returns 2 -* -* var v = out[ 0 ]; -* // returns 0.0 -* -* v = out[ 1 ]; -* // returns 0.0 -*/ -setReadOnly( Float16Array.prototype, 'filter', function filter( predicate, thisArg ) { - var buf; - var out; - var i; - var v; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'null3c', predicate ) ); - } - buf = this._buffer; - out = []; - for ( i = 0; i < this._length; i++ ) { - v = fromWord( buf[ i ] ); - if ( predicate.call( thisArg, v, i, this ) ) { - out.push( v ); - } - } - return new this.constructor( out ); -}); - -/** -* Returns the first element in an array for which a predicate function returns a truthy value. -* -* @name find -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - predicate function execution context -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a function -* @returns {(boolean|void)} array element or undefined -* -* @example -* function predicate( v ) { -* return v > 0.0; -* } -* -* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] ); -* -* var v = arr.find( predicate ); -* // returns 1.0 -*/ -setReadOnly( Float16Array.prototype, 'find', function find( predicate, thisArg ) { - var buf; - var v; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'null3c', predicate ) ); - } - buf = this._buffer; - for ( i = 0; i < this._length; i++ ) { - v = fromWord( buf[ i ] ); - if ( predicate.call( thisArg, v, i, this ) ) { - return v; - } - } -}); - -/** -* Returns the index of the first element in an array for which a predicate function returns a truthy value. -* -* @name findIndex -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - predicate function execution context -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a function -* @returns {integer} index or -1 -* -* @example -* function predicate( v ) { -* return v > 0.0; -* } -* -* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] ); -* -* var v = arr.findIndex( predicate ); -* // returns 1 -*/ -setReadOnly( Float16Array.prototype, 'findIndex', function findIndex( predicate, thisArg ) { - var buf; - var v; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'null3c', predicate ) ); - } - buf = this._buffer; - for ( i = 0; i < this._length; i++ ) { - v = fromWord( buf[ i ] ); - if ( predicate.call( thisArg, v, i, this ) ) { - return i; - } - } - return -1; -}); - -/** -* Returns the last element in an array for which a predicate function returns a truthy value. -* -* @name findLast -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - predicate function execution context -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a function -* @returns {(boolean|void)} array element or undefined -* -* @example -* function predicate( v ) { -* return v > 0.0; -* } -* -* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] ); -* -* var v = arr.findLast( predicate ); -* // returns 1.0 -*/ -setReadOnly( Float16Array.prototype, 'findLast', function findLast( predicate, thisArg ) { - var buf; - var v; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'null3c', predicate ) ); - } - buf = this._buffer; - for ( i = this._length-1; i >= 0; i-- ) { - v = fromWord( buf[ i ] ); - if ( predicate.call( thisArg, v, i, this ) ) { - return v; - } - } -}); - -/** -* Returns the index of the last element in an array for which a predicate function returns a truthy value. -* -* @name findLastIndex -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - predicate function execution context -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a function -* @returns {integer} index or -1 -* -* @example -* function predicate( v ) { -* return v > 0.0; -* } -* -* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] ); -* -* var v = arr.findLastIndex( predicate ); -* // returns 1 -*/ -setReadOnly( Float16Array.prototype, 'findLastIndex', function findLastIndex( predicate, thisArg ) { - var buf; - var v; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'null3c', predicate ) ); - } - buf = this._buffer; - for ( i = this._length-1; i >= 0; i-- ) { - v = fromWord( buf[ i ] ); - if ( predicate.call( thisArg, v, i, this ) ) { - return i; - } - } - return -1; -}); - -/** -* Invokes a function once for each array element. -* -* @name forEach -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} fcn - function to invoke -* @param {*} [thisArg] - function invocation context -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a function -* -* @example -* function log( v, i ) { -* console.log( '%s: %s', i, v.toString() ); -* } -* -* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] ); -* -* arr.forEach( log ); -*/ -setReadOnly( Float16Array.prototype, 'forEach', function forEach( fcn, thisArg ) { - var buf; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'null3c', fcn ) ); - } - buf = this._buffer; - for ( i = 0; i < this._length; i++ ) { - fcn.call( thisArg, fromWord( buf[ i ] ), i, this ); - } -}); - -/** -* Returns an array element. -* -* @private -* @name _get -* @memberof Float16Array.prototype -* @type {Function} -* @param {NonNegativeInteger} idx - element index -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} must provide a nonnegative integer -* @returns {(number|void)} array element -*/ -setReadOnly( Float16Array.prototype, '_get', function get( idx ) { - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isNonNegativeInteger( idx ) ) { - throw new TypeError( format( 'null2K', idx ) ); - } - if ( idx >= this._length ) { - return; - } - return fromWord( this._buffer[ idx ] ); -}); - -/** -* Returns a boolean indicating whether an array includes a provided value. -* -* @name includes -* @memberof Float16Array.prototype -* @type {Function} -* @param {number} searchElement - search element -* @param {integer} [fromIndex=0] - starting index (inclusive) -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a floating-point number -* @throws {TypeError} second argument must be an integer -* @returns {boolean} boolean indicating whether an array includes a value -* -* @example -* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] ); -* -* var bool = arr.includes( 1.0 ); -* // returns true -* -* bool = arr.includes( 1.0, 2 ); -* // returns false -* -* bool = arr.includes( 5.0 ); -* // returns false -*/ -setReadOnly( Float16Array.prototype, 'includes', function includes( searchElement, fromIndex ) { - var buf; - var i; - var v; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isNumber( searchElement ) ) { - throw new TypeError( format( 'null49', searchElement ) ); - } - if ( arguments.length > 1 ) { - if ( !isInteger( fromIndex ) ) { - throw new TypeError( format( 'null7f', fromIndex ) ); - } - if ( fromIndex < 0 ) { - fromIndex += this._length; - if ( fromIndex < 0 ) { - fromIndex = 0; - } - } - } else { - fromIndex = 0; - } - buf = this._buffer; - v = toWord( searchElement ); - for ( i = fromIndex; i < this._length; i++ ) { - if ( v === buf[ i ] ) { - return true; - } - } - return false; -}); - -/** -* Returns the first index at which a given element can be found. -* -* @name indexOf -* @memberof Float16Array.prototype -* @type {Function} -* @param {float16} searchElement - element to find -* @param {integer} [fromIndex=0] - starting index (inclusive) -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a floating-point number -* @throws {TypeError} second argument must be an integer -* @returns {integer} index or -1 -* -* @example -* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] ); -* -* var idx = arr.indexOf( 2.0 ); -* // returns 2 -* -* idx = arr.indexOf( 2.0, 3 ); -* // returns -1 -* -* idx = arr.indexOf( 3.0, 3 ); -* // returns 3 -*/ -setReadOnly( Float16Array.prototype, 'indexOf', function indexOf( searchElement, fromIndex ) { - var buf; - var i; - var v; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isNumber( searchElement ) ) { - throw new TypeError( format( 'null49', searchElement ) ); - } - if ( arguments.length > 1 ) { - if ( !isInteger( fromIndex ) ) { - throw new TypeError( format( 'null7f', fromIndex ) ); - } - if ( fromIndex < 0 ) { - fromIndex += this._length; - if ( fromIndex < 0 ) { - fromIndex = 0; - } - } - } else { - fromIndex = 0; - } - buf = this._buffer; - v = toWord( searchElement ); - for ( i = fromIndex; i < this._length; i++ ) { - if ( v === buf[ i ] ) { - return i; - } - } - return -1; -}); - -/** -* Returns a new string by concatenating all array elements. -* -* @name join -* @memberof Float16Array.prototype -* @type {Function} -* @param {string} [separator=','] - element separator -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a string -* @returns {string} string representation -* -* @example -* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] ); -* -* var str = arr.join(); -* // returns '0,1,2' -* -* str = arr.join( '|' ); -* // returns '0|1|2' -*/ -setReadOnly( Float16Array.prototype, 'join', function join( separator ) { - var buf; - var out; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( arguments.length > 0 ) { - if ( !isString( separator ) ) { - throw new TypeError( format( 'null3F', separator ) ); - } - } else { - separator = ','; - } - buf = this._buffer; - out = []; - for ( i = 0; i < this._length; i++ ) { - out.push( fromWord( buf[ i ] ) ); - } - return out.join( separator ); -}); - -/** -* Returns an iterator for iterating over each index key in a typed array. -* -* @name keys -* @memberof Float16Array.prototype -* @type {Function} -* @throws {TypeError} `this` must be a floating-point number array -* @returns {Iterator} iterator -* -* @example -* var arr = new Float16Array( [ 1.0, 2.0 ] ); -* -* var iter = arr.keys(); -* -* var v = iter.next().value; -* // returns 0 -* -* v = iter.next().value; -* // returns 1 -* -* var bool = iter.next().done; -* // returns true -*/ -setReadOnly( Float16Array.prototype, 'keys', function keys() { - var self; - var iter; - var len; - var FLG; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - self = this; - len = this._length; - - // Initialize an iteration index: - i = -1; - - // Create an iterator protocol-compliant object: - iter = {}; - setReadOnly( iter, 'next', next ); - setReadOnly( iter, 'return', end ); - - if ( ITERATOR_SYMBOL ) { - setReadOnly( iter, ITERATOR_SYMBOL, factory ); - } - return iter; - - /** - * Returns an iterator protocol-compliant object containing the next iterated value. - * - * @private - * @returns {Object} iterator protocol-compliant object - */ - function next() { - i += 1; - if ( FLG || i >= len ) { - return { - 'done': true - }; - } - return { - 'value': i, - 'done': false - }; - } - - /** - * Finishes an iterator. - * - * @private - * @param {*} [value] - value to return - * @returns {Object} iterator protocol-compliant object - */ - function end( value ) { - FLG = true; - if ( arguments.length ) { - return { - 'value': value, - 'done': true - }; - } - return { - 'done': true - }; - } - - /** - * Returns a new iterator. - * - * @private - * @returns {Iterator} iterator - */ - function factory() { - return self.keys(); - } -}); - -/** -* Returns the last index at which a given element can be found. -* -* @name lastIndexOf -* @memberof Float16Array.prototype -* @type {Function} -* @param {number} searchElement - element to find -* @param {integer} [fromIndex] - starting index (inclusive) -* @throws {TypeError} `this` must be a floating-point number -* @throws {TypeError} first argument must be a numeric value -* @throws {TypeError} second argument must be an integer -* @returns {integer} index or -1 -* -* @example -* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 2.0 ] ); -* -* var idx = arr.lastIndexOf( 2.0 ); -* // returns 4 -* -* idx = arr.lastIndexOf( 2.0, 3 ); -* // returns 2 -* -* idx = arr.lastIndexOf( 4.0, 3 ); -* // returns -1 -* -* idx = arr.lastIndexOf( 1.0, -3 ); -* // returns 1 -*/ -setReadOnly( Float16Array.prototype, 'lastIndexOf', function lastIndexOf( searchElement, fromIndex ) { - var buf; - var i; - var v; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isNumber( searchElement ) ) { - throw new TypeError( format( 'null49', searchElement ) ); - } - if ( arguments.length > 1 ) { - if ( !isInteger( fromIndex ) ) { - throw new TypeError( format( 'null7f', fromIndex ) ); - } - if ( fromIndex >= this._length ) { - fromIndex = this._length - 1; - } else if ( fromIndex < 0 ) { - fromIndex += this._length; - } - } else { - fromIndex = this._length - 1; - } - buf = this._buffer; - v = toWord( searchElement ); - for ( i = fromIndex; i >= 0; i-- ) { - if ( v === buf[ i ] ) { - return i; - } - } - return -1; -}); - -/** -* Number of array elements. -* -* @name length -* @memberof Float16Array.prototype -* @readonly -* @type {NonNegativeInteger} -* -* @example -* var arr = new Float16Array( 10 ); -* -* var len = arr.length; -* // returns 10 -*/ -setReadOnlyAccessor( Float16Array.prototype, 'length', function get() { - return this._length; -}); - -/** -* Returns a new array with each element being the result of a provided callback function. -* -* @name map -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} fcn - callback function -* @param {*} [thisArg] - callback function execution context -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a function -* @returns {Float16Array} new floating-point number array -* -* @example -* function scale( v ) { -* return v * 2.0; -* } -* -* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] ); -* -* var out = arr.map( scale ); -* // returns -* -* var z = out[ 0 ]; -* // returns 0.0 -* -* z = out[ 1 ]; -* // returns 2.0 -* -* z = out[ 2 ]; -* // returns 4.0 -*/ -setReadOnly( Float16Array.prototype, 'map', function map( fcn, thisArg ) { - var outbuf; - var out; - var buf; - var i; - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( format('null3c'), fcn ); - } - buf = this._buffer; - out = new this.constructor( this._length ); - outbuf = out._buffer; // eslint-disable-line no-underscore-dangle - for ( i = 0; i < this._length; i++ ) { - outbuf[ i ] = toWord( fcn.call( thisArg, fromWord( buf[ i ] ), i, this ) ); // eslint-disable-line max-len - } - return out; -}); - -/** -* Applies a provided callback function to each element of the array, in order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion. -* -* @name reduce -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} reducer - callback function -* @param {*} [initialValue] - initial value -* @throws {TypeError} `this` must be a floating-point number array -* @throws {Error} if not provided an initial value, the array must have at least one element -* @returns {*} accumulated result -* -* @example -* function add( acc, v ) { -* return acc + v; -* } -* -* var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); -* -* var out = arr.reduce( add, 0 ); -* // returns 6.0 -*/ -setReadOnly( Float16Array.prototype, 'reduce', function reduce( reducer, initialValue ) { - var buf; - var len; - var acc; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isFunction( reducer ) ) { - throw new TypeError( format( 'null3c', reducer ) ); - } - buf = this._buffer; - len = this._length; - if ( arguments.length > 1 ) { - acc = initialValue; - i = 0; - } else { - if ( len === 0 ) { - throw new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' ); - } - acc = fromWord( buf[ 0 ] ); - i = 1; - } - for ( ; i < len; i++ ) { - acc = reducer( acc, fromWord( buf[ i ] ), i, this ); - } - return acc; -}); - -/** -* Applies a provided callback function to each element of the array, in reverse order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion. -* -* @name reduceRight -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} reducer - callback function -* @param {*} [initialValue] - initial value -* @throws {TypeError} `this` must be a floating-point number array -* @throws {Error} if not provided an initial value, the array must have at least one element -* @returns {*} accumulated result -* -* @example -* function add( acc, v ) { -* return acc + v; -* } -* -* var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); -* -* var out = arr.reduceRight( add, 0 ); -* // returns 6.0 -*/ -setReadOnly( Float16Array.prototype, 'reduceRight', function reduceRight( reducer, initialValue ) { - var buf; - var len; - var acc; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isFunction( reducer ) ) { - throw new TypeError( format( 'null3c', reducer ) ); - } - buf = this._buffer; - len = this._length; - if ( arguments.length > 1 ) { - acc = initialValue; - i = len - 1; - } else { - if ( len === 0 ) { - throw new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' ); - } - acc = fromWord( buf[ len-1 ] ); - i = len - 2; - } - for ( ; i >= 0; i-- ) { - acc = reducer( acc, fromWord( buf[ i ] ), i, this ); - } - return acc; -}); - -/** -* Reverses an array in-place. -* -* @name reverse -* @memberof Float16Array.prototype -* @type {Function} -* @throws {TypeError} `this` must be a floating-point number array -* @returns {Float16Array} reversed array -* -* @example -* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] ); -* -* var out = arr.reverse(); -* // returns -* -* var v = out[ 0 ]; -* // returns 2.0 -* -* v = out[ 1 ]; -* // returns 1.0 -* -* v = out[ 2 ]; -* // returns 0.0 -*/ -setReadOnly( Float16Array.prototype, 'reverse', function reverse() { - var buf; - var tmp; - var len; - var N; - var i; - var j; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number 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 one or more array elements. -* -* ## Notes -* -* - When provided a typed array, we must check whether the source array shares the same buffer as the target array and whether the underlying memory overlaps. In particular, we are concerned with the following scenario: -* -* ```text -* buf: --------------------- -* src: --------------------- -* ``` -* -* In the above, as we copy values from `src`, we will overwrite values in the `src` view, resulting in duplicated values copied into the end of `buf`, which is not intended. Hence, to avoid overwriting source values, we must **copy** source values to a temporary array. -* -* In the other overlapping scenario, -* -* ```text -* buf: --------------------- -* src: --------------------- -* ``` -* -* by the time we begin copying into the overlapping region, we are copying from the end of `src`, a non-overlapping region, which means we don't run the risk of copying copied values, rather than the original `src` values, as intended. -* -* @name set -* @memberof Float16Array.prototype -* @type {Function} -* @param {(Collection|Float16Array)} value - value(s) -* @param {NonNegativeInteger} [i=0] - element index at which to start writing values -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a collection -* @throws {TypeError} index argument must be a nonnegative integer -* @throws {RangeError} index argument is out-of-bounds -* @throws {RangeError} target array lacks sufficient storage to accommodate source values -* @returns {void} -* -* @example -* var arr = new Float16Array( 10 ); -* -* var v = arr[ 0 ]; -* // returns 0.0 -* -* arr.set( [ 1.0, 2.0 ], 0 ); -* -* v = arr[ 0 ]; -* // returns 1.0 -*/ -setReadOnly( Float16Array.prototype, 'set', function set( value ) { - var sbuf; - var idx; - var buf; - var tmp; - var flg; - var N; - var i; - var j; - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isCollection( value ) ) { - throw new TypeError( format( 'null2O', value ) ); - } - buf = this._buffer; - if ( arguments.length > 1 ) { - idx = arguments[ 1 ]; - if ( !isNonNegativeInteger( idx ) ) { - throw new TypeError( format( 'null2L', idx ) ); - } - } else { - idx = 0; - } - N = value.length; - if ( idx+N > this._length ) { - throw new RangeError( format('null03') ); - } - if ( isFloat16Array( value ) ) { - sbuf = value._buffer; // eslint-disable-line no-underscore-dangle - flg = true; - } else { - sbuf = value; - flg = false; - } - // Check for overlapping memory... - j = buf.byteOffset + (idx*BYTES_PER_ELEMENT); - if ( - sbuf.buffer === buf.buffer && - ( - sbuf.byteOffset < j && - sbuf.byteOffset+sbuf.byteLength > j - ) - ) { - // We need to copy source values... - tmp = new Uint16Array( sbuf.length ); - for ( i = 0; i < sbuf.length; i++ ) { - tmp[ i ] = sbuf[ i ]; - } - sbuf = tmp; - } - if ( flg ) { - for ( i = 0; i < N; idx++, i++ ) { - buf[ idx ] = sbuf[ i ]; - } - } else { - for ( i = 0; i < N; idx++, i++ ) { - buf[ idx ] = toWord( sbuf[ i ] ); - } - } -}); - -/** -* Copies a portion of a typed array to a new typed array. -* -* @name slice -* @memberof Float16Array.prototype -* @type {Function} -* @param {integer} [begin] - start index (inclusive) -* @param {integer} [end] - end index (exclusive) -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be integer -* @throws {TypeError} second argument must be integer -* @returns {Float16Array} floating-point number array -* -* @example -* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] ); -* -* var out = arr.slice(); -* // returns -* -* var len = out.length; -* // returns 5 -* -* var v = out[ 0 ]; -* // returns 0.0 -* -* v = out[ len-1 ]; -* // returns 4.0 -* -* out = arr.slice( 1, -2 ); -* // returns -* -* len = out.length; -* // returns 2 -* -* v = out[ 0 ]; -* // returns 1.0 -* -* v = out[ len-1 ]; -* // returns 2.0 -*/ -setReadOnly( Float16Array.prototype, 'slice', function slice( begin, end ) { - var outlen; - var outbuf; - var out; - var buf; - var len; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - buf = this._buffer; - len = this._length; - if ( arguments.length === 0 ) { - begin = 0; - end = len; - } else { - if ( !isInteger( begin ) ) { - throw new TypeError( format( 'null7e', begin ) ); - } - if ( begin < 0 ) { - begin += len; - if ( begin < 0 ) { - begin = 0; - } - } - if ( arguments.length === 1 ) { - end = len; - } else { - if ( !isInteger( end ) ) { - throw new TypeError( format( 'null7f', end ) ); - } - if ( end < 0 ) { - end += len; - if ( end < 0 ) { - end = 0; - } - } else if ( end > len ) { - end = len; - } - } - } - if ( begin < end ) { - outlen = end - begin; - } else { - outlen = 0; - } - out = new this.constructor( outlen ); - outbuf = out._buffer; // eslint-disable-line no-underscore-dangle - for ( i = 0; i < outlen; i++ ) { - outbuf[ i ] = buf[ i+begin ]; - } - return out; -}); - -/** -* Tests whether at least one element in an array passes a test implemented by a predicate function. -* -* @name some -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - predicate function execution context -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a function -* @returns {boolean} boolean indicating whether at least one element passes a test -* -* @example -* function predicate( v ) { -* return v > 0.0; -* } -* -* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] ); -* -* var bool = arr.some( predicate ); -* // returns true -*/ -setReadOnly( Float16Array.prototype, 'some', function some( predicate, thisArg ) { - var buf; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'null3c', predicate ) ); - } - buf = this._buffer; - for ( i = 0; i < this._length; i++ ) { - if ( predicate.call( thisArg, fromWord( buf[ i ] ), i, this ) ) { - return true; - } - } - return false; -}); - -/** -* Sorts an array in-place. -* -* @name sort -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} [compareFcn] - comparison function -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a function -* @returns {Float16Array} sorted array -* -* @example -* function compare( a, b ) { -* if ( a < b ) { -* return -1; -* } -* if ( a > b ) { -* return 1; -* } -* return 0; -* } -* -* var arr = new Float16Array( [ 1.0, 0.0, 2.0 ] ); -* -* arr.sort( compare ); -* -* var v = arr[ 0 ]; -* // returns 0.0 -* -* v = arr[ 1 ]; -* // returns 1.0 -* -* v = arr[ 2 ]; -* // returns 2.0 -*/ -setReadOnly( Float16Array.prototype, 'sort', function sort( compareFcn ) { - var buf; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - buf = this._buffer; - if ( arguments.length === 0 ) { - buf.sort( defaultCompare ); - return this; - } - if ( !isFunction( compareFcn ) ) { - throw new TypeError( format( 'null3c', compareFcn ) ); - } - buf.sort( compare ); - return this; - - /** - * Default comparison function for float16 values. - * - * @private - * @param {unsigned16} a - unsigned 16-bit integer for comparison - * @param {unsigned16} b - unsigned 16-bit integer for comparison - * @returns {number} comparison result - */ - function defaultCompare( a, b ) { // eslint-disable-line stdlib/no-unnecessary-nested-functions - var x = fromWord( a ); - var y = fromWord( b ); - - // Handle NaN... - if ( isnan( x ) && isnan( y ) ) { - return 0; - } - if ( isnan( x ) ) { - return 1; - } - if ( isnan( y ) ) { - return -1; - } - // Normal comparison - if ( x < y ) { - return -1; - } - if ( x > y ) { - return 1; - } - return 0; - } - - /** - * Comparison function wrapper. - * - * @private - * @param {unsigned16} a - unsigned 16-bit integer for comparison - * @param {unsigned16} b - unsigned 16-bit integer for comparison - * @returns {number} comparison result - */ - function compare( a, b ) { - return compareFcn( fromWord( a ), fromWord( b ) ); - } -}); - -/** -* Creates a new typed array view over the same underlying `ArrayBuffer` and with the same underlying data type as the host array. -* -* @name subarray -* @memberof Float16Array.prototype -* @type {Function} -* @param {integer} [begin] - start index (inclusive) -* @param {integer} [end] - end index (exclusive) -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be an integer -* @throws {TypeError} second argument must be an integer -* @returns {Float16Array} subarray -* -* @example -* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] ); -* -* var subarr = arr.subarray(); -* // returns -* -* var len = subarr.length; -* // returns 5 -* -* var bool = subarr[ 0 ]; -* // returns 0.0 -* -* bool = subarr[ len-1 ]; -* // returns 4.0 -* -* subarr = arr.subarray( 1, -2 ); -* // returns -* -* len = subarr.length; -* // returns 2 -* -* bool = subarr[ 0 ]; -* // returns 1.0 -* -* bool = subarr[ len-1 ]; -* // returns 2.0 -*/ -setReadOnly( Float16Array.prototype, 'subarray', function subarray( begin, end ) { - var offset; - var buf; - var len; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - buf = this._buffer; - len = this._length; - if ( arguments.length === 0 ) { - begin = 0; - end = len; - } else { - if ( !isInteger( begin ) ) { - throw new TypeError( format( 'null7e', begin ) ); - } - if ( begin < 0 ) { - begin += len; - if ( begin < 0 ) { - begin = 0; - } - } - if ( arguments.length === 1 ) { - end = len; - } else { - if ( !isInteger( end ) ) { - throw new TypeError( format( 'null7f', end ) ); - } - if ( end < 0 ) { - end += len; - if ( end < 0 ) { - end = 0; - } - } else if ( end > len ) { - end = len; - } - } - } - if ( begin >= len ) { - len = 0; - offset = buf.byteLength; - } else if ( begin >= end ) { - len = 0; - offset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT ); - } else { - len = end - begin; - offset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT ); - } - return new this.constructor( buf.buffer, offset, ( len < 0 ) ? 0 : len ); -}); - -/** -* Serializes an array as a locale-specific string. -* -* @name toLocaleString -* @memberof Float16Array.prototype -* @type {Function} -* @param {(string|Array)} [locales] - locale identifier(s) -* @param {Object} [options] - configuration options -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a string or an array of strings -* @throws {TypeError} options argument must be an object -* @returns {string} string representation -* -* @example -* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] ); -* -* var str = arr.toLocaleString(); -* // returns '0,1,2' -*/ -setReadOnly( Float16Array.prototype, 'toLocaleString', function toLocaleString( locales, options ) { - var opts; - var loc; - var out; - var buf; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( arguments.length === 0 ) { - loc = []; - } else if ( isString( locales ) || isStringArray( locales ) ) { - loc = locales; - } else { - throw new TypeError( format( 'invalid argument. First argument must be a string or an array of strings. Value: `%s`.', locales ) ); - } - if ( arguments.length < 2 ) { - opts = {}; - } else if ( isObject( options ) ) { - opts = options; - } else { - throw new TypeError( format( 'null2V', options ) ); - } - buf = this._buffer; - out = []; - for ( i = 0; i < this._length; i++ ) { - out.push( fromWord( buf[ i ] ) ); - } - return out.toLocaleString( loc, opts ); -}); - -/** -* Returns a new typed array containing the elements in reversed order. -* -* @name toReversed -* @memberof Float16Array.prototype -* @type {Function} -* @throws {TypeError} `this` must be a floating-point number array -* @returns {Float16Array} reversed array -* -* @example -* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] ); -* -* var out = arr.toReversed(); -* // returns -* -* var v = out[ 0 ]; -* // returns 2.0 -* -* v = out[ 1 ]; -* // returns 1.0 -* -* v = out[ 2 ]; -* // returns 0.0 -*/ -setReadOnly( Float16Array.prototype, 'toReversed', function toReversed() { - var outbuf; - var out; - var len; - var buf; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number 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; -}); - -/** -* Returns a new typed array containing the elements in sorted order. -* -* @name toSorted -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} [compareFcn] - comparison function -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a function -* @returns {Float16Array} sorted array -* -* @example -* function compare( a, b ) { -* if ( a > b ) { -* return 1; -* } -* if ( a < b ) { -* return -1; -* } -* return 0; -* } -* -* var arr = new Float16Array( [ 2.0, 0.0, 1.0 ] ); -* -* var out = arr.toSorted( compare ); -* // returns -* -* var v = out[ 0 ]; -* // returns 0.0 -* -* v = out[ 1 ]; -* // returns 1.0 -* -* v = out[ 2 ]; -* // returns 2.0 -*/ -setReadOnly( Float16Array.prototype, 'toSorted', function toSorted( compareFcn ) { - var out; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - out = new this.constructor( this ); - if ( arguments.length === 0 ) { - return out.sort(); - } - return out.sort( compareFcn ); -}); - -/** -* Serializes an array as a string. -* -* @name toString -* @memberof Float16Array.prototype -* @type {Function} -* @throws {TypeError} `this` must be a floating-point number array -* @returns {string} string representation -* -* @example -* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] ); -* -* var str = arr.toString(); -* // returns '0,1,2' -*/ -setReadOnly( Float16Array.prototype, 'toString', function toString() { - var out; - var buf; - var i; - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - buf = this._buffer; - out = []; - for ( i = 0; i < this._length; i++ ) { - out.push( fromWord( buf[ i ] ) ); - } - return out.join( ',' ); -}); - -/** -* Returns an iterator for iterating over each value in a typed array. -* -* @name values -* @memberof Float16Array.prototype -* @type {Function} -* @throws {TypeError} `this` must be a floating-point number array -* @returns {Iterator} iterator -* -* @example -* var arr = new Float16Array( [ 0.0, 1.0 ] ); -* -* var iter = arr.values(); -* -* var v = iter.next().value; -* // returns 0.0 -* -* v = iter.next().value; -* // returns 1.0 -* -* var bool = iter.next().done; -* // returns true -*/ -setReadOnly( Float16Array.prototype, 'values', function values() { - var iter; - var self; - var len; - var FLG; - var buf; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - self = this; - buf = this._buffer; - len = this._length; - - // Initialize an iteration index: - i = -1; - - // Create an iterator protocol-compliant object: - iter = {}; - setReadOnly( iter, 'next', next ); - setReadOnly( iter, 'return', end ); - - if ( ITERATOR_SYMBOL ) { - setReadOnly( iter, ITERATOR_SYMBOL, factory ); - } - return iter; - - /** - * Returns an iterator protocol-compliant object containing the next iterated value. - * - * @private - * @returns {Object} iterator protocol-compliant object - */ - function next() { - i += 1; - if ( FLG || i >= len ) { - return { - 'done': true - }; - } - return { - 'value': fromWord( buf[ i ] ), - 'done': false - }; - } - - /** - * Finishes an iterator. - * - * @private - * @param {*} [value] - value to return - * @returns {Object} iterator protocol-compliant object - */ - function end( value ) { - FLG = true; - if ( arguments.length ) { - return { - 'value': value, - 'done': true - }; - } - return { - 'done': true - }; - } - - /** - * Returns a new iterator. - * - * @private - * @returns {Iterator} iterator - */ - function factory() { - return self.values(); - } -}); - -/** -* Returns a new typed array with the element at a provided index replaced with a provided value. -* -* @name with -* @memberof Float16Array.prototype -* @type {Function} -* @param {integer} index - element index -* @param {number} value - new value -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be an integer -* @throws {RangeError} index argument is out-of-bounds -* @throws {TypeError} second argument must be a floating-point number -* @returns {Float16Array} new typed array -* -* @example -* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] ); -* -* var out = arr.with( 0, 3.0 ); -* // returns -* -* var v = out[ 0 ]; -* // returns 3.0 -*/ -setReadOnly( Float16Array.prototype, 'with', function copyWith( index, value ) { - var out; - var len; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isInteger( index ) ) { - throw new TypeError( format( 'null7e', index ) ); - } - len = this._length; - if ( index < 0 ) { - index += len; - } - if ( index < 0 || index >= len ) { - throw new RangeError( format( 'nullFP', index ) ); - } - if ( !isNumber( value ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a floating-point number. Value: `%s`.', value ) ); - } - out = new this.constructor( this ); - out[ index ] = value; - return out; -}); - - -// EXPORTS // - -module.exports = Float16Array; diff --git a/package.json b/package.json index 476464f..953c789 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.0", "description": "Float16Array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib/index.js", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,65 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-uint16": "^0.2.3", - "@stdlib/assert-has-float16array-support": "^0.1.1", - "@stdlib/assert-has-iterator-symbol-support": "^0.2.3", - "@stdlib/assert-is-arraybuffer": "^0.2.3", - "@stdlib/assert-is-collection": "^0.2.3", - "@stdlib/assert-is-function": "^0.2.3", - "@stdlib/assert-is-integer": "^0.2.3", - "@stdlib/assert-is-nonnegative-integer": "^0.2.3", - "@stdlib/assert-is-number": "^0.2.3", - "@stdlib/assert-is-object": "^0.2.3", - "@stdlib/assert-is-string": "^0.2.3", - "@stdlib/assert-is-string-array": "^0.2.3", - "@stdlib/blas-base-gcopy": "^0.2.3", - "@stdlib/math-base-assert-is-nan": "^0.2.3", - "@stdlib/math-base-special-floor": "^0.2.4", - "@stdlib/number-float16-base-from-word": "^0.2.1", - "@stdlib/number-float16-base-to-word": "^0.1.1", - "@stdlib/number-float64-base-to-float16": "^0.1.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/symbol-iterator": "^0.2.3", - "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.4", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", - "@stdlib/utils-define-read-write-accessor": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.2.3", - "@stdlib/assert-has-own-property": "^0.2.3", - "@stdlib/assert-instance-of": "^0.3.1", - "@stdlib/assert-is-array": "^0.2.3", - "@stdlib/assert-is-boolean": "^0.2.3", - "@stdlib/assert-is-iterator-like": "^0.2.3", - "@stdlib/console-log-each": "^0.2.4", - "@stdlib/math-base-special-pow": "^0.3.1", - "@stdlib/random-array-uniform": "^0.2.2", - "@stdlib/utils-identity-function": "^0.2.3", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..41ab3bb --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 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 main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/polyfill/test.at.js b/test/polyfill/test.at.js deleted file mode 100644 index 2cd65c2..0000000 --- a/test/polyfill/test.at.js +++ /dev/null @@ -1,144 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `at` method for returning an array element', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'at' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.at ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.at.call( value, 0 ); - }; - } -}); - -tape( 'the method throws an error if provided an index argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - 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.at( value ); - }; - } -}); - -tape( 'the method returns `undefined` if provided an index which exceeds array dimensions', function test( t ) { - var arr; - var v; - var i; - - arr = new Float16Array( 10 ); - for ( i = -arr.length; i < arr.length; i++ ) { - if ( i < 0 ) { - v = arr.at( i-arr.length ); - t.strictEqual( v, void 0, 'returns expected value for index '+(i-arr.length) ); - } else { - v = arr.at( arr.length+i ); - t.strictEqual( v, void 0, 'returns expected value for index '+(arr.length+i) ); - } - } - t.end(); -}); - -tape( 'the method returns an array element', function test( t ) { - var arr; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( i+0.05 ); - } - - arr = new Float16Array( arr ); - - for ( i = -arr.length; i < arr.length; i++ ) { - v = arr.at( i ); - if ( i < 0 ) { - t.strictEqual( v, float64ToFloat16( arr.length + i + 0.05 ), 'returns expected value for index '+i ); - } else { - t.strictEqual( v, float64ToFloat16( i + 0.05 ), 'returns expected value for index '+i ); - } - } - t.end(); -}); diff --git a/test/polyfill/test.copy_within.js b/test/polyfill/test.copy_within.js deleted file mode 100644 index 0a8eb57..0000000 --- a/test/polyfill/test.copy_within.js +++ /dev/null @@ -1,281 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 Uint16Array = require( '@stdlib/array-uint16' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `copyWithin` method for copying a sequence of array elements within a floating-point number array', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'copyWithin' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within an array', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( 0, 3 ); - buf = new Uint16Array( arr.buffer ); - - // Overwritten: - t.strictEqual( buf[ 0 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 4.05 ), 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 2 ], toWord( 2.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (negative target)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( -arr.length, 3 ); - buf = new Uint16Array( arr.buffer ); - - // Overwritten: - t.strictEqual( buf[ 0 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 4.05 ), 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 2 ], toWord( 2.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (negative start)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( 0, -2 ); - buf = new Uint16Array( arr.buffer ); - - // Overwritten: - t.strictEqual( buf[ 0 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 4.05 ), 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 2 ], toWord( 2.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (end=length)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( 0, 3, arr.length ); - buf = new Uint16Array( arr.buffer ); - - // Overwritten: - t.strictEqual( buf[ 0 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 4.05 ), 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 2 ], toWord( 2.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (non-inclusive end)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( 2, 0, 2 ); - buf = new Uint16Array( arr.buffer ); - - // Remain the same: - t.strictEqual( buf[ 0 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - - // Overwritten: - t.strictEqual( buf[ 2 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 1.05 ), 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (negative end)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( 2, 0, -3 ); - buf = new Uint16Array( arr.buffer ); - - // Remain the same: - t.strictEqual( buf[ 0 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - - // Overwritten: - t.strictEqual( buf[ 2 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 1.05 ), 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (target >= length)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( arr.length, 3 ); - buf = new Uint16Array( arr.buffer ); - - // Remain the same: - t.strictEqual( buf[ 0 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 2 ], toWord( 2.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (target > start)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( 2, 0 ); - buf = new Uint16Array( arr.buffer ); - - // Remain the same: - t.strictEqual( buf[ 0 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - - // Overwritten: - t.strictEqual( buf[ 2 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 4 ], toWord( 2.05 ), 'returns expected value' ); - - t.end(); -}); diff --git a/test/polyfill/test.entries.js b/test/polyfill/test.entries.js deleted file mode 100644 index 4cea4d1..0000000 --- a/test/polyfill/test.entries.js +++ /dev/null @@ -1,238 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 proxyquire = require( 'proxyquire' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isNumber = require( '@stdlib/assert-is-number' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `entries` method for returning an iterator for iterating over array key-value pairs', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'entries' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.entries ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.entries.call( value ); - }; - } -}); - -tape( 'the method returns an iterator protocol-compliant object', function test( t ) { - var buf; - var arr; - var it; - var v; - var i; - - buf = [ 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( buf ); - - it = arr.entries(); - t.strictEqual( it.next.length, 0, 'has zero arity' ); - - for ( i = 0; i < arr.length; i++ ) { - v = it.next(); - t.strictEqual( isArray( v.value ), true, 'returns expected value' ); - t.strictEqual( v.value[ 0 ], i, 'returns expected value' ); - t.strictEqual( isNumber( v.value[ 1 ] ), true, 'returns expected value' ); - t.strictEqual( v.value[ 1 ], float64ToFloat16( buf[ i ] ), 'returns expected value' ); - t.strictEqual( typeof v.done, 'boolean', 'returns expected value' ); - } - t.end(); -}); - -tape( 'the method returns an iterator which has a `return` method for closing an iterator (no argument)', function test( t ) { - var buf; - var arr; - var it; - var v; - - buf = [ 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( buf ); - - it = arr.entries(); - - v = it.next(); - t.strictEqual( v.value[ 1 ], float64ToFloat16( buf[ 0 ] ), 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value[ 1 ], float64ToFloat16( buf[ 1 ] ), 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.return(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method returns an iterator which has a `return` method for closing an iterator (argument)', function test( t ) { - var buf; - var arr; - var it; - var v; - - buf = [ 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( buf ); - - it = arr.entries(); - - v = it.next(); - t.strictEqual( v.value[ 1 ], float64ToFloat16( buf[ 0 ] ), 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value[ 1 ], float64ToFloat16( buf[ 1 ] ), 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.return( 'finished' ); - t.strictEqual( v.value, 'finished', 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'if an environment supports `Symbol.iterator`, the method returns an iterable', function test( t ) { - var Float16Array; - var arr; - var buf; - var it1; - var it2; - var v1; - var v2; - var i; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - buf = [ 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( buf ); - - it1 = arr.entries(); - t.strictEqual( typeof it1[ '__ITERATOR_SYMBOL__' ], 'function', 'has method' ); - t.strictEqual( it1[ '__ITERATOR_SYMBOL__' ].length, 0, 'has zero arity' ); - - it2 = it1[ '__ITERATOR_SYMBOL__' ](); - t.strictEqual( typeof it2, 'object', 'returns expected value' ); - t.strictEqual( typeof it2.next, 'function', 'has `next` method' ); - t.strictEqual( typeof it2.return, 'function', 'has `return` method' ); - - for ( i = 0; i < arr.length; i++ ) { - v1 = it1.next().value; - v2 = it2.next().value; - t.strictEqual( v1[ 0 ], v2[ 0 ], 'returns expected value' ); - t.strictEqual( v1[ 1 ], v2[ 1 ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'if an environment does not support `Symbol.iterator`, the method does not return an "iterable"', function test( t ) { - var Float16Array; - var arr; - var buf; - var it; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/symbol-iterator': false - }); - - buf = [ 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( buf ); - - it = arr.entries(); - t.strictEqual( it[ ITERATOR_SYMBOL ], void 0, 'does not have property' ); - - t.end(); -}); diff --git a/test/polyfill/test.every.js b/test/polyfill/test.every.js deleted file mode 100644 index 384adc4..0000000 --- a/test/polyfill/test.every.js +++ /dev/null @@ -1,174 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `every` method for returning boolean indicating whether all elements pass a test', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'every' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.every ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.every.call( value, predicate ); - }; - } - - function predicate( v ) { - return v === 0.0; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.every( value ); - }; - } -}); - -tape( 'the method returns `true` if operating on an empty floating-point number array', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( 0 ); - bool = arr.every( predicate ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns `true` if all elements pass a test', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 1.05, 1.05, 1.05 ] ); - bool = arr.every( predicate ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v === float64ToFloat16( 1.05 ); - } -}); - -tape( 'the method returns `false` if one or more elements fail a test', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 1.05, 0.05, 1.05 ] ); - bool = arr.every( predicate ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v === float64ToFloat16( 1.05 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var bool; - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ 1.05, 1.05, 1.05, 1.05 ] ); - bool = arr.every( predicate, ctx ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v === float64ToFloat16( 1.05 ); - } -}); diff --git a/test/polyfill/test.fill.js b/test/polyfill/test.fill.js deleted file mode 100644 index 197e33f..0000000 --- a/test/polyfill/test.fill.js +++ /dev/null @@ -1,305 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 Uint16Array = require( '@stdlib/array-uint16' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `fill` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'fill' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.fill ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.fill.call( value, 1.0 ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a floating-point number', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 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.fill( value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - 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.fill( 1.0, value ); - }; - } -}); - -tape( 'the method throws an error if provided a third argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - 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.fill( 1.0, 0, value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.fill( 1.05 ); - - t.strictEqual( out instanceof Float16Array, true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 10 ); - out = arr.fill( 1.05 ); - - t.strictEqual( out, arr, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'if called with one argument, the method sets each array element to the provided value', function test( t ) { - var arr; - var buf; - var i; - - arr = new Float16Array( 3 ); - arr.fill( 1.05 ); - - buf = new Uint16Array( arr.buffer ); - - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( buf[ i ], toWord( 1.05 ), 'returns expected value' ); - } - - t.end(); -}); - -tape( 'if called with two arguments, the method sets each array element to the provided value starting from a start index (inclusive)', function test( t ) { - var arr; - var buf; - - arr = new Float16Array( 3 ); - buf = new Uint16Array( arr.buffer ); - - arr.fill( 1.05, 1 ); - - t.strictEqual( buf[ 0 ], toWord( 0.0 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 2 ], toWord( 1.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'if called with three arguments, the method sets each array element to the provided value starting from a start index (inclusive) until a specified end index (exclusive)', function test( t ) { - var arr; - var buf; - - arr = new Float16Array( 3 ); - buf = new Uint16Array( arr.buffer ); - - arr.fill( 1.05, 0, 2 ); - - t.strictEqual( buf[ 0 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 2 ], toWord( 0.0 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method supports negative indices', function test( t ) { - var arr; - var buf; - - arr = new Float16Array( 3 ); - buf = new Uint16Array( arr.buffer ); - - arr.fill( 1.05, -3, -1 ); - - t.strictEqual( buf[ 0 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 2 ], toWord( 0.0 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'if a provided start index resolves to a negative index, the method fills an array starting from the first element', function test( t ) { - var arr; - var buf; - var i; - - arr = new Float16Array( 3 ); - buf = new Uint16Array( arr.buffer ); - - arr.fill( 1.05, -10 ); - - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( buf[ i ], toWord( 1.05 ), 'returns expected value' ); - } - - t.end(); -}); - -tape( 'if a provided end index resolves to an index exceeding the last array element index, the method fills an array until the last element (inclusive)', function test( t ) { - var arr; - var buf; - var i; - - arr = new Float16Array( 3 ); - buf = new Uint16Array( arr.buffer ); - - arr.fill( 1.05, 1, 10 ); - - t.strictEqual( buf[ 0 ], toWord( 0.0 ), 'returns expected value' ); - for ( i = 1; i < arr.length; i++ ) { - t.strictEqual( buf[ i ], toWord( 1.05 ), 'returns expected value' ); - } - - t.end(); -}); - -tape( 'if a provided start index resolves to an index which is greater than or equal to a resolved end index, the method does not fill an array', function test( t ) { - var arr; - var buf; - - arr = new Float16Array( 3 ); - buf = new Uint16Array( arr.buffer ); - - arr.fill( 1.0, 2, 1 ); - - t.strictEqual( buf[ 0 ], toWord( 0.0 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 0.0 ), 'returns expected value' ); - t.strictEqual( buf[ 2 ], toWord( 0.0 ), 'returns expected value' ); - - t.end(); -}); diff --git a/test/polyfill/test.filter.js b/test/polyfill/test.filter.js deleted file mode 100644 index c5be66b..0000000 --- a/test/polyfill/test.filter.js +++ /dev/null @@ -1,226 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 instanceOf = require( '@stdlib/assert-instance-of' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `filter` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'filter' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.filter ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.filter.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( v === 1.0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.filter( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.filter( predicate ); - - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v === 1.0 ); - } -}); - -tape( 'the method returns a new floating-point number array containing only those elements which satisfy a test condition', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 1.05, 2.05 ] ); - expected = new Uint16Array( [ toWord( 1.05 ), toWord( 1.05 ) ] ); - actual = arr.filter( predicate ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v === float64ToFloat16( 1.05 ) ); - } -}); - -tape( 'the method copies all elements to a new array if all elements satisfy a test condition', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ) - ]); - actual = arr.filter( predicate ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.notEqual( actual, arr, 'returns a new instance' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v > 1.0 ); - } -}); - -tape( 'the method returns an empty array if no elements satisfy a test condition', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array( [] ); - actual = arr.filter( predicate ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.notEqual( actual, arr, 'returns a new instance' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 1.0 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var expected; - var actual; - var arr; - var buf; - var ctx; - - arr = new Float16Array( [ 1.05, 2.05, 1.05, 1.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 1.05 ), - toWord( 1.05 ) - ]); - ctx = { - 'count': 0 - }; - actual = arr.filter( predicate, ctx ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v === float64ToFloat16( 1.05 ) ); - } -}); diff --git a/test/polyfill/test.find.js b/test/polyfill/test.find.js deleted file mode 100644 index 64dffd0..0000000 --- a/test/polyfill/test.find.js +++ /dev/null @@ -1,174 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `find` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'find' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.find ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.find.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( v === 1.0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.find( value ); - }; - } -}); - -tape( 'the method returns `undefined` if operating on an empty floating-point number array', function test( t ) { - var arr; - var v; - - arr = new Float16Array( 0 ); - v = arr.find( predicate ); - - t.strictEqual( v, void 0, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns the first element which passes a test', function test( t ) { - var arr; - var v; - - arr = new Float16Array( [ 1.05, -2.05, 3.05, -4.05 ] ); - v = arr.find( predicate ); - - t.strictEqual( v, float64ToFloat16( -2.05 ), 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method returns `undefined` if all elements fail a test', function test( t ) { - var arr; - var v; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - v = arr.find( predicate ); - - t.strictEqual( v, void 0, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - var v; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ -1.05, -2.05, 3.05, 4.05, 5.05 ] ); - v = arr.find( predicate, ctx ); - - t.strictEqual( v, float64ToFloat16( 3.05 ), 'returns expected value' ); - t.strictEqual( ctx.count, 3, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v > 0.0 ); - } -}); diff --git a/test/polyfill/test.find_index.js b/test/polyfill/test.find_index.js deleted file mode 100644 index e1516da..0000000 --- a/test/polyfill/test.find_index.js +++ /dev/null @@ -1,173 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `findIndex` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'findIndex' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.findIndex ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.findIndex.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( v === 1.0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.findIndex( value ); - }; - } -}); - -tape( 'the method returns `-1` if operating on an empty floating-point number array', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( 0 ); - idx = arr.findIndex( predicate ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns the index of the first element which passes a test', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( [ 1.05, -2.05, 3.05, -4.05 ] ); - idx = arr.findIndex( predicate ); - - t.strictEqual( idx, 1, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0); - } -}); - -tape( 'the method returns `-1` if all elements fail a test', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - idx = arr.findIndex( predicate ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - var idx; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ -1.05, -2.05, 3.05, 4.05, 5.05 ] ); - idx = arr.findIndex( predicate, ctx ); - - t.strictEqual( idx, 2, 'returns expected value' ); - t.strictEqual( ctx.count, 3, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v > 0.0 ); - } -}); diff --git a/test/polyfill/test.find_last.js b/test/polyfill/test.find_last.js deleted file mode 100644 index 091e5a7..0000000 --- a/test/polyfill/test.find_last.js +++ /dev/null @@ -1,174 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `findLast` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'findLast' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.findLast ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.findLast.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( v === 0.0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.findLast( value ); - }; - } -}); - -tape( 'the method returns `undefined` if operating on an empty floating-point number array', function test( t ) { - var arr; - var v; - - arr = new Float16Array( 0 ); - v = arr.findLast( predicate ); - - t.strictEqual( v, void 0, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns the last element which passes a test', function test( t ) { - var arr; - var v; - - arr = new Float16Array( [ 1.05, -2.05, 3.05, -4.05 ] ); - v = arr.findLast( predicate ); - - t.strictEqual( v, float64ToFloat16( -4.05 ), 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method returns `undefined` if all elements fail a test', function test( t ) { - var arr; - var v; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - v = arr.findLast( predicate ); - - t.strictEqual( v, void 0, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - var v; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ -1.05, -2.05, 3.05, 4.05, 5.05 ] ); - v = arr.findLast( predicate, ctx ); - - t.strictEqual( v, float64ToFloat16( 5.05 ), 'returns expected value' ); - t.strictEqual( ctx.count, 1, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v > 0.0 ); - } -}); diff --git a/test/polyfill/test.find_last_index.js b/test/polyfill/test.find_last_index.js deleted file mode 100644 index 1b7b8df..0000000 --- a/test/polyfill/test.find_last_index.js +++ /dev/null @@ -1,173 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `findLastIndex` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'findLastIndex' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.findLastIndex ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.findLastIndex.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( v === 1.0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.findLastIndex( value ); - }; - } -}); - -tape( 'the method returns `-1` if operating on an empty floating-point number array', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( 0 ); - idx = arr.findLastIndex( predicate ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns the index of the last element which passes a test', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( [ 1.05, -2.05, 3.05, -4.05 ] ); - idx = arr.findLastIndex( predicate ); - - t.strictEqual( idx, 3, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method returns `-1` if all elements fail a test', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - idx = arr.findLastIndex( predicate ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - var idx; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ -1.05, -2.05, 3.05, 4.05, 5.05 ] ); - idx = arr.findLastIndex( predicate, ctx ); - - t.strictEqual( idx, 4, 'returns expected value' ); - t.strictEqual( ctx.count, 1, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v > 0.0 ); - } -}); diff --git a/test/polyfill/test.for_each.js b/test/polyfill/test.for_each.js deleted file mode 100644 index 98e75c2..0000000 --- a/test/polyfill/test.for_each.js +++ /dev/null @@ -1,196 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `forEach` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'forEach' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.forEach ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.forEach.call( value, fcn ); - }; - } - - function fcn( v ) { - if ( !isNumber( v ) ) { - t.fail( 'should be a number' ); - } - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.forEach( value ); - }; - } -}); - -tape( 'the method should not invoke a provided callback function if operating on an empty floating-point array', function test( t ) { - var arr; - - arr = new Float16Array( 0 ); - arr.forEach( fcn ); - - t.end(); - - function fcn() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns `undefined`', function test( t ) { - var arr; - var out; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - out = arr.forEach( fcn ); - - t.strictEqual( out, void 0, 'returns expected value' ); - t.end(); - - function fcn( v ) { - if ( !isNumber( v ) ) { - t.fail( 'should be a number' ); - } - } -}); - -tape( 'the method invokes a provided function for each element in an array', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var arr; - - indices = []; - values = []; - arrays = []; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - arr.forEach( fcn ); - - expected = [ - float64ToFloat16( 1.05 ), - float64ToFloat16( 2.05 ), - float64ToFloat16( 3.05 ), - float64ToFloat16( 4.05 ) - ]; - - t.deepEqual( values, expected, 'returns expected value' ); - t.deepEqual( indices, [ 0, 1, 2, 3 ], 'returns expected value' ); - t.strictEqual( arrays[ 0 ], arr, 'returns expected value' ); - t.strictEqual( arrays[ 1 ], arr, 'returns expected value' ); - t.strictEqual( arrays[ 2 ], arr, 'returns expected value' ); - t.strictEqual( arrays[ 3 ], arr, 'returns expected value' ); - - t.end(); - - function fcn( v, i, arr ) { - values.push( v ); - indices.push( i ); - arrays.push( arr ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - arr.forEach( fcn, ctx ); - - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function fcn() { - this.count += 1; // eslint-disable-line no-invalid-this - } -}); diff --git a/test/polyfill/test.from.js b/test/polyfill/test.from.js deleted file mode 100644 index d9cfc1a..0000000 --- a/test/polyfill/test.from.js +++ /dev/null @@ -1,654 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 proxyquire = require( 'proxyquire' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is a `from` method for creating a 16-bit floating-point number array from an array-like object or an iterable', function test( t ) { - var arr; - - t.strictEqual( hasOwnProp( Float16Array, 'from' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.from ), true, 'has method' ); - - arr = Float16Array.from( [] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a constructor', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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 Float16Array.from.call( value, [] ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array constructor', function test( t ) { - var values; - var i; - - values = [ - {}, - null, - 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 Float16Array.from.call( value, [] ); - }; - } -}); - -tape( 'the method throws an error if not provided an iterable or array-like object', function test( t ) { - var values; - var i; - - 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 Float16Array.from( value ); - }; - } -}); - -tape( 'the method throws an error if not provided an iterable or array-like object (callback)', function test( t ) { - var values; - var i; - - 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 Float16Array.from( value, clbk ); - }; - } - - function clbk() { - return 1.0; - } -}); - -tape( 'the method throws an error if not provided an iterable or array-like object (callback, thisArg)', function test( t ) { - var values; - var i; - - 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 Float16Array.from( value, clbk, {} ); - }; - } - - function clbk() { - return 1.0; - } -}); - -tape( 'the method throws an error if provided a second argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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 Float16Array.from( [], value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not a function (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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 Float16Array.from( [], value, {} ); - }; - } -}); - -tape( 'the method returns a floating-point number array', function test( t ) { - var arr; - var v; - - // Generic array: - arr = Float16Array.from( [] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Float16Array.from( [ 1.0, 2.0, 3.0, 4.0 ] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - // Generic array containing non-numeric values: - arr = Float16Array.from( [ 'beep' ] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - arr = Float16Array.from( [ null, 4 ] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - arr = Float16Array.from( [ true, {}, '' ] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 3, 'returns expected value' ); - - // Typed array: - arr = Float16Array.from( new Uint16Array( 0 ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Float16Array.from( new Uint16Array( [ 1, 1 ] ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // Floating-point number typed array: - arr = Float16Array.from( new Float16Array( 0 ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Float16Array.from( new Float16Array( [ 1.0, 2.0 ] ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method returns a floating-point number array (iterable)', function test( t ) { - var Float16Array; - var iter; - var arr; - var v; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - iter = { - 'next': next, - 'i': 0, - 'N': 4 - }; - arr = Float16Array.from( createIterable( iter ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, iter.N, 'returns expected value' ); - - t.end(); - - function hasSupport() { - return true; - } - - function createIterable( iterator ) { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return iterator; - } - } - - function next() { - iter.i += 1; - if ( iter.i <= iter.N ) { - return { - 'value': 1.0 - }; - } - return { - 'done': true - }; - } -}); - -tape( 'the method supports providing a "map" function which is invoked for each source element', function test( t ) { - var arr; - var v; - - // Generic array: - arr = Float16Array.from( [], clbk1 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Float16Array.from( [ 1.0, 2.0, 3.0, 4.0 ], clbk1 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - // Generic array containing non-numeric values: - arr = Float16Array.from( [ 'beep' ], clbk2 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - arr = Float16Array.from( [ null ], clbk2 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - arr = Float16Array.from( [ [], {} ], clbk1 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - arr = Float16Array.from( [ 4, 5 ], clbk1 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // Typed array: - arr = Float16Array.from( new Uint16Array( 0 ), clbk1 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Float16Array.from( new Uint16Array( [ 1, 1 ] ), clbk1 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // Floating-point number typed array: - arr = Float16Array.from( new Float16Array( 0 ), clbk2 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Float16Array.from( new Float16Array( [ true, true ] ), clbk2 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - t.end(); - - function clbk1( v ) { - return v; - } - - function clbk2() { - return true; - } -}); - -tape( 'the method supports providing a "map" function which is invoked for each iterated value', function test( t ) { - var Float16Array; - var iter; - var arr; - var v; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - iter = { - 'next': next, - 'i': 0, - 'N': 4 - }; - arr = Float16Array.from( createIterable( iter ), clbk ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, iter.N, 'returns expected value' ); - - t.end(); - - function hasSupport() { - return true; - } - - function createIterable( iterator ) { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return iterator; - } - } - - function next() { - iter.i += 1; - if ( iter.i <= iter.N ) { - return { - 'value': 1.0 - }; - } - return { - 'done': true - }; - } - - function clbk( v ) { - return !v; - } -}); - -tape( 'the method supports providing a `this` context for a provided map function', function test( t ) { - var arr; - var ctx; - - ctx = { - 'count': 0 - }; - arr = Float16Array.from( [ 1.0, 2.0, 3.0, 4.0 ], clbk1, ctx ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function clbk1( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v; - } -}); - -tape( 'the method supports providing a `this` context for a provided map function (iterable)', function test( t ) { - var Float16Array; - var iter; - var ctx; - var arr; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - iter = { - 'next': next, - 'i': 0, - 'N': 4 - }; - ctx = { - 'count': 0 - }; - - arr = Float16Array.from( createIterable( iter ), clbk, ctx ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function hasSupport() { - return true; - } - - function createIterable( iterator ) { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return iterator; - } - } - - function next() { - iter.i += 1; - if ( iter.i <= iter.N ) { - return { - 'value': 1.0 - }; - } - return { - 'done': true - }; - } - - function clbk( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v; - } -}); - -tape( 'the method throws an error if provided a non-iterable object (non-ES2015+)', function test( t ) { - var Float16Array; - var values; - var i; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - {}, - { - '0': 1, - '1': 2, - '2': 3 - } - ]; - 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 Float16Array.from( value ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the method throws an error if provided a non-iterable object (ES2015+)', function test( t ) { - var Float16Array; - var values; - var i; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - values = [ - {}, - { - '0': 1, - '1': 2, - '2': 3 - }, - { - '__SYMBOL_ITERATOR__': null - }, - { - '__SYMBOL_ITERATOR__': 'beep' - }, - { - '__SYMBOL_ITERATOR__': nonIterable1 - }, - { - '__SYMBOL_ITERATOR__': nonIterable2 - } - ]; - 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 Float16Array.from( value ); - }; - } - - function hasSupport() { - return true; - } - - function nonIterable1() { - return null; - } - - function nonIterable2() { - return {}; - } -}); diff --git a/test/polyfill/test.includes.js b/test/polyfill/test.includes.js deleted file mode 100644 index 8bb9850..0000000 --- a/test/polyfill/test.includes.js +++ /dev/null @@ -1,222 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `includes` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'includes' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.includes ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.includes.call( value, true ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a numeric value', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 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.includes( value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - 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.includes( true, value ); - }; - } -}); - -tape( 'the method returns `false` if operating on an empty floating-point number array', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( 0 ); - bool = arr.includes( 1.0 ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `false` if a floating-point number is not found', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( 10 ); - bool = arr.includes( 1.0 ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `true` if an array contains a specified floating-point number', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05] ); - bool = arr.includes( float64ToFloat16( 1.05 ) ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `false` if provided a second argument which exceeds the input array length', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( 10 ); - bool = arr.includes( 0.0, 20 ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 1.05, 1.05, 1.05 ] ); - - bool = arr.includes( float64ToFloat16( 1.05 ), 0 ); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = arr.includes( float64ToFloat16( 2.05 ), 1 ); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = arr.includes( float64ToFloat16( 2.05 ), 3 ); - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index (negative)', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 1.05, 1.05, 1.05 ] ); - - bool = arr.includes( float64ToFloat16( 1.05 ), -5 ); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = arr.includes( float64ToFloat16( 2.05 ), -2 ); - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'when provided a starting index which resolves to an index which is less than zero, the method searches from the first array element', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 1.05, 1.05, 1.05 ] ); - - bool = arr.includes( float64ToFloat16( 1.05 ), -10 ); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = arr.includes( float64ToFloat16( 2.05 ), -10 ); - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); -}); diff --git a/test/polyfill/test.index_of.js b/test/polyfill/test.index_of.js deleted file mode 100644 index b432c6d..0000000 --- a/test/polyfill/test.index_of.js +++ /dev/null @@ -1,222 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `indexOf` method for returning the index of an array element', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'indexOf' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.indexOf ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.indexOf.call( value, 1.0 ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a numeric value', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 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.indexOf( value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - 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.indexOf( 1.0, value ); - }; - } -}); - -tape( 'the method returns `-1` if operating on an empty floating-point number array', function test( t ) { - var arr; - var idx; - - arr = new Float16Array(); - idx = arr.indexOf( 1.0 ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `-1` if a numeric value is not found', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( 10 ); - idx = arr.indexOf( 1.0 ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns the index of the first match if a numeric value is found', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - idx = arr.indexOf( float64ToFloat16( 2.05 ) ); - - t.strictEqual( idx, 1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `-1` if provided a second argument which exceeds the input array length', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( 10 ); - idx = arr.indexOf( 1.0, 20 ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 2.05, 5.05 ] ); - - idx = arr.indexOf( float64ToFloat16( 2.05 ), 0 ); - t.strictEqual( idx, 1, 'returns expected value' ); - - idx = arr.indexOf( float64ToFloat16( 2.05 ), 2 ); - t.strictEqual( idx, 3, 'returns expected value' ); - - idx = arr.indexOf( float64ToFloat16( 2.05 ), 4 ); - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index (negative)', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 2.05, 5.05 ] ); - - idx = arr.indexOf( float64ToFloat16( 2.05 ), -5 ); - t.strictEqual( idx, 1, 'returns expected value' ); - - idx = arr.indexOf( float64ToFloat16( 2.05 ), -1 ); - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'when provided a starting index which resolves to an index which is less than zero, the method searches from the first array element', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 2.05, 5.05 ] ); - - idx = arr.indexOf( float64ToFloat16( 2.05 ), -10 ); - t.strictEqual( idx, 1, 'returns expected value' ); - - idx = arr.indexOf( float64ToFloat16( 1.05 ), -10 ); - t.strictEqual( idx, 0, 'returns expected value' ); - t.end(); -}); diff --git a/test/polyfill/test.join.js b/test/polyfill/test.join.js deleted file mode 100644 index 007f1cb..0000000 --- a/test/polyfill/test.join.js +++ /dev/null @@ -1,173 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `join` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'join' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.join ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.join.call( value ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `separator` argument which is not a string', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - 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.join( value ); - }; - } -}); - -tape( 'the method returns an empty string if invoked on an empty array', function test( t ) { - var str; - var arr; - - arr = new Float16Array( 0 ); - str = arr.join(); - - t.strictEqual( str, '', 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a string representation of a floating-point number array with elements separated by a separator', function test( t ) { - var expected; - var str; - var arr; - var i; - - arr = new Float16Array( [ 0.05, 1.05, 2.05, 3.05, 4.05 ] ); - - expected = float64ToFloat16( 0.05 ); - for ( i = 1; i < arr.length; i++ ) { - expected += '@' + float64ToFloat16( i + 0.05 ); - } - - str = arr.join( '@' ); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a string representation of a floating-point number array with elements separated by a separator (single element)', function test( t ) { - var expected; - var str; - var arr; - - arr = new Float16Array( [ 1.05 ] ); - expected = '' + float64ToFloat16( 1.05 ); - - str = arr.join(); - - t.strictEqual( str, expected, 'returns expected value' ); - - arr = new Float16Array( [ 1.05 ] ); - expected = '' + float64ToFloat16( 1.05 ); - - str = arr.join( '@' ); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if the method is invoked without a separator argument, the method returns a string representation of a floating-point number array with elements separated by a comma', function test( t ) { - var expected; - var str; - var arr; - var i; - - arr = new Float16Array( [ 0.05, 1.05, 2.05, 3.05, 4.05 ] ); - - expected = float64ToFloat16( 0.05 ); - for ( i = 1; i < arr.length; i++ ) { - expected += ',' + float64ToFloat16( i + 0.05 ); - } - - str = arr.join(); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); diff --git a/test/polyfill/test.js b/test/polyfill/test.js deleted file mode 100644 index 6e254ad..0000000 --- a/test/polyfill/test.js +++ /dev/null @@ -1,740 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 proxyquire = require( 'proxyquire' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var arr = new Float16Array( 0 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var ctor; - var arr; - - ctor = Float16Array; - - arr = ctor( 0 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (no argument)', function test( t ) { - var arr = new Float16Array(); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (no argument, no new)', function test( t ) { - var ctor; - var arr; - - ctor = Float16Array; - - arr = ctor(); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (length)', function test( t ) { - var arr = new Float16Array( 10 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (length, no new)', function test( t ) { - var ctor; - var arr; - - ctor = Float16Array; - - arr = ctor( 10 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (array)', function test( t ) { - var arr = new Float16Array( [] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (array, no new)', function test( t ) { - var ctor; - var arr; - - ctor = Float16Array; - - arr = ctor( [] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (typed array)', function test( t ) { - var arr = new Float16Array( new Uint16Array( 0 ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (typed array, no new)', function test( t ) { - var ctor; - var arr; - - ctor = Float16Array; - - arr = ctor( new Uint16Array( 0 ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (iterable)', function test( t ) { - var Float16Array; - var arr; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - arr = new Float16Array( createIterable() ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); - - function hasSupport() { - return true; - } - - function createIterable() { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return { - 'next': next - }; - } - - function next() { - return { - 'done': true - }; - } - } -}); - -tape( 'the constructor returns a 16-bit floating-point number array (iterable, no new)', function test( t ) { - var ctor; - var arr; - - ctor = proxyquire( './../../lib/polyfill', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - arr = ctor( createIterable() ); - t.strictEqual( arr instanceof ctor, true, 'returns expected value' ); - - t.end(); - - function hasSupport() { - return true; - } - - function createIterable() { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return { - 'next': next - }; - } - - function next() { - return { - 'done': true - }; - } - } -}); - -tape( 'the constructor returns a 16-bit floating-point number array (ArrayBuffer)', function test( t ) { - var arr = new Float16Array( new ArrayBuffer( 0 ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (ArrayBuffer, no new)', function test( t ) { - var ctor; - var arr; - - ctor = Float16Array; - - arr = ctor( new ArrayBuffer( 0 ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (ArrayBuffer, byte offset)', function test( t ) { - var arr = new Float16Array( new ArrayBuffer( 8 ), 8 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (ArrayBuffer, byte offset, no new)', function test( t ) { - var ctor; - var arr; - - ctor = Float16Array; - - arr = ctor( new ArrayBuffer( 8 ), 8 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (ArrayBuffer, byte offset, length)', function test( t ) { - var arr = new Float16Array( new ArrayBuffer( 8 ), 8, 0 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (ArrayBuffer, byte offset, length, no new)', function test( t ) { - var ctor; - var arr; - - ctor = Float16Array; - - arr = ctor( new ArrayBuffer( 8 ), 8, 0 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'attached to the constructor is a property returning the number of bytes per array element', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Float16Array.BYTES_PER_ELEMENT, 2, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the constructor is a property returning the constructor name', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array, 'name' ), true, 'has property' ); - t.strictEqual( Float16Array.name, 'Float16Array', 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance having a `BYTES_PER_ELEMENT` property returning the number of bytes per array element', function test( t ) { - var arr; - - t.strictEqual( hasOwnProp( Float16Array.prototype, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Float16Array.prototype.BYTES_PER_ELEMENT, 2, 'returns expected value' ); - - arr = new Float16Array( 0 ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance having a `buffer` property for returning the underlying memory (i.e., ArrayBuffer)', function test( t ) { - var arr; - var buf; - - arr = new Float16Array( 0 ); - buf = arr.buffer; - t.strictEqual( isArrayBuffer( buf ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance having a `byteLength` property for returning the number of bytes belonging to the array view', function test( t ) { - var arr; - var v; - - arr = new Float16Array( 0 ); - v = arr.byteLength; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( new ArrayBuffer( 64 ), 8 ); - v = arr.byteLength; - t.strictEqual( v, 56, 'returns expected value' ); - - arr = new Float16Array( new ArrayBuffer( 64 ), 64 ); - v = arr.byteLength; - t.strictEqual( v, 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance having a `byteOffset` property for returning the byte offset pointing to the first array element in the underlying memory', function test( t ) { - var arr; - var v; - - arr = new Float16Array( 0 ); - v = arr.byteOffset; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( new ArrayBuffer( 64 ), 32 ); - v = arr.byteOffset; - t.strictEqual( v, 32, 'returns expected value' ); - - arr = new Float16Array( new ArrayBuffer( 64 ), 64 ); - v = arr.byteOffset; - t.strictEqual( v, 64, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance having a `length` property for returning the number of array elements', function test( t ) { - var arr; - var v; - - // No arguments: - arr = new Float16Array(); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - // Explicit array length: - arr = new Float16Array( 0 ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( 10 ); - v = arr.length; - t.strictEqual( v, 10, 'returns expected value' ); - - // Generic array: - arr = new Float16Array( [] ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - // Typed array: - arr = new Float16Array( new Uint16Array( 0 ) ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( new Uint16Array( [ 1.0, 1.0 ] ) ); - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // Float16 typed array: - arr = new Float16Array( new Float16Array( 0 ) ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( new Float16Array( [ 1.0, 2.0 ] ) ); - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // ArrayBuffer: - arr = new Float16Array( new ArrayBuffer( 64 ), 32 ); - v = arr.length; - t.strictEqual( v, 16, 'returns expected value' ); - - arr = new Float16Array( new ArrayBuffer( 64 ), 64 ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( new ArrayBuffer( 64 ), 32, 2 ); - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance having a `length` property for returning the number of array elements (iterable)', function test( t ) { - var Float16Array; - var iter; - var arr; - var v; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - iter = { - 'next': next, - 'i': 0, - 'N': 4 - }; - arr = new Float16Array( createIterable( iter ) ); - v = arr.length; - t.strictEqual( v, iter.N, 'returns expected value' ); - - t.end(); - - function hasSupport() { - return true; - } - - function createIterable( iterator ) { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return iterator; - } - } - - function next() { - iter.i += 1; - if ( iter.i <= iter.N ) { - return { - 'value': 1.0 - }; - } - return { - 'done': true - }; - } -}); - -tape( 'the constructor throws an error if provided an ArrayBuffer which is not a multiple of 2', function test( t ) { - var values; - var i; - - values = [ - 1, - 3, - 5, - 7, - 9, - 11, - 101, - 1001 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided an ArrayBuffer having a byte length equal to '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Float16Array( new ArrayBuffer( value ) ); - }; - } -}); - -tape( 'the constructor throws an error if provided a non-iterable object (non-ES2015+)', function test( t ) { - var Float16Array; - var values; - var i; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - {}, - { - '0': 1, - '1': 2, - '2': 3 - } - ]; - 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 new Float16Array( value ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the constructor throws an error if provided a non-iterable object (ES2015+)', function test( t ) { - var Float16Array; - var values; - var i; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - values = [ - {}, - { - '0': 1, - '1': 2, - '2': 3 - }, - { - '__SYMBOL_ITERATOR__': null - }, - { - '__SYMBOL_ITERATOR__': 'beep' - }, - { - '__SYMBOL_ITERATOR__': nonIterable1 - }, - { - '__SYMBOL_ITERATOR__': nonIterable2 - } - ]; - 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 new Float16Array( value ); - }; - } - - function hasSupport() { - return true; - } - - function nonIterable1() { - return null; - } - - function nonIterable2() { - return {}; - } -}); - -tape( 'the constructor throws an error if not provided a length, iterable, array-like object, or ArrayBuffer', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - 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 new Float16Array( value ); - }; - } -}); - -tape( 'the constructor throws an error if provided more than one argument and the first argument is not an ArrayBuffer', function test( t ) { - var values; - var i; - - 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 new Float16Array( value, 0 ); - }; - } -}); - -tape( 'the constructor throws an error if provided a byte offset argument which is not a nonnegative integer', function test( t ) { - var values; - var i; - - values = [ - '5', - -1, - 3.14, - 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 new Float16Array( new ArrayBuffer( 64 ), value ); - }; - } -}); - -tape( 'the constructor throws an error if provided a byte offset argument which is not a multiple of 2', function test( t ) { - var values; - var i; - - values = [ - 1, - 3, - 5, - 7, - 9, - 11, - 101, - 1001 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Float16Array( new ArrayBuffer( 1e3 ), value ); - }; - } -}); - -tape( 'the constructor throws an error if provided a byte offset argument such that the view byte length is not a multiple of 8', function test( t ) { - var values; - var i; - - values = [ - 2, - 4, - 6, - 8, - 10, - 12, - 14, - 16, - 18, - 20 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Float16Array( new ArrayBuffer( 101 ), value ); - }; - } -}); - -tape( 'the constructor throws an error if provided a length argument which is not a nonnegative integer (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - -1, - 3.14, - 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 new Float16Array( new ArrayBuffer( 64 ), 0, value ); - }; - } -}); - -tape( 'the constructor throws an error if provided insufficient memory to accommodate byte offset and length arguments', function test( t ) { - var values; - var i; - - values = [ - 8, - 16, - 24, - 32 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Float16Array( new ArrayBuffer( 100 ), value, 1e3 ); - }; - } -}); diff --git a/test/polyfill/test.keys.js b/test/polyfill/test.keys.js deleted file mode 100644 index 59c6210..0000000 --- a/test/polyfill/test.keys.js +++ /dev/null @@ -1,261 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 proxyquire = require( 'proxyquire' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `keys` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'keys' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.keys ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.keys.call( value ); - }; - } -}); - -tape( 'the method returns an iterator protocol-compliant object', function test( t ) { - var expected; - var arr; - var it; - var i; - var r; - var e; - - arr = new Float16Array( [ 1.05, 2.05 ] ); - expected = [ - { - 'value': 0, - 'done': false - }, - { - 'value': 1, - 'done': false - }, - { - 'done': true - } - ]; - it = arr.keys(); - - t.strictEqual( typeof it, 'object', 'returns expected value' ); - t.strictEqual( typeof it.next, 'function', 'has next method' ); - - for ( i = 0; i < expected.length; i++ ) { - r = it.next(); - e = expected[ i ]; - if ( e.value === void 0 ) { - t.deepEqual( r, e, 'returns expected value' ); - } else { - t.strictEqual( r.value, e.value, 'returns expected value' ); - t.strictEqual( r.done, e.done, 'returns expected value' ); - } - } - - t.end(); -}); - -tape( 'the method returns an iterator which does not iterate over empty arrays', function test( t ) { - var expected; - var arr; - var it; - var i; - var v; - - arr = new Float16Array( [] ); - expected = [ - { - 'done': true - }, - { - 'done': true - }, - { - 'done': true - } - ]; - it = arr.keys(); - - t.strictEqual( typeof it, 'object', 'returns expected value' ); - t.strictEqual( typeof it.next, 'function', 'has next method' ); - - for ( i = 0; i < expected.length; i++ ) { - v = it.next(); - t.deepEqual( v, expected[ i ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (no argument)', function test( t ) { - var arr; - var it; - var v; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - it = arr.keys(); - - v = it.next(); - t.strictEqual( v.value, 0, 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, 1, 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.return(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (argument)', function test( t ) { - var arr; - var it; - var v; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - it = arr.keys(); - - v = it.next(); - t.strictEqual( v.value, 0, 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, 1, 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.return( 'beep' ); - t.strictEqual( v.value, 'beep', 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'if an environment supports `Symbol.iterator`, the method returns an iterable', function test( t ) { - var Float16Array; - var arr; - var buf; - var it1; - var it2; - var v1; - var v2; - var i; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - buf = [ 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( buf ); - - it1 = arr.keys(); - t.strictEqual( typeof it1[ '__ITERATOR_SYMBOL__' ], 'function', 'has method' ); - t.strictEqual( it1[ '__ITERATOR_SYMBOL__' ].length, 0, 'has zero arity' ); - - it2 = it1[ '__ITERATOR_SYMBOL__' ](); - t.strictEqual( typeof it2, 'object', 'returns expected value' ); - t.strictEqual( typeof it2.next, 'function', 'has `next` method' ); - t.strictEqual( typeof it2.return, 'function', 'has `return` method' ); - - for ( i = 0; i < arr.length; i++ ) { - v1 = it1.next().value; - v2 = it2.next().value; - t.strictEqual( v1, v2, 'returns expected value' ); - } - t.end(); -}); - -tape( 'if an environment does not support `Symbol.iterator`, the method does not return an "iterable"', function test( t ) { - var Float16Array; - var arr; - var buf; - var it; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/symbol-iterator': false - }); - - buf = [ 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( buf ); - - it = arr.keys(); - t.strictEqual( it[ ITERATOR_SYMBOL ], void 0, 'does not have property' ); - - t.end(); -}); diff --git a/test/polyfill/test.last_index_of.js b/test/polyfill/test.last_index_of.js deleted file mode 100644 index 6a2fe99..0000000 --- a/test/polyfill/test.last_index_of.js +++ /dev/null @@ -1,211 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `lastIndexOf` method for returning the index of an array element', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'lastIndexOf' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.lastIndexOf ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.lastIndexOf.call( value, true ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a numeric value', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 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.lastIndexOf( value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - 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.lastIndexOf( true, value ); - }; - } -}); - -tape( 'the method returns `-1` if operating on an empty floating-point number array', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( 0 ); - idx = arr.lastIndexOf( 0.0 ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `-1` if a numeric value is not found', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( 10 ); - idx = arr.lastIndexOf( 1.0 ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns the index of the first match when searching from the end of the array if a search element is found', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 1.05, 2.05 ] ); - idx = arr.lastIndexOf( float64ToFloat16( 1.05 ) ); - - t.strictEqual( idx, 2, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 2.05, 1.05, 1.05 ] ); - - idx = arr.lastIndexOf( float64ToFloat16( 1.05 ), 4 ); - t.strictEqual( idx, 4, 'returns expected value' ); - - idx = arr.lastIndexOf( float64ToFloat16( 2.05 ), 2 ); - t.strictEqual( idx, 2, 'returns expected value' ); - - idx = arr.lastIndexOf( float64ToFloat16( 2.05 ), 0 ); - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index (negative)', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 2.05, 1.05, 1.05 ] ); - - idx = arr.lastIndexOf( float64ToFloat16( 1.05 ), -3 ); - t.strictEqual( idx, 0, 'returns expected value' ); - - idx = arr.lastIndexOf( float64ToFloat16( 2.05 ), -1 ); - t.strictEqual( idx, 2, 'returns expected value' ); - t.end(); -}); - -tape( 'when the method is provided a starting index which resolves to an index which exceeds the maximum array index, the method searches from the last array element', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 2.05, 1.05, 1.05 ] ); - - idx = arr.lastIndexOf( float64ToFloat16( 1.05 ), 10 ); - t.strictEqual( idx, 4, 'returns expected value' ); - - idx = arr.lastIndexOf( float64ToFloat16( 2.05 ), 10 ); - t.strictEqual( idx, 2, 'returns expected value' ); - t.end(); -}); diff --git a/test/polyfill/test.map.js b/test/polyfill/test.map.js deleted file mode 100644 index 233d1d8..0000000 --- a/test/polyfill/test.map.js +++ /dev/null @@ -1,178 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 identity = require( '@stdlib/utils-identity-function' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `map` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'map' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.map ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.map.call( value, identity ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.map( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.map( identity ); - - t.strictEqual( instanceOf( out, Float16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - t.notEqual( out, arr, 'returns a new instance' ); - t.end(); -}); - -tape( 'the method returns a new floating-point number array containing elements which are the result of a provided callback function', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( -1.05 ), - toWord( -2.05 ), - toWord( -3.05 ), - toWord( -4.05 ) - ]); - actual = arr.map( invert ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.notEqual( actual, arr, 'returns a new instance' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); - - function invert( v ) { - return -v; - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var expected; - var actual; - var arr; - var buf; - var ctx; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( -1.05 ), - toWord( -2.05 ), - toWord( -3.05 ), - toWord( -4.05 ) - ]); - ctx = { - 'count': 0 - }; - actual = arr.map( invert, ctx ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.strictEqual( ctx.count, 6, 'returns expected value' ); - t.end(); - - function invert( v, i ) { - this.count += i; // eslint-disable-line no-invalid-this - return -v; - } -}); diff --git a/test/polyfill/test.of.js b/test/polyfill/test.of.js deleted file mode 100644 index 5031bb5..0000000 --- a/test/polyfill/test.of.js +++ /dev/null @@ -1,130 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `of` method for creating a 16-bit floating-point number array from a variable number of arguments', function test( t ) { - var arr; - - t.strictEqual( hasOwnProp( Float16Array, 'of' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.of ), true, 'has method' ); - - arr = Float16Array.of(); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a constructor', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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 Float16Array.of.call( value, true, true ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point array constructor', function test( t ) { - var values; - var i; - - values = [ - {}, - null, - 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 Float16Array.of.call( value, true, true ); - }; - } -}); - -tape( 'the method returns a floating-point number array', function test( t ) { - var arr; - var v; - - // No arguments: - arr = Float16Array.of(); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - // Numeric arguments: - arr = Float16Array.of( 1.0, 2.0, 3.0, 4.0 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - // Non-numeric arguments: - arr = Float16Array.of( 1, {}, 0, null, 'beep' ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 5, 'returns expected value' ); - - // Mixed arguments: - arr = Float16Array.of( true, 1, false, 0 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - t.end(); -}); diff --git a/test/polyfill/test.reduce.js b/test/polyfill/test.reduce.js deleted file mode 100644 index 7d9cbc0..0000000 --- a/test/polyfill/test.reduce.js +++ /dev/null @@ -1,189 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `reduce` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'reduce' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.reduce ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.reduce.call( value, reducer ); - }; - } - - function reducer( acc, value ) { - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.reduce( value ); - }; - } -}); - -tape( 'the method throws an error if not provided an initial value when operating on an empty floating-point number array', function test( t ) { - var arr; - - arr = new Float16Array( 0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - arr.reduce( reducer ); - } - - function reducer( acc, value ) { - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method uses the first element of the array as the initial value when an initial value is not provided', function test( t ) { - var valueArray; - var accArray; - var expected; - var actual; - var arr; - var ind; - - arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - accArray = [ 1.0, 3.0 ]; - valueArray = [ 2.0, 3.0 ]; - expected = float64ToFloat16( 6.0 ); - actual = arr.reduce( reducer ); - - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); - - function reducer( acc, value, index ) { - ind = index-1; - t.strictEqual( acc, float64ToFloat16( accArray[ ind ] ), 'returns expected value' ); - t.strictEqual( value, float64ToFloat16( valueArray[ ind ] ), 'returns expected value' ); - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method supports providing an initial value as the second argument', function test( t ) { - var valueArray; - var accArray; - var expected; - var actual; - var arr; - - arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - accArray = [ 2.0, 3.0, 5.0 ]; - valueArray = [ 1.0, 2.0, 3.0 ]; - expected = 8.0; - actual = arr.reduce( reducer, 2.0 ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value, index ) { - t.strictEqual( acc, float64ToFloat16( accArray[ index ] ), 'returns expected value' ); - t.strictEqual( value, float64ToFloat16( valueArray[ index ] ), 'returns expected value' ); - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method returns the accumulated result', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = float64ToFloat16( 10.20 ); - actual = arr.reduce( reducer ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value ) { - return float64ToFloat16( acc + value ); - } -}); diff --git a/test/polyfill/test.reduce_right.js b/test/polyfill/test.reduce_right.js deleted file mode 100644 index 0d27e43..0000000 --- a/test/polyfill/test.reduce_right.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `reduceRight` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'reduceRight' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.reduceRight ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.reduceRight.call( value, reducer ); - }; - } - - function reducer( acc, value ) { - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.reduceRight( value ); - }; - } -}); - -tape( 'the method throws an error if not provided an initial value when operating on an empty floating-point number array', function test( t ) { - var arr; - - arr = new Float16Array( 0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - arr.reduceRight( reducer ); - } - - function reducer( acc, value ) { - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method uses the last element of the array as the initial value when an initial value is not provided', function test( t ) { - var valueArray; - var accArray; - var expected; - var actual; - var arr; - var len; - - arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - len = arr.length; - accArray = [ 3.0, 5.0 ]; - valueArray = [ 2.0, 1.0 ]; - expected = float64ToFloat16( 6.0 ); - actual = arr.reduceRight( reducer ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value, index ) { - var ind = (len-index-2); - t.strictEqual( acc, float64ToFloat16( accArray[ ind ] ), 'returns expected value' ); - t.strictEqual( value, float64ToFloat16( valueArray[ ind ] ), 'returns expected value' ); - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method supports providing an initial value as the second argument', function test( t ) { - var valueArray; - var accArray; - var expected; - var actual; - var arr; - var len; - - arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - len = arr.length; - accArray = [ 2.0, 5.0, 7.0 ]; - valueArray = [ 3.0, 2.0, 1.0 ]; - expected = 8.0; - actual = arr.reduceRight( reducer, 2.0 ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value, index ) { - var ind = (len-index-1); - t.strictEqual( acc, float64ToFloat16( accArray[ ind ] ), 'returns expected value' ); - t.strictEqual( value, float64ToFloat16( valueArray[ ind ] ), 'returns expected value' ); - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method returns the accumulated result', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = float64ToFloat16( 10.20 ); - actual = arr.reduceRight( reducer ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value ) { - return float64ToFloat16( acc + value ); - } -}); diff --git a/test/polyfill/test.reverse.js b/test/polyfill/test.reverse.js deleted file mode 100644 index 080a4c3..0000000 --- a/test/polyfill/test.reverse.js +++ /dev/null @@ -1,122 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 instanceOf = require( '@stdlib/assert-instance-of' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, '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( Float16Array.prototype, 'reverse' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.reverse ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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 floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - 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 floating-point number array in-place', function test( t ) { - var expected; - var arr; - var buf; - var out; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05, 5.05 ] ); - expected = new Uint16Array([ - toWord( 5.05 ), - toWord( 4.05 ), - toWord( 3.05 ), - toWord( 2.05 ), - toWord( 1.05 ) - ]); - out = arr.reverse(); - buf = new Uint16Array( arr.buffer ); - - t.strictEqual( instanceOf( arr, Float16Array ), true, 'returns expected value' ); - t.strictEqual( out, arr, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 10 ); - out = arr.reverse(); - - t.strictEqual( out.length, 10, 'returns expected value' ); - t.end(); -}); diff --git a/test/polyfill/test.set.js b/test/polyfill/test.set.js deleted file mode 100644 index d5e0ebb..0000000 --- a/test/polyfill/test.set.js +++ /dev/null @@ -1,259 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `set` method for setting one or more array elements', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.set ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.set.call( value, 0 ); - }; - } -}); - -tape( 'the method throws an error if provided an index argument which is not a nonnegative integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - -5, - 3.14, - 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.set( [ 1.0 ], value ); - }; - } -}); - -tape( 'the method throws an error if provided an index argument which is out-of-bounds', function test( t ) { - var values; - var arr1; - var arr2; - var i; - - arr1 = new Float16Array( 10 ); - arr2 = []; - for ( i = 0; i < arr1.length; i++ ) { - arr2.push( 1.0 ); - } - - values = [ - 1, - 2, - 3, - 4, - 5 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr1.set( arr2, value ); - }; - } -}); - -tape( 'the method sets one or more array elements', function test( t ) { - var arr; - var v; - var i; - - arr = new Float16Array( 10 ); - - v = arr[ 0 ]; - t.strictEqual( v, 0.0, 'returns expected value' ); - - // No index argument: - arr.set( [ 1.0 ] ); - - v = arr[ 0 ]; - t.strictEqual( v, 1.0, 'returns expected value' ); - - arr.set( [ 0.0 ] ); - - // Index argument: - for ( i = 0; i < arr.length; i++ ) { - v = arr[ i ]; - t.strictEqual( v, 0.0, 'returns expected value' ); - - arr.set( [ 1.05 ], i ); - - v = arr[ i ]; - t.strictEqual( v, float64ToFloat16( 1.05 ), 'returns expected value' ); - } - - // Multiple values, no index argument: - arr.set( [ 1.05, 2.05 ] ); - - v = arr[ 0 ]; - t.strictEqual( v, float64ToFloat16( 1.05 ), 'returns expected value' ); - - v = arr[ 1 ]; - t.strictEqual( v, float64ToFloat16( 2.05 ), 'returns expected value' ); - - // Multiple values, index argument: - arr.set( [ 1.05, 2.05 ], 2 ); - - v = arr[ 2 ]; - t.strictEqual( v, float64ToFloat16( 1.05 ), 'returns expected value' ); - - v = arr[ 3 ]; - t.strictEqual( v, float64ToFloat16( 2.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method sets an array element (floating-point number array; shared buffer)', function test( t ) { - var byteOffset; - var arr; - var src; - var buf; - var ab; - var v; - var i; - - byteOffset = 112; - - ab = new ArrayBuffer( 240 ); - arr = new Float16Array( ab, byteOffset, 10 ); - - // Overlapping (requires copy), multiple values, no index argument: - buf = [ 1.05, 2.05 ]; - src = new Float16Array( ab, byteOffset-(1*arr.BYTES_PER_ELEMENT), 2 ); - for ( i = 0; i < buf.length; i++ ) { - src[ i ] = buf[ i ]; - } - arr.set( src ); - - v = arr[ 0 ]; - t.strictEqual( v, float64ToFloat16( buf[ 0 ] ), 'returns expected value' ); - - v = arr[ 1 ]; - t.strictEqual( v, float64ToFloat16( buf[ 1 ] ), 'returns expected value' ); - - // Overlapping (requires copy), multiple values, index argument: - buf = [ -1.05, -2.05 ]; - src = new Float16Array( ab, byteOffset+(1*arr.BYTES_PER_ELEMENT), 2 ); - for ( i = 0; i < buf.length; i++ ) { - src[ i ] = buf[ i ]; - } - arr.set( src, 2 ); - - v = arr[ 2 ]; - t.strictEqual( v, float64ToFloat16( buf[ 0 ] ), 'returns expected value' ); - - v = arr[ 3 ]; - t.strictEqual( v, float64ToFloat16( buf[ 1 ] ), 'returns expected value' ); - - // Overlapping (no copy), multiple values, no index argument: - buf = [ 3.05, 4.05 ]; - src = new Float16Array( ab, byteOffset+(1*arr.BYTES_PER_ELEMENT), 2 ); - for ( i = 0; i < buf.length; i++ ) { - src[ i ] = buf[ i ]; - } - arr.set( src ); - - v = arr[ 0 ]; - t.strictEqual( v, float64ToFloat16( buf[ 0 ] ), 'returns expected value' ); - - v = arr[ 1 ]; - t.strictEqual( v, float64ToFloat16( buf[ 1 ] ), 'returns expected value' ); - - // Overlapping (no copy), multiple values, index argument: - buf = [ -3.05, -4.05 ]; - src = new Float16Array( ab, byteOffset+(3*arr.BYTES_PER_ELEMENT), 2 ); - for ( i = 0; i < buf.length; i++ ) { - src[ i ] = buf[ i ]; - } - arr.set( src, 2 ); - - v = arr[ 2 ]; - t.strictEqual( v, float64ToFloat16( buf[ 0 ] ), 'returns expected value' ); - - v = arr[ 3 ]; - t.strictEqual( v, float64ToFloat16( buf[ 1 ] ), 'returns expected value' ); - - t.end(); -}); diff --git a/test/polyfill/test.slice.js b/test/polyfill/test.slice.js deleted file mode 100644 index f6743cb..0000000 --- a/test/polyfill/test.slice.js +++ /dev/null @@ -1,311 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 instanceOf = require( '@stdlib/assert-instance-of' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `slice` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'slice' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.slice ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.slice.call( value ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.slice( value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.slice( 0, value ); - }; - } -}); - -tape( 'the method returns an empty typed array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.slice(); - - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'if called without arguments, the method returns a typed array containing the same elements as the original array', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ) - ]); - actual = arr.slice(); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.notEqual( actual, arr, 'returns a new instance' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if called with one argument, the method returns a typed array containing elements starting from a specified beginning index (inclusive)', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ) - ]); - actual = arr.slice( 1 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if provided two arguments, the method returns a typed array containing elements starting from a specified beginning index (inclusive) and ending at a specified stop index (exclusive)', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ) - ]); - actual = arr.slice( 1, 3 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ) - ]); - actual = arr.slice( 1, 30 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method resolves negative indices relative to the last element', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ) - ]); - actual = arr.slice( -3, -1 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ) - ]); - actual = arr.slice( -30, -2 ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty typed array if a resolved beginning index exceeds a resolved ending index', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array( [] ); - actual = arr.slice( 2, 0 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty typed array if a resolved beginning index exceeds the maximum array index', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array( [] ); - actual = arr.slice( 5 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty typed array if a resolved ending index is less than or equal to zero', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); - expected = new Uint16Array( [] ); - actual = arr.slice( 2, -8 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - - actual = arr.slice( 1, 0 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); diff --git a/test/polyfill/test.some.js b/test/polyfill/test.some.js deleted file mode 100644 index dfa9cda..0000000 --- a/test/polyfill/test.some.js +++ /dev/null @@ -1,196 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `some` method for returning boolean indicating whether at least one element passes a test', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'some' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.some ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.some.call( value, predicate ); - }; - } - - function predicate( v ) { - return v === 1.0; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.some( value ); - }; - } -}); - -tape( 'the method returns `false` if operating on an empty floating-point number array', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( 0 ); - bool = arr.some( predicate ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns `true` if at least one element passes a test', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - bool = arr.some( predicate ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v === float64ToFloat16( 1.05 ); - } -}); - -tape( 'the method returns `false` if all elements fail a test', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - bool = arr.some( predicate ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v === float64ToFloat16( 5.05 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var bool; - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - bool = arr.some( predicate, ctx ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v === float64ToFloat16( 4.05 ); - } -}); - -tape( 'the method stops executing upon encountering the first element which passes a test', function test( t ) { - var bool; - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - bool = arr.some( predicate, ctx ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.strictEqual( ctx.count, 1, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v === float64ToFloat16( 1.05 ); - } -}); diff --git a/test/polyfill/test.sort.js b/test/polyfill/test.sort.js deleted file mode 100644 index 1ebbfd6..0000000 --- a/test/polyfill/test.sort.js +++ /dev/null @@ -1,189 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 instanceOf = require( '@stdlib/assert-instance-of' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Comparison function. -* -* @private -* @param {boolean} a - first value for comparison -* @param {boolean} b - second value for comparison -* @returns {number} comparison result -*/ -function compareFcn( a, b ) { - if ( a < b ) { - return -1; - } - if ( a > b ) { - return 1; - } - return 0; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `sort` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'sort' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.sort ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.sort.call( value, compareFcn ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.sort( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.sort( compareFcn ); - - t.strictEqual( out.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the method sorts elements of a floating-point number array in-place', function test( t ) { - var expected; - var arr; - var out; - var buf; - - arr = new Float16Array( [ 4.05, 3.05, 1.05, 5.05, 2.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ), - toWord( 5.05 ) - ]); - out = arr.sort( compareFcn ); - buf = new Uint16Array( out.buffer ); - - t.strictEqual( instanceOf( arr, Float16Array ), true, 'returns expected value' ); - t.strictEqual( out, arr, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - - arr = new Float16Array( [ 2.05, 1.05, -1.05, 0.05, -2.05 ] ); - expected = new Uint16Array([ - toWord( -2.05 ), - toWord( -1.05 ), - toWord( 0.05 ), - toWord( 1.05 ), - toWord( 2.05 ) - ]); - out = arr.sort( compareFcn ); - buf = new Uint16Array( out.buffer ); - - t.strictEqual( instanceOf( arr, Float16Array ), true, 'returns expected value' ); - t.strictEqual( out, arr, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Float16Array( [ 4.05, 3.05, 1.05, 5.05, 2.05 ] ); - out = arr.sort( compareFcn ); - - t.strictEqual( out.length, arr.length, 'returns expected value' ); - t.end(); -}); diff --git a/test/polyfill/test.subarray.js b/test/polyfill/test.subarray.js deleted file mode 100644 index c6d42d1..0000000 --- a/test/polyfill/test.subarray.js +++ /dev/null @@ -1,308 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 instanceOf = require( '@stdlib/assert-instance-of' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `subarray` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'subarray' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.subarray ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.subarray.call( value ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.subarray( value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.subarray( 0, value ); - }; - } -}); - -tape( 'the method returns empty array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.subarray(); - - t.strictEqual( out.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'if called without arguments, the method returns a view containing the same elements as the original array', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ) - ]); - actual = arr.subarray(); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if called with one argument, the method returns a view containing elements starting from a specified beginning index (inclusive)', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ) - ]); - actual = arr.subarray( 1 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if provided two arguments, the method returns a view containing elements starting from a specified beginning index (inclusive) and ending at a specified stop index (exclusive)', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ) - ]); - actual = arr.subarray( 1, 3 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method resolves negative indices relative to the last element', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ) - ]); - actual = arr.subarray( -3, -1 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 2.05 ) - ]); - actual = arr.subarray( -30, -2 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty view if a resolved beginning index exceeds a resolved ending index', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array( [] ); - actual = arr.subarray( 2, 0 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty view if a resolved beginning index exceeds the maximum array index', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array( [] ); - actual = arr.subarray( 5 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty view if a resolved ending index is less than or equal to zero', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array( [] ); - actual = arr.subarray( 2, -8 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - - actual = arr.subarray( 1, 0 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); diff --git a/test/polyfill/test.to_locale_string.js b/test/polyfill/test.to_locale_string.js deleted file mode 100644 index 96fb9b0..0000000 --- a/test/polyfill/test.to_locale_string.js +++ /dev/null @@ -1,187 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `toLocaleString` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'toLocaleString' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.toLocaleString ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.toLocaleString.call( value ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a string or an array of strings', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 0 ); - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - {}, - [ 1, 2, 3 ], - 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.toLocaleString( value ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a string or an array of strings (options)', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 0 ); - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - {}, - [ 1, 2, 3 ], - 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.toLocaleString( value, {} ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an object', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array(); - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - 'beep', - [], - 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.toLocaleString( 'en-GB', value ); - }; - } -}); - -tape( 'the method returns an empty string if invoked on an empty array', function test( t ) { - var str; - var arr; - - arr = new Float16Array( 0 ); - str = arr.toLocaleString(); - - t.strictEqual( str, '', 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a string representation of a floating-point number array', function test( t ) { - var expected; - var str; - var arr; - - arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - expected = '1,2,3'; - - str = arr.toLocaleString(); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); diff --git a/test/polyfill/test.to_reversed.js b/test/polyfill/test.to_reversed.js deleted file mode 100644 index a3f8da5..0000000 --- a/test/polyfill/test.to_reversed.js +++ /dev/null @@ -1,121 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 instanceOf = require( '@stdlib/assert-instance-of' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, '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( Float16Array.prototype, 'toReversed' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.toReversed ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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 floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - 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 buf; - var out; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05, 5.05 ] ); - expected = new Uint16Array([ - toWord( 5.05 ), - toWord( 4.05 ), - toWord( 3.05 ), - toWord( 2.05 ), - toWord( 1.05 ) - ]); - out = arr.toReversed(); - buf = new Uint16Array( out.buffer ); - - t.strictEqual( instanceOf( out, Float16Array ), true, 'returns expected value' ); - t.notEqual( out, arr, 'returns a new instance' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 10 ); - out = arr.toReversed(); - - t.strictEqual( out.length, 10, 'returns expected value' ); - t.end(); -}); diff --git a/test/polyfill/test.to_sorted.js b/test/polyfill/test.to_sorted.js deleted file mode 100644 index e011bef..0000000 --- a/test/polyfill/test.to_sorted.js +++ /dev/null @@ -1,172 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 instanceOf = require( '@stdlib/assert-instance-of' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Comparison function. -* -* @private -* @param {boolean} a - first value for comparison -* @param {boolean} b - second value for comparison -* @returns {number} comparison result -*/ -function compareFcn( a, b ) { - if ( a < b ) { - return -1; - } - if ( a > b ) { - return 1; - } - return 0; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `toSorted` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'toSorted' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.toSorted ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.toSorted.call( value, compareFcn ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.toSorted( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.toSorted( compareFcn ); - - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a new typed array containing elements in sorted order', function test( t ) { - var expected; - var arr; - var out; - var buf; - - arr = new Float16Array( [ 4.05, 3.05, 1.05, 5.05, 2.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ), - toWord( 5.05 ) - ]); - out = arr.toSorted( compareFcn ); - buf = new Uint16Array( out.buffer ); - - t.strictEqual( instanceOf( out, Float16Array ), true, 'returns expected value' ); - t.notEqual( out, arr, 'returns a new instance' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Float16Array( [ 4.05, 3.05, 1.05, 5.05, 2.05 ] ); - out = arr.toSorted( compareFcn ); - - t.strictEqual( out.length, arr.length, 'returns expected value' ); - t.end(); -}); diff --git a/test/polyfill/test.to_string.js b/test/polyfill/test.to_string.js deleted file mode 100644 index b0c098b..0000000 --- a/test/polyfill/test.to_string.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `toString` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.toString ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.toString.call( value ); - }; - } -}); - -tape( 'the method returns an empty string if invoked on an empty array', function test( t ) { - var str; - var arr; - - arr = new Float16Array( 0 ); - str = arr.toString(); - - t.strictEqual( str, '', 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a string representation of a floating-point number array', function test( t ) { - var expected; - var str; - var arr; - - arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - expected = '1,2,3,4'; - - str = arr.toString(); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); diff --git a/test/polyfill/test.values.js b/test/polyfill/test.values.js deleted file mode 100644 index ce5fc09..0000000 --- a/test/polyfill/test.values.js +++ /dev/null @@ -1,264 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 proxyquire = require( 'proxyquire' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var isNumber = require( '@stdlib/assert-is-number' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `values` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'values' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.values ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.values.call( value ); - }; - } -}); - -tape( 'the method returns an iterator protocol-compliant object', function test( t ) { - var expected; - var arr; - var it; - var i; - var r; - var e; - - arr = new Float16Array( [ 1.05, 2.05 ] ); - expected = [ - { - 'value': float64ToFloat16( 1.05 ), - 'done': false - }, - { - 'value': float64ToFloat16( 2.05 ), - 'done': false - }, - { - 'done': true - } - ]; - it = arr.values(); - - t.strictEqual( typeof it, 'object', 'returns expected value' ); - t.strictEqual( typeof it.next, 'function', 'has next method' ); - - for ( i = 0; i < expected.length; i++ ) { - r = it.next(); - e = expected[ i ]; - if ( e.value === void 0 ) { - t.deepEqual( r, e, 'returns expected value' ); - } else { - t.strictEqual( isNumber( r.value ), true, 'returns expected value' ); - t.strictEqual( r.value, e.value, 'returns expected value' ); - t.strictEqual( r.done, e.done, 'returns expected value' ); - } - } - - t.end(); -}); - -tape( 'the method returns an iterator which does not iterate over empty arrays', function test( t ) { - var expected; - var arr; - var it; - var i; - var v; - - arr = new Float16Array( [] ); - expected = [ - { - 'done': true - }, - { - 'done': true - }, - { - 'done': true - } - ]; - it = arr.values(); - - t.strictEqual( typeof it, 'object', 'returns expected value' ); - t.strictEqual( typeof it.next, 'function', 'has next method' ); - - for ( i = 0; i < expected.length; i++ ) { - v = it.next(); - t.deepEqual( v, expected[ i ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (no argument)', function test( t ) { - var arr; - var it; - var v; - - arr = new Float16Array( [ 1.05, 2.05, 3.05 ] ); - it = arr.values(); - - v = it.next(); - t.strictEqual( v.value, float64ToFloat16( 1.05 ), 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, float64ToFloat16( 2.05 ), 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.return(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (argument)', function test( t ) { - var arr; - var it; - var v; - - arr = new Float16Array( [ 1.05, 2.05, 3.05 ] ); - it = arr.values(); - - v = it.next(); - t.strictEqual( v.value, float64ToFloat16( 1.05 ), 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, float64ToFloat16( 2.05 ), 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.return( 'beep' ); - t.strictEqual( v.value, 'beep', 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'if an environment supports `Symbol.iterator`, the method returns an iterable', function test( t ) { - var Float16Array; - var arr; - var buf; - var it1; - var it2; - var v1; - var v2; - var i; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - buf = [ 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( buf ); - - it1 = arr.values(); - t.strictEqual( typeof it1[ '__ITERATOR_SYMBOL__' ], 'function', 'has method' ); - t.strictEqual( it1[ '__ITERATOR_SYMBOL__' ].length, 0, 'has zero arity' ); - - it2 = it1[ '__ITERATOR_SYMBOL__' ](); - t.strictEqual( typeof it2, 'object', 'returns expected value' ); - t.strictEqual( typeof it2.next, 'function', 'has `next` method' ); - t.strictEqual( typeof it2.return, 'function', 'has `return` method' ); - - for ( i = 0; i < arr.length; i++ ) { - v1 = it1.next().value; - v2 = it2.next().value; - t.strictEqual( v1, v2, 'returns expected value' ); - } - t.end(); -}); - -tape( 'if an environment does not support `Symbol.iterator`, the method does not return an "iterable"', function test( t ) { - var Float16Array; - var arr; - var buf; - var it; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/symbol-iterator': false - }); - - buf = [ 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( buf ); - - it = arr.values(); - t.strictEqual( it[ ITERATOR_SYMBOL ], void 0, 'does not have property' ); - - t.end(); -}); diff --git a/test/polyfill/test.with.js b/test/polyfill/test.with.js deleted file mode 100644 index 0b6eda1..0000000 --- a/test/polyfill/test.with.js +++ /dev/null @@ -1,213 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `with` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'with' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.with ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.with.call( value, 0, true ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 3.14, - 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.with( value, true ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not in bounds', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - -11, - -12, - 11, - 12 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.with( value, 1.0 ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not a numeric value', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 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.with( 0, value ); - }; - } -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 10 ); - out = arr.with( 5, 1.0 ); - - t.strictEqual( out.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a new floating-point number array with the element at a provided index replaced with a provided value', function test( t ) { - var expected; - var arr; - var buf; - var out; - - arr = new Float16Array( [ 1.05, 1.05, 1.05, 1.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 1.05 ), - toWord( 1.05 ), - toWord( 2.05 ) - ]); - out = arr.with( 3, 2.05 ); - buf = new Uint16Array( out.buffer ); - - t.strictEqual( out instanceof Float16Array, true, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.notEqual( out, arr, 'returns new instance' ); - t.end(); -}); - -tape( 'the method supports negative indices', function test( t ) { - var expected; - var arr; - var buf; - var out; - - arr = new Float16Array( [ 1.05, 1.05, 1.05, 1.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 1.05 ), - toWord( 1.05 ), - toWord( 2.05 ) - ]); - out = arr.with( -1, 2.05 ); - buf = new Uint16Array( out.buffer ); - - t.strictEqual( out instanceof Float16Array, true, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.at.js b/test/test.at.js deleted file mode 100644 index 19df3bd..0000000 --- a/test/test.at.js +++ /dev/null @@ -1,111 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `at` method for returning an array element', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.at ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.at.call( value, 0 ); - }; - } -}); - -tape( 'the method returns `undefined` if provided an index which exceeds array dimensions', function test( t ) { - var arr; - var v; - var i; - - arr = new Float16Array( 10 ); - for ( i = -arr.length; i < arr.length; i++ ) { - if ( i < 0 ) { - v = arr.at( i-arr.length ); - t.strictEqual( v, void 0, 'returns expected value for index '+(i-arr.length) ); - } else { - v = arr.at( arr.length+i ); - t.strictEqual( v, void 0, 'returns expected value for index '+(arr.length+i) ); - } - } - t.end(); -}); - -tape( 'the method returns an array element', function test( t ) { - var arr; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( i+0.05 ); - } - - arr = new Float16Array( arr ); - - for ( i = -arr.length; i < arr.length; i++ ) { - v = arr.at( i ); - if ( i < 0 ) { - t.strictEqual( v, float64ToFloat16( arr.length + i + 0.05 ), 'returns expected value for index '+i ); - } else { - t.strictEqual( v, float64ToFloat16( i + 0.05 ), 'returns expected value for index '+i ); - } - } - t.end(); -}); diff --git a/test/test.copy_within.js b/test/test.copy_within.js deleted file mode 100644 index d286509..0000000 --- a/test/test.copy_within.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `copyWithin` method for copying a sequence of array elements within a floating-point number array', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within an array', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( 0, 3 ); - buf = new Uint16Array( arr.buffer ); - - // Overwritten: - t.strictEqual( buf[ 0 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 4.05 ), 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 2 ], toWord( 2.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (negative target)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( -arr.length, 3 ); - buf = new Uint16Array( arr.buffer ); - - // Overwritten: - t.strictEqual( buf[ 0 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 4.05 ), 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 2 ], toWord( 2.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (negative start)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( 0, -2 ); - buf = new Uint16Array( arr.buffer ); - - // Overwritten: - t.strictEqual( buf[ 0 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 4.05 ), 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 2 ], toWord( 2.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (end=length)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( 0, 3, arr.length ); - buf = new Uint16Array( arr.buffer ); - - // Overwritten: - t.strictEqual( buf[ 0 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 4.05 ), 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 2 ], toWord( 2.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (non-inclusive end)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( 2, 0, 2 ); - buf = new Uint16Array( arr.buffer ); - - // Remain the same: - t.strictEqual( buf[ 0 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - - // Overwritten: - t.strictEqual( buf[ 2 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 1.05 ), 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (negative end)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( 2, 0, -3 ); - buf = new Uint16Array( arr.buffer ); - - // Remain the same: - t.strictEqual( buf[ 0 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - - // Overwritten: - t.strictEqual( buf[ 2 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 1.05 ), 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (target >= length)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( arr.length, 3 ); - buf = new Uint16Array( arr.buffer ); - - // Remain the same: - t.strictEqual( buf[ 0 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 2 ], toWord( 2.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (target > start)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( 2, 0 ); - buf = new Uint16Array( arr.buffer ); - - // Remain the same: - t.strictEqual( buf[ 0 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - - // Overwritten: - t.strictEqual( buf[ 2 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 4 ], toWord( 2.05 ), 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.entries.js b/test/test.entries.js deleted file mode 100644 index 396dd8e..0000000 --- a/test/test.entries.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isNumber = require( '@stdlib/assert-is-number' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `entries` method for returning an iterator for iterating over array key-value pairs', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.entries ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.entries.call( value ); - }; - } -}); - -tape( 'the method returns an iterator protocol-compliant object', function test( t ) { - var buf; - var arr; - var it; - var v; - var i; - - buf = [ 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( buf ); - - it = arr.entries(); - t.strictEqual( it.next.length, 0, 'has zero arity' ); - - for ( i = 0; i < arr.length; i++ ) { - v = it.next(); - t.strictEqual( isArray( v.value ), true, 'returns expected value' ); - t.strictEqual( v.value[ 0 ], i, 'returns expected value' ); - t.strictEqual( isNumber( v.value[ 1 ] ), true, 'returns expected value' ); - t.strictEqual( v.value[ 1 ], float64ToFloat16( buf[ i ] ), 'returns expected value' ); - t.strictEqual( typeof v.done, 'boolean', 'returns expected value' ); - } - t.end(); -}); diff --git a/test/test.every.js b/test/test.every.js deleted file mode 100644 index 0742d6a..0000000 --- a/test/test.every.js +++ /dev/null @@ -1,172 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `every` method for returning boolean indicating whether all elements pass a test', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.every ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.every.call( value, predicate ); - }; - } - - function predicate( v ) { - return v === 0.0; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.every( value ); - }; - } -}); - -tape( 'the method returns `true` if operating on an empty floating-point number array', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( 0 ); - bool = arr.every( predicate ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns `true` if all elements pass a test', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 1.05, 1.05, 1.05 ] ); - bool = arr.every( predicate ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v === float64ToFloat16( 1.05 ); - } -}); - -tape( 'the method returns `false` if one or more elements fail a test', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 1.05, 0.05, 1.05 ] ); - bool = arr.every( predicate ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v === float64ToFloat16( 1.05 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var bool; - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ 1.05, 1.05, 1.05, 1.05 ] ); - bool = arr.every( predicate, ctx ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v === float64ToFloat16( 1.05 ); - } -}); diff --git a/test/test.fill.js b/test/test.fill.js deleted file mode 100644 index d434060..0000000 --- a/test/test.fill.js +++ /dev/null @@ -1,212 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `fill` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.fill ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.fill.call( value, 1.0 ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.fill( 1.05 ); - - t.strictEqual( out instanceof Float16Array, true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 10 ); - out = arr.fill( 1.05 ); - - t.strictEqual( out, arr, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'if called with one argument, the method sets each array element to the provided value', function test( t ) { - var arr; - var buf; - var i; - - arr = new Float16Array( 3 ); - arr.fill( 1.05 ); - - buf = new Uint16Array( arr.buffer ); - - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( buf[ i ], toWord( 1.05 ), 'returns expected value' ); - } - - t.end(); -}); - -tape( 'if called with two arguments, the method sets each array element to the provided value starting from a start index (inclusive)', function test( t ) { - var arr; - var buf; - - arr = new Float16Array( 3 ); - buf = new Uint16Array( arr.buffer ); - - arr.fill( 1.05, 1 ); - - t.strictEqual( buf[ 0 ], toWord( 0.0 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 2 ], toWord( 1.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'if called with three arguments, the method sets each array element to the provided value starting from a start index (inclusive) until a specified end index (exclusive)', function test( t ) { - var arr; - var buf; - - arr = new Float16Array( 3 ); - buf = new Uint16Array( arr.buffer ); - - arr.fill( 1.05, 0, 2 ); - - t.strictEqual( buf[ 0 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 2 ], toWord( 0.0 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method supports negative indices', function test( t ) { - var arr; - var buf; - - arr = new Float16Array( 3 ); - buf = new Uint16Array( arr.buffer ); - - arr.fill( 1.05, -3, -1 ); - - t.strictEqual( buf[ 0 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 2 ], toWord( 0.0 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'if a provided start index resolves to a negative index, the method fills an array starting from the first element', function test( t ) { - var arr; - var buf; - var i; - - arr = new Float16Array( 3 ); - buf = new Uint16Array( arr.buffer ); - - arr.fill( 1.05, -10 ); - - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( buf[ i ], toWord( 1.05 ), 'returns expected value' ); - } - - t.end(); -}); - -tape( 'if a provided end index resolves to an index exceeding the last array element index, the method fills an array until the last element (inclusive)', function test( t ) { - var arr; - var buf; - var i; - - arr = new Float16Array( 3 ); - buf = new Uint16Array( arr.buffer ); - - arr.fill( 1.05, 1, 10 ); - - t.strictEqual( buf[ 0 ], toWord( 0.0 ), 'returns expected value' ); - for ( i = 1; i < arr.length; i++ ) { - t.strictEqual( buf[ i ], toWord( 1.05 ), 'returns expected value' ); - } - - t.end(); -}); - -tape( 'if a provided start index resolves to an index which is greater than or equal to a resolved end index, the method does not fill an array', function test( t ) { - var arr; - var buf; - - arr = new Float16Array( 3 ); - buf = new Uint16Array( arr.buffer ); - - arr.fill( 1.0, 2, 1 ); - - t.strictEqual( buf[ 0 ], toWord( 0.0 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 0.0 ), 'returns expected value' ); - t.strictEqual( buf[ 2 ], toWord( 0.0 ), 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.filter.js b/test/test.filter.js deleted file mode 100644 index 1b77a61..0000000 --- a/test/test.filter.js +++ /dev/null @@ -1,224 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `filter` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.filter ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.filter.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( v === 1.0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.filter( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.filter( predicate ); - - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v === 1.0 ); - } -}); - -tape( 'the method returns a new floating-point number array containing only those elements which satisfy a test condition', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 1.05, 2.05 ] ); - expected = new Uint16Array( [ toWord( 1.05 ), toWord( 1.05 ) ] ); - actual = arr.filter( predicate ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v === float64ToFloat16( 1.05 ) ); - } -}); - -tape( 'the method copies all elements to a new array if all elements satisfy a test condition', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ) - ]); - actual = arr.filter( predicate ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.notEqual( actual, arr, 'returns a new instance' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v > 1.0 ); - } -}); - -tape( 'the method returns an empty array if no elements satisfy a test condition', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array( [] ); - actual = arr.filter( predicate ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.notEqual( actual, arr, 'returns a new instance' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 1.0 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var expected; - var actual; - var arr; - var buf; - var ctx; - - arr = new Float16Array( [ 1.05, 2.05, 1.05, 1.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 1.05 ), - toWord( 1.05 ) - ]); - ctx = { - 'count': 0 - }; - actual = arr.filter( predicate, ctx ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v === float64ToFloat16( 1.05 ) ); - } -}); diff --git a/test/test.find.js b/test/test.find.js deleted file mode 100644 index 1836dc3..0000000 --- a/test/test.find.js +++ /dev/null @@ -1,172 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `find` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.find ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.find.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( v === 1.0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.find( value ); - }; - } -}); - -tape( 'the method returns `undefined` if operating on an empty floating-point number array', function test( t ) { - var arr; - var v; - - arr = new Float16Array( 0 ); - v = arr.find( predicate ); - - t.strictEqual( v, void 0, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns the first element which passes a test', function test( t ) { - var arr; - var v; - - arr = new Float16Array( [ 1.05, -2.05, 3.05, -4.05 ] ); - v = arr.find( predicate ); - - t.strictEqual( v, float64ToFloat16( -2.05 ), 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method returns `undefined` if all elements fail a test', function test( t ) { - var arr; - var v; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - v = arr.find( predicate ); - - t.strictEqual( v, void 0, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - var v; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ -1.05, -2.05, 3.05, 4.05, 5.05 ] ); - v = arr.find( predicate, ctx ); - - t.strictEqual( v, float64ToFloat16( 3.05 ), 'returns expected value' ); - t.strictEqual( ctx.count, 3, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v > 0.0 ); - } -}); diff --git a/test/test.find_index.js b/test/test.find_index.js deleted file mode 100644 index b3e9023..0000000 --- a/test/test.find_index.js +++ /dev/null @@ -1,171 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `findIndex` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.findIndex ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.findIndex.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( v === 1.0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.findIndex( value ); - }; - } -}); - -tape( 'the method returns `-1` if operating on an empty floating-point number array', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( 0 ); - idx = arr.findIndex( predicate ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns the index of the first element which passes a test', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( [ 1.05, -2.05, 3.05, -4.05 ] ); - idx = arr.findIndex( predicate ); - - t.strictEqual( idx, 1, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0); - } -}); - -tape( 'the method returns `-1` if all elements fail a test', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - idx = arr.findIndex( predicate ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - var idx; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ -1.05, -2.05, 3.05, 4.05, 5.05 ] ); - idx = arr.findIndex( predicate, ctx ); - - t.strictEqual( idx, 2, 'returns expected value' ); - t.strictEqual( ctx.count, 3, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v > 0.0 ); - } -}); diff --git a/test/test.find_last.js b/test/test.find_last.js deleted file mode 100644 index 4451b22..0000000 --- a/test/test.find_last.js +++ /dev/null @@ -1,172 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `findLast` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.findLast ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.findLast.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( v === 0.0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.findLast( value ); - }; - } -}); - -tape( 'the method returns `undefined` if operating on an empty floating-point number array', function test( t ) { - var arr; - var v; - - arr = new Float16Array( 0 ); - v = arr.findLast( predicate ); - - t.strictEqual( v, void 0, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns the last element which passes a test', function test( t ) { - var arr; - var v; - - arr = new Float16Array( [ 1.05, -2.05, 3.05, -4.05 ] ); - v = arr.findLast( predicate ); - - t.strictEqual( v, float64ToFloat16( -4.05 ), 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method returns `undefined` if all elements fail a test', function test( t ) { - var arr; - var v; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - v = arr.findLast( predicate ); - - t.strictEqual( v, void 0, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - var v; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ -1.05, -2.05, 3.05, 4.05, 5.05 ] ); - v = arr.findLast( predicate, ctx ); - - t.strictEqual( v, float64ToFloat16( 5.05 ), 'returns expected value' ); - t.strictEqual( ctx.count, 1, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v > 0.0 ); - } -}); diff --git a/test/test.find_last_index.js b/test/test.find_last_index.js deleted file mode 100644 index c303468..0000000 --- a/test/test.find_last_index.js +++ /dev/null @@ -1,171 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `findLastIndex` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.findLastIndex ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.findLastIndex.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( v === 1.0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.findLastIndex( value ); - }; - } -}); - -tape( 'the method returns `-1` if operating on an empty floating-point number array', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( 0 ); - idx = arr.findLastIndex( predicate ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns the index of the last element which passes a test', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( [ 1.05, -2.05, 3.05, -4.05 ] ); - idx = arr.findLastIndex( predicate ); - - t.strictEqual( idx, 3, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method returns `-1` if all elements fail a test', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - idx = arr.findLastIndex( predicate ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - var idx; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ -1.05, -2.05, 3.05, 4.05, 5.05 ] ); - idx = arr.findLastIndex( predicate, ctx ); - - t.strictEqual( idx, 4, 'returns expected value' ); - t.strictEqual( ctx.count, 1, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v > 0.0 ); - } -}); diff --git a/test/test.for_each.js b/test/test.for_each.js deleted file mode 100644 index af6afda..0000000 --- a/test/test.for_each.js +++ /dev/null @@ -1,194 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `forEach` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.forEach ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.forEach.call( value, fcn ); - }; - } - - function fcn( v ) { - if ( !isNumber( v ) ) { - t.fail( 'should be a number' ); - } - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.forEach( value ); - }; - } -}); - -tape( 'the method should not invoke a provided callback function if operating on an empty floating-point array', function test( t ) { - var arr; - - arr = new Float16Array( 0 ); - arr.forEach( fcn ); - - t.end(); - - function fcn() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns `undefined`', function test( t ) { - var arr; - var out; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - out = arr.forEach( fcn ); - - t.strictEqual( out, void 0, 'returns expected value' ); - t.end(); - - function fcn( v ) { - if ( !isNumber( v ) ) { - t.fail( 'should be a number' ); - } - } -}); - -tape( 'the method invokes a provided function for each element in an array', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var arr; - - indices = []; - values = []; - arrays = []; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - arr.forEach( fcn ); - - expected = [ - float64ToFloat16( 1.05 ), - float64ToFloat16( 2.05 ), - float64ToFloat16( 3.05 ), - float64ToFloat16( 4.05 ) - ]; - - t.deepEqual( values, expected, 'returns expected value' ); - t.deepEqual( indices, [ 0, 1, 2, 3 ], 'returns expected value' ); - t.strictEqual( arrays[ 0 ], arr, 'returns expected value' ); - t.strictEqual( arrays[ 1 ], arr, 'returns expected value' ); - t.strictEqual( arrays[ 2 ], arr, 'returns expected value' ); - t.strictEqual( arrays[ 3 ], arr, 'returns expected value' ); - - t.end(); - - function fcn( v, i, arr ) { - values.push( v ); - indices.push( i ); - arrays.push( arr ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - arr.forEach( fcn, ctx ); - - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function fcn() { - this.count += 1; // eslint-disable-line no-invalid-this - } -}); diff --git a/test/test.from.js b/test/test.from.js deleted file mode 100644 index 15a43a2..0000000 --- a/test/test.from.js +++ /dev/null @@ -1,309 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 Uint16Array = require( '@stdlib/array-uint16' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is a `from` method for creating a 16-bit floating-point number array from an array-like object or an iterable', function test( t ) { - var arr; - - t.strictEqual( isFunction( Float16Array.from ), true, 'has method' ); - - arr = Float16Array.from( [] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a constructor', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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 Float16Array.from.call( value, [] ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array constructor', function test( t ) { - var values; - var i; - - values = [ - {}, - null, - 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 Float16Array.from.call( value, [] ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - {}, - [] - ]; - 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 Float16Array.from( [], value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not a function (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - {}, - [] - ]; - 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 Float16Array.from( [], value, {} ); - }; - } -}); - -tape( 'the method returns a floating-point number array', function test( t ) { - var arr; - var v; - - // Generic array: - arr = Float16Array.from( [] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Float16Array.from( [ 1.0, 2.0, 3.0, 4.0 ] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - // Generic array containing non-numeric values: - arr = Float16Array.from( [ 'beep' ] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - arr = Float16Array.from( [ null, 4 ] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - arr = Float16Array.from( [ true, {}, '' ] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 3, 'returns expected value' ); - - // Typed array: - arr = Float16Array.from( new Uint16Array( 0 ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Float16Array.from( new Uint16Array( [ 1, 1 ] ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // Floating-point number typed array: - arr = Float16Array.from( new Float16Array( 0 ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Float16Array.from( new Float16Array( [ 1.0, 2.0 ] ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method supports providing a "map" function which is invoked for each source element', function test( t ) { - var arr; - var v; - - // Generic array: - arr = Float16Array.from( [], clbk1 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Float16Array.from( [ 1.0, 2.0, 3.0, 4.0 ], clbk1 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - // Generic array containing non-numeric values: - arr = Float16Array.from( [ 'beep' ], clbk2 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - arr = Float16Array.from( [ null ], clbk2 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - arr = Float16Array.from( [ [], {} ], clbk1 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - arr = Float16Array.from( [ 4, 5 ], clbk1 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // Typed array: - arr = Float16Array.from( new Uint16Array( 0 ), clbk1 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Float16Array.from( new Uint16Array( [ 1, 1 ] ), clbk1 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // Floating-point number typed array: - arr = Float16Array.from( new Float16Array( 0 ), clbk2 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Float16Array.from( new Float16Array( [ true, true ] ), clbk2 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - t.end(); - - function clbk1( v ) { - return v; - } - - function clbk2() { - return true; - } -}); - -tape( 'the method supports providing a `this` context for a provided map function', function test( t ) { - var arr; - var ctx; - - ctx = { - 'count': 0 - }; - arr = Float16Array.from( [ 1.0, 2.0, 3.0, 4.0 ], clbk1, ctx ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function clbk1( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v; - } -}); diff --git a/test/test.includes.js b/test/test.includes.js deleted file mode 100644 index a367b40..0000000 --- a/test/test.includes.js +++ /dev/null @@ -1,160 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `includes` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.includes ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.includes.call( value, true ); - }; - } -}); - -tape( 'the method returns `false` if operating on an empty floating-point number array', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( 0 ); - bool = arr.includes( 1.0 ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `false` if a floating-point number is not found', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( 10 ); - bool = arr.includes( 1.0 ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `true` if an array contains a specified floating-point number', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05] ); - bool = arr.includes( float64ToFloat16( 1.05 ) ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `false` if provided a second argument which exceeds the input array length', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( 10 ); - bool = arr.includes( 0.0, 20 ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 1.05, 1.05, 1.05 ] ); - - bool = arr.includes( float64ToFloat16( 1.05 ), 0 ); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = arr.includes( float64ToFloat16( 2.05 ), 1 ); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = arr.includes( float64ToFloat16( 2.05 ), 3 ); - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index (negative)', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 1.05, 1.05, 1.05 ] ); - - bool = arr.includes( float64ToFloat16( 1.05 ), -5 ); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = arr.includes( float64ToFloat16( 2.05 ), -2 ); - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'when provided a starting index which resolves to an index which is less than zero, the method searches from the first array element', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 1.05, 1.05, 1.05 ] ); - - bool = arr.includes( float64ToFloat16( 1.05 ), -10 ); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = arr.includes( float64ToFloat16( 2.05 ), -10 ); - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.index_of.js b/test/test.index_of.js deleted file mode 100644 index 2a684aa..0000000 --- a/test/test.index_of.js +++ /dev/null @@ -1,160 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `indexOf` method for returning the index of an array element', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.indexOf ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.indexOf.call( value, 1.0 ); - }; - } -}); - -tape( 'the method returns `-1` if operating on an empty floating-point number array', function test( t ) { - var arr; - var idx; - - arr = new Float16Array(); - idx = arr.indexOf( 1.0 ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `-1` if a numeric value is not found', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( 10 ); - idx = arr.indexOf( 1.0 ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns the index of the first match if a numeric value is found', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - idx = arr.indexOf( float64ToFloat16( 2.05 ) ); - - t.strictEqual( idx, 1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `-1` if provided a second argument which exceeds the input array length', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( 10 ); - idx = arr.indexOf( 1.0, 20 ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 2.05, 5.05 ] ); - - idx = arr.indexOf( float64ToFloat16( 2.05 ), 0 ); - t.strictEqual( idx, 1, 'returns expected value' ); - - idx = arr.indexOf( float64ToFloat16( 2.05 ), 2 ); - t.strictEqual( idx, 3, 'returns expected value' ); - - idx = arr.indexOf( float64ToFloat16( 2.05 ), 4 ); - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index (negative)', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 2.05, 5.05 ] ); - - idx = arr.indexOf( float64ToFloat16( 2.05 ), -5 ); - t.strictEqual( idx, 1, 'returns expected value' ); - - idx = arr.indexOf( float64ToFloat16( 2.05 ), -1 ); - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'when provided a starting index which resolves to an index which is less than zero, the method searches from the first array element', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 2.05, 5.05 ] ); - - idx = arr.indexOf( float64ToFloat16( 2.05 ), -10 ); - t.strictEqual( idx, 1, 'returns expected value' ); - - idx = arr.indexOf( float64ToFloat16( 1.05 ), -10 ); - t.strictEqual( idx, 0, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.join.js b/test/test.join.js deleted file mode 100644 index 800bb1f..0000000 --- a/test/test.join.js +++ /dev/null @@ -1,141 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `join` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.join ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.join.call( value ); - }; - } -}); - -tape( 'the method returns an empty string if invoked on an empty array', function test( t ) { - var str; - var arr; - - arr = new Float16Array( 0 ); - str = arr.join(); - - t.strictEqual( str, '', 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a string representation of a floating-point number array with elements separated by a separator', function test( t ) { - var expected; - var str; - var arr; - var i; - - arr = new Float16Array( [ 0.05, 1.05, 2.05, 3.05, 4.05 ] ); - - expected = float64ToFloat16( 0.05 ); - for ( i = 1; i < arr.length; i++ ) { - expected += '@' + float64ToFloat16( i + 0.05 ); - } - - str = arr.join( '@' ); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a string representation of a floating-point number array with elements separated by a separator (single element)', function test( t ) { - var expected; - var str; - var arr; - - arr = new Float16Array( [ 1.05 ] ); - expected = '' + float64ToFloat16( 1.05 ); - - str = arr.join(); - - t.strictEqual( str, expected, 'returns expected value' ); - - arr = new Float16Array( [ 1.05 ] ); - expected = '' + float64ToFloat16( 1.05 ); - - str = arr.join( '@' ); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if the method is invoked without a separator argument, the method returns a string representation of a floating-point number array with elements separated by a comma', function test( t ) { - var expected; - var str; - var arr; - var i; - - arr = new Float16Array( [ 0.05, 1.05, 2.05, 3.05, 4.05 ] ); - - expected = float64ToFloat16( 0.05 ); - for ( i = 1; i < arr.length; i++ ) { - expected += ',' + float64ToFloat16( i + 0.05 ); - } - - str = arr.join(); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 930feef..0000000 --- a/test/test.js +++ /dev/null @@ -1,320 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var arr = new Float16Array( 0 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (no argument)', function test( t ) { - var arr = new Float16Array(); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (length)', function test( t ) { - var arr = new Float16Array( 10 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (array)', function test( t ) { - var arr = new Float16Array( [] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (typed array)', function test( t ) { - var arr = new Float16Array( new Uint16Array( 0 ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (ArrayBuffer)', function test( t ) { - var arr = new Float16Array( new ArrayBuffer( 0 ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (ArrayBuffer, byte offset)', function test( t ) { - var arr = new Float16Array( new ArrayBuffer( 8 ), 8 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (ArrayBuffer, byte offset, length)', function test( t ) { - var arr = new Float16Array( new ArrayBuffer( 8 ), 8, 0 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the constructor is a property returning the number of bytes per array element', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Float16Array.BYTES_PER_ELEMENT, 2, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the constructor is a property returning the constructor name', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array, 'name' ), true, 'has property' ); - t.strictEqual( Float16Array.name, 'Float16Array', 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance having a `BYTES_PER_ELEMENT` property returning the number of bytes per array element', function test( t ) { - var arr; - - t.strictEqual( hasOwnProp( Float16Array.prototype, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Float16Array.prototype.BYTES_PER_ELEMENT, 2, 'returns expected value' ); - - arr = new Float16Array( 0 ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance having a `buffer` property for returning the underlying memory (i.e., ArrayBuffer)', function test( t ) { - var arr; - var buf; - - arr = new Float16Array( 0 ); - buf = arr.buffer; - t.strictEqual( isArrayBuffer( buf ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance having a `byteLength` property for returning the number of bytes belonging to the array view', function test( t ) { - var arr; - var v; - - arr = new Float16Array( 0 ); - v = arr.byteLength; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( new ArrayBuffer( 64 ), 8 ); - v = arr.byteLength; - t.strictEqual( v, 56, 'returns expected value' ); - - arr = new Float16Array( new ArrayBuffer( 64 ), 64 ); - v = arr.byteLength; - t.strictEqual( v, 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance having a `byteOffset` property for returning the byte offset pointing to the first array element in the underlying memory', function test( t ) { - var arr; - var v; - - arr = new Float16Array( 0 ); - v = arr.byteOffset; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( new ArrayBuffer( 64 ), 32 ); - v = arr.byteOffset; - t.strictEqual( v, 32, 'returns expected value' ); - - arr = new Float16Array( new ArrayBuffer( 64 ), 64 ); - v = arr.byteOffset; - t.strictEqual( v, 64, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance having a `length` property for returning the number of array elements', function test( t ) { - var arr; - var v; - - // No arguments: - arr = new Float16Array(); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - // Explicit array length: - arr = new Float16Array( 0 ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( 10 ); - v = arr.length; - t.strictEqual( v, 10, 'returns expected value' ); - - // Generic array: - arr = new Float16Array( [] ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - // Typed array: - arr = new Float16Array( new Uint16Array( 0 ) ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( new Uint16Array( [ 1.0, 1.0 ] ) ); - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // Float16 typed array: - arr = new Float16Array( new Float16Array( 0 ) ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( new Float16Array( [ 1.0, 2.0 ] ) ); - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // ArrayBuffer: - arr = new Float16Array( new ArrayBuffer( 64 ), 32 ); - v = arr.length; - t.strictEqual( v, 16, 'returns expected value' ); - - arr = new Float16Array( new ArrayBuffer( 64 ), 64 ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( new ArrayBuffer( 64 ), 32, 2 ); - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor throws an error if provided an ArrayBuffer which is not a multiple of 2', function test( t ) { - var values; - var i; - - values = [ - 1, - 3, - 5, - 7, - 9, - 11, - 101, - 1001 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided an ArrayBuffer having a byte length equal to '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Float16Array( new ArrayBuffer( value ) ); - }; - } -}); - -tape( 'the constructor throws an error if provided a byte offset argument which is not a multiple of 2', function test( t ) { - var values; - var i; - - values = [ - 1, - 3, - 5, - 7, - 9, - 11, - 101, - 1001 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Float16Array( new ArrayBuffer( 1e3 ), value ); - }; - } -}); - -tape( 'the constructor throws an error if provided a byte offset argument such that the view byte length is not a multiple of 8', function test( t ) { - var values; - var i; - - values = [ - 2, - 4, - 6, - 8, - 10, - 12, - 14, - 16, - 18, - 20 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Float16Array( new ArrayBuffer( 101 ), value ); - }; - } -}); - -tape( 'the constructor throws an error if provided insufficient memory to accommodate byte offset and length arguments', function test( t ) { - var values; - var i; - - values = [ - 8, - 16, - 24, - 32 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Float16Array( new ArrayBuffer( 100 ), value, 1e3 ); - }; - } -}); diff --git a/test/test.keys.js b/test/test.keys.js deleted file mode 100644 index 283d682..0000000 --- a/test/test.keys.js +++ /dev/null @@ -1,144 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `keys` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.keys ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.keys.call( value ); - }; - } -}); - -tape( 'the method returns an iterator protocol-compliant object', function test( t ) { - var expected; - var arr; - var it; - var i; - var r; - var e; - - arr = new Float16Array( [ 1.05, 2.05 ] ); - expected = [ - { - 'value': 0, - 'done': false - }, - { - 'value': 1, - 'done': false - }, - { - 'done': true - } - ]; - it = arr.keys(); - - t.strictEqual( typeof it, 'object', 'returns expected value' ); - t.strictEqual( typeof it.next, 'function', 'has next method' ); - - for ( i = 0; i < expected.length; i++ ) { - r = it.next(); - e = expected[ i ]; - if ( e.value === void 0 ) { - t.strictEqual( r.value, e.value, 'returns expected value' ); - t.strictEqual( r.done, e.done, 'returns expected value' ); - } else { - t.strictEqual( r.value, e.value, 'returns expected value' ); - t.strictEqual( r.done, e.done, 'returns expected value' ); - } - } - - t.end(); -}); - -tape( 'the method returns an iterator which does not iterate over empty arrays', function test( t ) { - var expected; - var arr; - var it; - var i; - var v; - - arr = new Float16Array( [] ); - expected = [ - { - 'done': true - }, - { - 'done': true - }, - { - 'done': true - } - ]; - it = arr.keys(); - - t.strictEqual( typeof it, 'object', 'returns expected value' ); - t.strictEqual( typeof it.next, 'function', 'has next method' ); - - for ( i = 0; i < expected.length; i++ ) { - v = it.next(); - t.strictEqual( v.value, expected[ i ].value, 'returns expected value' ); - t.strictEqual( v.done, expected[ i ].done, 'returns expected value' ); - } - t.end(); -}); diff --git a/test/test.last_index_of.js b/test/test.last_index_of.js deleted file mode 100644 index 5a42168..0000000 --- a/test/test.last_index_of.js +++ /dev/null @@ -1,149 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `lastIndexOf` method for returning the index of an array element', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.lastIndexOf ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.lastIndexOf.call( value, true ); - }; - } -}); - -tape( 'the method returns `-1` if operating on an empty floating-point number array', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( 0 ); - idx = arr.lastIndexOf( 0.0 ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `-1` if a numeric value is not found', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( 10 ); - idx = arr.lastIndexOf( 1.0 ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns the index of the first match when searching from the end of the array if a search element is found', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 1.05, 2.05 ] ); - idx = arr.lastIndexOf( float64ToFloat16( 1.05 ) ); - - t.strictEqual( idx, 2, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 2.05, 1.05, 1.05 ] ); - - idx = arr.lastIndexOf( float64ToFloat16( 1.05 ), 4 ); - t.strictEqual( idx, 4, 'returns expected value' ); - - idx = arr.lastIndexOf( float64ToFloat16( 2.05 ), 2 ); - t.strictEqual( idx, 2, 'returns expected value' ); - - idx = arr.lastIndexOf( float64ToFloat16( 2.05 ), 0 ); - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index (negative)', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 2.05, 1.05, 1.05 ] ); - - idx = arr.lastIndexOf( float64ToFloat16( 1.05 ), -3 ); - t.strictEqual( idx, 0, 'returns expected value' ); - - idx = arr.lastIndexOf( float64ToFloat16( 2.05 ), -1 ); - t.strictEqual( idx, 2, 'returns expected value' ); - t.end(); -}); - -tape( 'when the method is provided a starting index which resolves to an index which exceeds the maximum array index, the method searches from the last array element', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 2.05, 1.05, 1.05 ] ); - - idx = arr.lastIndexOf( float64ToFloat16( 1.05 ), 10 ); - t.strictEqual( idx, 4, 'returns expected value' ); - - idx = arr.lastIndexOf( float64ToFloat16( 2.05 ), 10 ); - t.strictEqual( idx, 2, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.map.js b/test/test.map.js deleted file mode 100644 index f7e5594..0000000 --- a/test/test.map.js +++ /dev/null @@ -1,176 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var identity = require( '@stdlib/utils-identity-function' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `map` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.map ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.map.call( value, identity ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.map( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.map( identity ); - - t.strictEqual( instanceOf( out, Float16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - t.notEqual( out, arr, 'returns a new instance' ); - t.end(); -}); - -tape( 'the method returns a new floating-point number array containing elements which are the result of a provided callback function', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( -1.05 ), - toWord( -2.05 ), - toWord( -3.05 ), - toWord( -4.05 ) - ]); - actual = arr.map( invert ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.notEqual( actual, arr, 'returns a new instance' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); - - function invert( v ) { - return -v; - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var expected; - var actual; - var arr; - var buf; - var ctx; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( -1.05 ), - toWord( -2.05 ), - toWord( -3.05 ), - toWord( -4.05 ) - ]); - ctx = { - 'count': 0 - }; - actual = arr.map( invert, ctx ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.strictEqual( ctx.count, 6, 'returns expected value' ); - t.end(); - - function invert( v, i ) { - this.count += i; // eslint-disable-line no-invalid-this - return -v; - } -}); diff --git a/test/test.of.js b/test/test.of.js deleted file mode 100644 index 6486686..0000000 --- a/test/test.of.js +++ /dev/null @@ -1,128 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `of` method for creating a 16-bit floating-point number array from a variable number of arguments', function test( t ) { - var arr; - - t.strictEqual( isFunction( Float16Array.of ), true, 'has method' ); - - arr = Float16Array.of(); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a constructor', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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 Float16Array.of.call( value, true, true ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point array constructor', function test( t ) { - var values; - var i; - - values = [ - {}, - null, - 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 Float16Array.of.call( value, true, true ); - }; - } -}); - -tape( 'the method returns a floating-point number array', function test( t ) { - var arr; - var v; - - // No arguments: - arr = Float16Array.of(); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - // Numeric arguments: - arr = Float16Array.of( 1.0, 2.0, 3.0, 4.0 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - // Non-numeric arguments: - arr = Float16Array.of( 1, {}, 0, null, 'beep' ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 5, 'returns expected value' ); - - // Mixed arguments: - arr = Float16Array.of( true, 1, false, 0 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 2010bde..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 proxyquire = require( 'proxyquire' ); -var hasFloat16ArraySupport = require( '@stdlib/assert-has-float16array-support' ); -var polyfill = require( './../lib/polyfill' ); -var ctor = require( './../lib' ); - - -// VARIABLES // - -var hasFloat16Arrays = hasFloat16ArraySupport(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports `Float16Array`, the export is an alias for `Float16Array`', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-float16array-support': isTrue, - './main.js': Mock - }); - t.strictEqual( Foo, Mock, 'returns builtin' ); - - if ( hasFloat16Arrays ) { - t.strictEqual( ctor, Float16Array, 'is alias' ); // eslint-disable-line stdlib/require-globals, no-undef - } - - t.end(); - - function Mock() { - return this; - } - - function isTrue() { - return true; - } -}); - -tape( 'if an environment does not support `Float16Array`, the export is a polyfill', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-float16array-support': isFalse - }); - - t.strictEqual( Foo, polyfill, 'returns polyfill' ); - t.end(); - - function isFalse() { - return false; - } -}); diff --git a/test/test.reduce.js b/test/test.reduce.js deleted file mode 100644 index 34786fc..0000000 --- a/test/test.reduce.js +++ /dev/null @@ -1,187 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `reduce` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.reduce ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.reduce.call( value, reducer ); - }; - } - - function reducer( acc, value ) { - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.reduce( value ); - }; - } -}); - -tape( 'the method throws an error if not provided an initial value when operating on an empty floating-point number array', function test( t ) { - var arr; - - arr = new Float16Array( 0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - arr.reduce( reducer ); - } - - function reducer( acc, value ) { - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method uses the first element of the array as the initial value when an initial value is not provided', function test( t ) { - var valueArray; - var accArray; - var expected; - var actual; - var arr; - var ind; - - arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - accArray = [ 1.0, 3.0 ]; - valueArray = [ 2.0, 3.0 ]; - expected = float64ToFloat16( 6.0 ); - actual = arr.reduce( reducer ); - - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); - - function reducer( acc, value, index ) { - ind = index-1; - t.strictEqual( acc, float64ToFloat16( accArray[ ind ] ), 'returns expected value' ); - t.strictEqual( value, float64ToFloat16( valueArray[ ind ] ), 'returns expected value' ); - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method supports providing an initial value as the second argument', function test( t ) { - var valueArray; - var accArray; - var expected; - var actual; - var arr; - - arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - accArray = [ 2.0, 3.0, 5.0 ]; - valueArray = [ 1.0, 2.0, 3.0 ]; - expected = 8.0; - actual = arr.reduce( reducer, 2.0 ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value, index ) { - t.strictEqual( acc, float64ToFloat16( accArray[ index ] ), 'returns expected value' ); - t.strictEqual( value, float64ToFloat16( valueArray[ index ] ), 'returns expected value' ); - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method returns the accumulated result', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = float64ToFloat16( 10.20 ); - actual = arr.reduce( reducer ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value ) { - return float64ToFloat16( acc + value ); - } -}); diff --git a/test/test.reduce_right.js b/test/test.reduce_right.js deleted file mode 100644 index 313b948..0000000 --- a/test/test.reduce_right.js +++ /dev/null @@ -1,190 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `reduceRight` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.reduceRight ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.reduceRight.call( value, reducer ); - }; - } - - function reducer( acc, value ) { - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.reduceRight( value ); - }; - } -}); - -tape( 'the method throws an error if not provided an initial value when operating on an empty floating-point number array', function test( t ) { - var arr; - - arr = new Float16Array( 0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - arr.reduceRight( reducer ); - } - - function reducer( acc, value ) { - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method uses the last element of the array as the initial value when an initial value is not provided', function test( t ) { - var valueArray; - var accArray; - var expected; - var actual; - var arr; - var len; - - arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - len = arr.length; - accArray = [ 3.0, 5.0 ]; - valueArray = [ 2.0, 1.0 ]; - expected = float64ToFloat16( 6.0 ); - actual = arr.reduceRight( reducer ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value, index ) { - var ind = (len-index-2); - t.strictEqual( acc, float64ToFloat16( accArray[ ind ] ), 'returns expected value' ); - t.strictEqual( value, float64ToFloat16( valueArray[ ind ] ), 'returns expected value' ); - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method supports providing an initial value as the second argument', function test( t ) { - var valueArray; - var accArray; - var expected; - var actual; - var arr; - var len; - - arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - len = arr.length; - accArray = [ 2.0, 5.0, 7.0 ]; - valueArray = [ 3.0, 2.0, 1.0 ]; - expected = 8.0; - actual = arr.reduceRight( reducer, 2.0 ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value, index ) { - var ind = (len-index-1); - t.strictEqual( acc, float64ToFloat16( accArray[ ind ] ), 'returns expected value' ); - t.strictEqual( value, float64ToFloat16( valueArray[ ind ] ), 'returns expected value' ); - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method returns the accumulated result', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = float64ToFloat16( 10.20 ); - actual = arr.reduceRight( reducer ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value ) { - return float64ToFloat16( acc + value ); - } -}); diff --git a/test/test.reverse.js b/test/test.reverse.js deleted file mode 100644 index 147a4a0..0000000 --- a/test/test.reverse.js +++ /dev/null @@ -1,120 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, '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( isFunction( Float16Array.prototype.reverse ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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 floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - 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 floating-point number array in-place', function test( t ) { - var expected; - var arr; - var buf; - var out; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05, 5.05 ] ); - expected = new Uint16Array([ - toWord( 5.05 ), - toWord( 4.05 ), - toWord( 3.05 ), - toWord( 2.05 ), - toWord( 1.05 ) - ]); - out = arr.reverse(); - buf = new Uint16Array( arr.buffer ); - - t.strictEqual( instanceOf( arr, Float16Array ), true, 'returns expected value' ); - t.strictEqual( out, arr, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 10 ); - out = arr.reverse(); - - t.strictEqual( out.length, 10, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.set.js b/test/test.set.js deleted file mode 100644 index 559efab..0000000 --- a/test/test.set.js +++ /dev/null @@ -1,225 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `set` method for setting one or more array elements', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.set ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.set.call( value, 0 ); - }; - } -}); - -tape( 'the method throws an error if provided an index argument which is out-of-bounds', function test( t ) { - var values; - var arr1; - var arr2; - var i; - - arr1 = new Float16Array( 10 ); - arr2 = []; - for ( i = 0; i < arr1.length; i++ ) { - arr2.push( 1.0 ); - } - - values = [ - 1, - 2, - 3, - 4, - 5 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr1.set( arr2, value ); - }; - } -}); - -tape( 'the method sets one or more array elements', function test( t ) { - var arr; - var v; - var i; - - arr = new Float16Array( 10 ); - - v = arr[ 0 ]; - t.strictEqual( v, 0.0, 'returns expected value' ); - - // No index argument: - arr.set( [ 1.0 ] ); - - v = arr[ 0 ]; - t.strictEqual( v, 1.0, 'returns expected value' ); - - arr.set( [ 0.0 ] ); - - // Index argument: - for ( i = 0; i < arr.length; i++ ) { - v = arr[ i ]; - t.strictEqual( v, 0.0, 'returns expected value' ); - - arr.set( [ 1.05 ], i ); - - v = arr[ i ]; - t.strictEqual( v, float64ToFloat16( 1.05 ), 'returns expected value' ); - } - - // Multiple values, no index argument: - arr.set( [ 1.05, 2.05 ] ); - - v = arr[ 0 ]; - t.strictEqual( v, float64ToFloat16( 1.05 ), 'returns expected value' ); - - v = arr[ 1 ]; - t.strictEqual( v, float64ToFloat16( 2.05 ), 'returns expected value' ); - - // Multiple values, index argument: - arr.set( [ 1.05, 2.05 ], 2 ); - - v = arr[ 2 ]; - t.strictEqual( v, float64ToFloat16( 1.05 ), 'returns expected value' ); - - v = arr[ 3 ]; - t.strictEqual( v, float64ToFloat16( 2.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method sets an array element (floating-point number array; shared buffer)', function test( t ) { - var byteOffset; - var arr; - var src; - var buf; - var ab; - var v; - var i; - - byteOffset = 112; - - ab = new ArrayBuffer( 240 ); - arr = new Float16Array( ab, byteOffset, 10 ); - - // Overlapping (requires copy), multiple values, no index argument: - buf = [ 1.05, 2.05 ]; - src = new Float16Array( ab, byteOffset-(1*arr.BYTES_PER_ELEMENT), 2 ); - for ( i = 0; i < buf.length; i++ ) { - src[ i ] = buf[ i ]; - } - arr.set( src ); - - v = arr[ 0 ]; - t.strictEqual( v, float64ToFloat16( buf[ 0 ] ), 'returns expected value' ); - - v = arr[ 1 ]; - t.strictEqual( v, float64ToFloat16( buf[ 1 ] ), 'returns expected value' ); - - // Overlapping (requires copy), multiple values, index argument: - buf = [ -1.05, -2.05 ]; - src = new Float16Array( ab, byteOffset+(1*arr.BYTES_PER_ELEMENT), 2 ); - for ( i = 0; i < buf.length; i++ ) { - src[ i ] = buf[ i ]; - } - arr.set( src, 2 ); - - v = arr[ 2 ]; - t.strictEqual( v, float64ToFloat16( buf[ 0 ] ), 'returns expected value' ); - - v = arr[ 3 ]; - t.strictEqual( v, float64ToFloat16( buf[ 1 ] ), 'returns expected value' ); - - // Overlapping (no copy), multiple values, no index argument: - buf = [ 3.05, 4.05 ]; - src = new Float16Array( ab, byteOffset+(1*arr.BYTES_PER_ELEMENT), 2 ); - for ( i = 0; i < buf.length; i++ ) { - src[ i ] = buf[ i ]; - } - arr.set( src ); - - v = arr[ 0 ]; - t.strictEqual( v, float64ToFloat16( buf[ 0 ] ), 'returns expected value' ); - - v = arr[ 1 ]; - t.strictEqual( v, float64ToFloat16( buf[ 1 ] ), 'returns expected value' ); - - // Overlapping (no copy), multiple values, index argument: - buf = [ -3.05, -4.05 ]; - src = new Float16Array( ab, byteOffset+(3*arr.BYTES_PER_ELEMENT), 2 ); - for ( i = 0; i < buf.length; i++ ) { - src[ i ] = buf[ i ]; - } - arr.set( src, 2 ); - - v = arr[ 2 ]; - t.strictEqual( v, float64ToFloat16( buf[ 0 ] ), 'returns expected value' ); - - v = arr[ 3 ]; - t.strictEqual( v, float64ToFloat16( buf[ 1 ] ), 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.slice.js b/test/test.slice.js deleted file mode 100644 index a9f9e04..0000000 --- a/test/test.slice.js +++ /dev/null @@ -1,249 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `slice` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.slice ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.slice.call( value ); - }; - } -}); - -tape( 'the method returns an empty typed array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.slice(); - - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'if called without arguments, the method returns a typed array containing the same elements as the original array', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ) - ]); - actual = arr.slice(); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.notEqual( actual, arr, 'returns a new instance' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if called with one argument, the method returns a typed array containing elements starting from a specified beginning index (inclusive)', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ) - ]); - actual = arr.slice( 1 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if provided two arguments, the method returns a typed array containing elements starting from a specified beginning index (inclusive) and ending at a specified stop index (exclusive)', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ) - ]); - actual = arr.slice( 1, 3 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ) - ]); - actual = arr.slice( 1, 30 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method resolves negative indices relative to the last element', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ) - ]); - actual = arr.slice( -3, -1 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ) - ]); - actual = arr.slice( -30, -2 ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty typed array if a resolved beginning index exceeds a resolved ending index', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array( [] ); - actual = arr.slice( 2, 0 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty typed array if a resolved beginning index exceeds the maximum array index', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array( [] ); - actual = arr.slice( 5 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty typed array if a resolved ending index is less than or equal to zero', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); - expected = new Uint16Array( [] ); - actual = arr.slice( 2, -8 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - - actual = arr.slice( 1, 0 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.some.js b/test/test.some.js deleted file mode 100644 index 238d1d9..0000000 --- a/test/test.some.js +++ /dev/null @@ -1,194 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `some` method for returning boolean indicating whether at least one element passes a test', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.some ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.some.call( value, predicate ); - }; - } - - function predicate( v ) { - return v === 1.0; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.some( value ); - }; - } -}); - -tape( 'the method returns `false` if operating on an empty floating-point number array', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( 0 ); - bool = arr.some( predicate ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns `true` if at least one element passes a test', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - bool = arr.some( predicate ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v === float64ToFloat16( 1.05 ); - } -}); - -tape( 'the method returns `false` if all elements fail a test', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - bool = arr.some( predicate ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v === float64ToFloat16( 5.05 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var bool; - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - bool = arr.some( predicate, ctx ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v === float64ToFloat16( 4.05 ); - } -}); - -tape( 'the method stops executing upon encountering the first element which passes a test', function test( t ) { - var bool; - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - bool = arr.some( predicate, ctx ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.strictEqual( ctx.count, 1, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v === float64ToFloat16( 1.05 ); - } -}); diff --git a/test/test.sort.js b/test/test.sort.js deleted file mode 100644 index e976a68..0000000 --- a/test/test.sort.js +++ /dev/null @@ -1,186 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Comparison function. -* -* @private -* @param {boolean} a - first value for comparison -* @param {boolean} b - second value for comparison -* @returns {number} comparison result -*/ -function compareFcn( a, b ) { - if ( a < b ) { - return -1; - } - if ( a > b ) { - return 1; - } - return 0; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `sort` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.sort ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.sort.call( value, compareFcn ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - {}, - [] - ]; - 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.sort( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.sort( compareFcn ); - - t.strictEqual( out.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the method sorts elements of a floating-point number array in-place', function test( t ) { - var expected; - var arr; - var out; - var buf; - - arr = new Float16Array( [ 4.05, 3.05, 1.05, 5.05, 2.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ), - toWord( 5.05 ) - ]); - out = arr.sort( compareFcn ); - buf = new Uint16Array( out.buffer ); - - t.strictEqual( instanceOf( arr, Float16Array ), true, 'returns expected value' ); - t.strictEqual( out, arr, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - - arr = new Float16Array( [ 2.05, 1.05, -1.05, 0.05, -2.05 ] ); - expected = new Uint16Array([ - toWord( -2.05 ), - toWord( -1.05 ), - toWord( 0.05 ), - toWord( 1.05 ), - toWord( 2.05 ) - ]); - out = arr.sort( compareFcn ); - buf = new Uint16Array( out.buffer ); - - t.strictEqual( instanceOf( arr, Float16Array ), true, 'returns expected value' ); - t.strictEqual( out, arr, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Float16Array( [ 4.05, 3.05, 1.05, 5.05, 2.05 ] ); - out = arr.sort( compareFcn ); - - t.strictEqual( out.length, arr.length, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.subarray.js b/test/test.subarray.js deleted file mode 100644 index 6684448..0000000 --- a/test/test.subarray.js +++ /dev/null @@ -1,246 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `subarray` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.subarray ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.subarray.call( value ); - }; - } -}); - -tape( 'the method returns empty array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.subarray(); - - t.strictEqual( out.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'if called without arguments, the method returns a view containing the same elements as the original array', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ) - ]); - actual = arr.subarray(); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if called with one argument, the method returns a view containing elements starting from a specified beginning index (inclusive)', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ) - ]); - actual = arr.subarray( 1 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if provided two arguments, the method returns a view containing elements starting from a specified beginning index (inclusive) and ending at a specified stop index (exclusive)', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ) - ]); - actual = arr.subarray( 1, 3 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method resolves negative indices relative to the last element', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ) - ]); - actual = arr.subarray( -3, -1 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 2.05 ) - ]); - actual = arr.subarray( -30, -2 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty view if a resolved beginning index exceeds a resolved ending index', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array( [] ); - actual = arr.subarray( 2, 0 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty view if a resolved beginning index exceeds the maximum array index', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array( [] ); - actual = arr.subarray( 5 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty view if a resolved ending index is less than or equal to zero', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array( [] ); - actual = arr.subarray( 2, -8 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - - actual = arr.subarray( 1, 0 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.to_locale_string.js b/test/test.to_locale_string.js deleted file mode 100644 index 6359a2c..0000000 --- a/test/test.to_locale_string.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `toLocaleString` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.toLocaleString ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.toLocaleString.call( value ); - }; - } -}); - -tape( 'the method returns an empty string if invoked on an empty array', function test( t ) { - var str; - var arr; - - arr = new Float16Array( 0 ); - str = arr.toLocaleString(); - - t.strictEqual( str, '', 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a string representation of a floating-point number array', function test( t ) { - var expected; - var str; - var arr; - - arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - expected = '1,2,3'; - - str = arr.toLocaleString(); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.to_reversed.js b/test/test.to_reversed.js deleted file mode 100644 index a82ad13..0000000 --- a/test/test.to_reversed.js +++ /dev/null @@ -1,119 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, '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( isFunction( Float16Array.prototype.toReversed ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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 floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - 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 buf; - var out; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05, 5.05 ] ); - expected = new Uint16Array([ - toWord( 5.05 ), - toWord( 4.05 ), - toWord( 3.05 ), - toWord( 2.05 ), - toWord( 1.05 ) - ]); - out = arr.toReversed(); - buf = new Uint16Array( out.buffer ); - - t.strictEqual( instanceOf( out, Float16Array ), true, 'returns expected value' ); - t.notEqual( out, arr, 'returns a new instance' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 10 ); - out = arr.toReversed(); - - t.strictEqual( out.length, 10, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.to_sorted.js b/test/test.to_sorted.js deleted file mode 100644 index 77508b5..0000000 --- a/test/test.to_sorted.js +++ /dev/null @@ -1,169 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Comparison function. -* -* @private -* @param {boolean} a - first value for comparison -* @param {boolean} b - second value for comparison -* @returns {number} comparison result -*/ -function compareFcn( a, b ) { - if ( a < b ) { - return -1; - } - if ( a > b ) { - return 1; - } - return 0; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `toSorted` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.toSorted ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.toSorted.call( value, compareFcn ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - {}, - [] - ]; - 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.toSorted( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.toSorted( compareFcn ); - - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a new typed array containing elements in sorted order', function test( t ) { - var expected; - var arr; - var out; - var buf; - - arr = new Float16Array( [ 4.05, 3.05, 1.05, 5.05, 2.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ), - toWord( 5.05 ) - ]); - out = arr.toSorted( compareFcn ); - buf = new Uint16Array( out.buffer ); - - t.strictEqual( instanceOf( out, Float16Array ), true, 'returns expected value' ); - t.notEqual( out, arr, 'returns a new instance' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Float16Array( [ 4.05, 3.05, 1.05, 5.05, 2.05 ] ); - out = arr.toSorted( compareFcn ); - - t.strictEqual( out.length, arr.length, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.to_string.js b/test/test.to_string.js deleted file mode 100644 index a2bb9e3..0000000 --- a/test/test.to_string.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `toString` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.toString ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with an invalid `this` context', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - null, - void 0 - ]; - 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.toString.call( value ); - }; - } -}); - -tape( 'the method returns an empty string if invoked on an empty array', function test( t ) { - var str; - var arr; - - arr = new Float16Array( 0 ); - str = arr.toString(); - - t.strictEqual( str, '', 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a string representation of a floating-point number array', function test( t ) { - var expected; - var str; - var arr; - - arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - expected = '1,2,3,4'; - - str = arr.toString(); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.values.js b/test/test.values.js deleted file mode 100644 index 225b3fe..0000000 --- a/test/test.values.js +++ /dev/null @@ -1,147 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var isNumber = require( '@stdlib/assert-is-number' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `values` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.values ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.values.call( value ); - }; - } -}); - -tape( 'the method returns an iterator protocol-compliant object', function test( t ) { - var expected; - var arr; - var it; - var i; - var r; - var e; - - arr = new Float16Array( [ 1.05, 2.05 ] ); - expected = [ - { - 'value': float64ToFloat16( 1.05 ), - 'done': false - }, - { - 'value': float64ToFloat16( 2.05 ), - 'done': false - }, - { - 'done': true - } - ]; - it = arr.values(); - - t.strictEqual( typeof it, 'object', 'returns expected value' ); - t.strictEqual( typeof it.next, 'function', 'has next method' ); - - for ( i = 0; i < expected.length; i++ ) { - r = it.next(); - e = expected[ i ]; - if ( e.value === void 0 ) { - t.strictEqual( r.value, e.value, 'returns expected value' ); - t.strictEqual( r.done, e.done, 'returns expected value' ); - } else { - t.strictEqual( isNumber( r.value ), true, 'returns expected value' ); - t.strictEqual( r.value, e.value, 'returns expected value' ); - t.strictEqual( r.done, e.done, 'returns expected value' ); - } - } - - t.end(); -}); - -tape( 'the method returns an iterator which does not iterate over empty arrays', function test( t ) { - var expected; - var arr; - var it; - var i; - var v; - - arr = new Float16Array( [] ); - expected = [ - { - 'done': true - }, - { - 'done': true - }, - { - 'done': true - } - ]; - it = arr.values(); - - t.strictEqual( typeof it, 'object', 'returns expected value' ); - t.strictEqual( typeof it.next, 'function', 'has next method' ); - - for ( i = 0; i < expected.length; i++ ) { - v = it.next(); - t.strictEqual( v.value, expected[ i ].value, 'returns expected value' ); - t.strictEqual( v.done, expected[ i ].done, 'returns expected value' ); - } - t.end(); -}); diff --git a/test/test.with.js b/test/test.with.js deleted file mode 100644 index de134c8..0000000 --- a/test/test.with.js +++ /dev/null @@ -1,151 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `with` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.with ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.with.call( value, 0, true ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not in bounds', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - -11, - -12, - 11, - 12 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.with( value, 1.0 ); - }; - } -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 10 ); - out = arr.with( 5, 1.0 ); - - t.strictEqual( out.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a new floating-point number array with the element at a provided index replaced with a provided value', function test( t ) { - var expected; - var arr; - var buf; - var out; - - arr = new Float16Array( [ 1.05, 1.05, 1.05, 1.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 1.05 ), - toWord( 1.05 ), - toWord( 2.05 ) - ]); - out = arr.with( 3, 2.05 ); - buf = new Uint16Array( out.buffer ); - - t.strictEqual( out instanceof Float16Array, true, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.notEqual( out, arr, 'returns new instance' ); - t.end(); -}); - -tape( 'the method supports negative indices', function test( t ) { - var expected; - var arr; - var buf; - var out; - - arr = new Float16Array( [ 1.05, 1.05, 1.05, 1.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 1.05 ), - toWord( 1.05 ), - toWord( 2.05 ) - ]); - out = arr.with( -1, 2.05 ); - buf = new Uint16Array( out.buffer ); - - t.strictEqual( out instanceof Float16Array, true, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); From 077b1865a5caf4234d917f895aa4ab2400dbed29 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 13 May 2026 08:24:31 +0000 Subject: [PATCH 03/14] Transform error messages --- lib/polyfill/index.js | 102 +++++++++++++++++++++--------------------- package.json | 2 +- 2 files changed, 52 insertions(+), 52 deletions(-) diff --git a/lib/polyfill/index.js b/lib/polyfill/index.js index 5073dcb..063db06 100644 --- a/lib/polyfill/index.js +++ b/lib/polyfill/index.js @@ -38,7 +38,7 @@ var setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); var setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' ); var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var Uint16Array = require( '@stdlib/array-uint16' ); var f16 = require( '@stdlib/number-float64-base-to-float16' ); var toWord = require( '@stdlib/number-float16-base-to-word' ); @@ -234,49 +234,49 @@ function Float16Array() { } } else if ( isArrayBuffer( arg ) ) { if ( !isInteger( arg.byteLength/BYTES_PER_ELEMENT ) ) { - throw new RangeError( format( 'invalid argument. ArrayBuffer byte length must be a multiple of %u. Byte length: `%u`.', BYTES_PER_ELEMENT, arg.byteLength ) ); + throw new RangeError( format( 'nullE9', BYTES_PER_ELEMENT, arg.byteLength ) ); } buf = new Uint16Array( arg ); } else if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, ArrayBuffer, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( 'null29', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( 'null2A', arg ) ); } buf = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( buf.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( 'null2A', arg ) ); } buf = new Uint16Array( fromIterator( buf ) ); } else { - throw new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( 'null2A', arg ) ); } } else { buf = arguments[ 0 ]; if ( !isArrayBuffer( buf ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', buf ) ); + throw new TypeError( format( 'null2B', buf ) ); } byteOffset = arguments[ 1 ]; if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) ); + throw new TypeError( format( 'null2C', byteOffset ) ); } if ( !isInteger( byteOffset/BYTES_PER_ELEMENT ) ) { - throw new RangeError( format( 'invalid argument. Byte offset must be a multiple of %u. Value: `%u`.', BYTES_PER_ELEMENT, byteOffset ) ); + throw new RangeError( format( 'nullEA', BYTES_PER_ELEMENT, byteOffset ) ); } if ( nargs === 2 ) { len = buf.byteLength - byteOffset; if ( !isInteger( len/BYTES_PER_ELEMENT ) ) { - throw new RangeError( format( 'invalid arguments. ArrayBuffer view byte length must be a multiple of %u. View byte length: `%u`.', BYTES_PER_ELEMENT, len ) ); + throw new RangeError( format( 'null2E', BYTES_PER_ELEMENT, len ) ); } buf = new Uint16Array( buf, byteOffset ); } else { len = arguments[ 2 ]; if ( !isNonNegativeInteger( len ) ) { - throw new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', len ) ); + throw new TypeError( format( 'null2F', len ) ); } if ( (len*BYTES_PER_ELEMENT) > (buf.byteLength-byteOffset) ) { - throw new RangeError( format( 'invalid arguments. ArrayBuffer has insufficient capacity. Either decrease the array length or provide a bigger buffer. Minimum capacity: `%u`.', len*BYTES_PER_ELEMENT ) ); + throw new RangeError( format( 'null2G', len*BYTES_PER_ELEMENT ) ); } buf = new Uint16Array( buf, byteOffset, len ); } @@ -362,7 +362,7 @@ setReadOnly( Float16Array, 'from', function from( src ) { var len; var i; if ( !isFunction( this ) ) { - throw new TypeError( 'invalid invocation. `this` context must be a constructor.' ); + throw new TypeError( format('null01') ); } if ( !isFloatingPointArrayConstructor( this ) ) { throw new TypeError( 'invalid invocation. `this` is not a floating-point array.' ); @@ -371,7 +371,7 @@ setReadOnly( Float16Array, 'from', function from( src ) { if ( nargs > 1 ) { clbk = arguments[ 1 ]; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( 'null2H', clbk ) ); } if ( nargs > 2 ) { thisArg = arguments[ 2 ]; @@ -392,7 +392,7 @@ setReadOnly( Float16Array, 'from', function from( src ) { if ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) { // eslint-disable-line max-len buf = src[ ITERATOR_SYMBOL ](); if ( !isFunction( buf.next ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) ); + throw new TypeError( format( 'null2J', src ) ); } if ( clbk ) { tmp = fromIteratorMap( buf, clbk, thisArg ); @@ -410,7 +410,7 @@ setReadOnly( Float16Array, 'from', function from( src ) { } return out; } - throw new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) ); + throw new TypeError( format( 'null2J', src ) ); }); /** @@ -438,7 +438,7 @@ setReadOnly( Float16Array, 'of', function of() { var args; var i; if ( !isFunction( this ) ) { - throw new TypeError( 'invalid invocation. `this` context must be a constructor.' ); + throw new TypeError( format('null01') ); } if ( !isFloatingPointArrayConstructor( this ) ) { throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); @@ -478,7 +478,7 @@ setReadOnly( Float16Array.prototype, 'at', function at( idx ) { throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Must provide an integer. Value: `%s`.', idx ) ); + throw new TypeError( format( 'null8A', idx ) ); } if ( idx < 0 ) { idx += this._length; @@ -731,7 +731,7 @@ setReadOnly( Float16Array.prototype, 'every', function every( predicate, thisArg throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( 'null3c', predicate ) ); } buf = this._buffer; for ( i = 0; i < this._length; i++ ) { @@ -781,13 +781,13 @@ setReadOnly( Float16Array.prototype, 'fill', function fill( value, start, end ) throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isNumber( value ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a number. Value: `%s`.', value ) ); + throw new TypeError( format( 'null49', value ) ); } buf = this._buffer; len = this._length; if ( arguments.length > 1 ) { if ( !isInteger( start ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', start ) ); + throw new TypeError( format( 'null7f', start ) ); } if ( start < 0 ) { start += len; @@ -797,7 +797,7 @@ setReadOnly( Float16Array.prototype, 'fill', function fill( value, start, end ) } if ( arguments.length > 2 ) { if ( !isInteger( end ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', end ) ); + throw new TypeError( format( 'null2z', end ) ); } if ( end < 0 ) { end += len; @@ -863,7 +863,7 @@ setReadOnly( Float16Array.prototype, 'filter', function filter( predicate, thisA throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( 'null3c', predicate ) ); } buf = this._buffer; out = []; @@ -907,7 +907,7 @@ setReadOnly( Float16Array.prototype, 'find', function find( predicate, thisArg ) throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( 'null3c', predicate ) ); } buf = this._buffer; for ( i = 0; i < this._length; i++ ) { @@ -949,7 +949,7 @@ setReadOnly( Float16Array.prototype, 'findIndex', function findIndex( predicate, throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( 'null3c', predicate ) ); } buf = this._buffer; for ( i = 0; i < this._length; i++ ) { @@ -992,7 +992,7 @@ setReadOnly( Float16Array.prototype, 'findLast', function findLast( predicate, t throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( 'null3c', predicate ) ); } buf = this._buffer; for ( i = this._length-1; i >= 0; i-- ) { @@ -1034,7 +1034,7 @@ setReadOnly( Float16Array.prototype, 'findLastIndex', function findLastIndex( pr throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( 'null3c', predicate ) ); } buf = this._buffer; for ( i = this._length-1; i >= 0; i-- ) { @@ -1074,7 +1074,7 @@ setReadOnly( Float16Array.prototype, 'forEach', function forEach( fcn, thisArg ) throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( 'null3c', fcn ) ); } buf = this._buffer; for ( i = 0; i < this._length; i++ ) { @@ -1099,7 +1099,7 @@ setReadOnly( Float16Array.prototype, '_get', function get( idx ) { throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isNonNegativeInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Must provide a nonnegative integer. Value: `%s`.', idx ) ); + throw new TypeError( format( 'null2K', idx ) ); } if ( idx >= this._length ) { return; @@ -1141,11 +1141,11 @@ setReadOnly( Float16Array.prototype, 'includes', function includes( searchElemen throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isNumber( searchElement ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a number. Value: `%s`.', searchElement ) ); + throw new TypeError( format( 'null49', searchElement ) ); } if ( arguments.length > 1 ) { if ( !isInteger( fromIndex ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) ); + throw new TypeError( format( 'null7f', fromIndex ) ); } if ( fromIndex < 0 ) { fromIndex += this._length; @@ -1200,11 +1200,11 @@ setReadOnly( Float16Array.prototype, 'indexOf', function indexOf( searchElement, throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isNumber( searchElement ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a number. Value: `%s`.', searchElement ) ); + throw new TypeError( format( 'null49', searchElement ) ); } if ( arguments.length > 1 ) { if ( !isInteger( fromIndex ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) ); + throw new TypeError( format( 'null7f', fromIndex ) ); } if ( fromIndex < 0 ) { fromIndex += this._length; @@ -1255,7 +1255,7 @@ setReadOnly( Float16Array.prototype, 'join', function join( separator ) { } if ( arguments.length > 0 ) { if ( !isString( separator ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', separator ) ); + throw new TypeError( format( 'null3F', separator ) ); } } else { separator = ','; @@ -1404,11 +1404,11 @@ setReadOnly( Float16Array.prototype, 'lastIndexOf', function lastIndexOf( search throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isNumber( searchElement ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a number. Value: `%s`.', searchElement ) ); + throw new TypeError( format( 'null49', searchElement ) ); } if ( arguments.length > 1 ) { if ( !isInteger( fromIndex ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) ); + throw new TypeError( format( 'null7f', fromIndex ) ); } if ( fromIndex >= this._length ) { fromIndex = this._length - 1; @@ -1486,7 +1486,7 @@ setReadOnly( Float16Array.prototype, 'map', function map( fcn, thisArg ) { throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isFunction( fcn ) ) { - throw new TypeError( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ); + throw new TypeError( format('null3c'), fcn ); } buf = this._buffer; out = new this.constructor( this._length ); @@ -1529,7 +1529,7 @@ setReadOnly( Float16Array.prototype, 'reduce', function reduce( reducer, initial throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isFunction( reducer ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', reducer ) ); + throw new TypeError( format( 'null3c', reducer ) ); } buf = this._buffer; len = this._length; @@ -1581,7 +1581,7 @@ setReadOnly( Float16Array.prototype, 'reduceRight', function reduceRight( reduce throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isFunction( reducer ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', reducer ) ); + throw new TypeError( format( 'null3c', reducer ) ); } buf = this._buffer; len = this._length; @@ -1707,20 +1707,20 @@ setReadOnly( Float16Array.prototype, 'set', function set( value ) { throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isCollection( value ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', value ) ); + throw new TypeError( format( 'null2O', value ) ); } buf = this._buffer; if ( arguments.length > 1 ) { idx = arguments[ 1 ]; if ( !isNonNegativeInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Index argument must be a nonnegative integer. Value: `%s`.', idx ) ); + throw new TypeError( format( 'null2L', idx ) ); } } else { idx = 0; } N = value.length; if ( idx+N > this._length ) { - throw new RangeError( 'invalid arguments. Target array lacks sufficient storage to accommodate source values.' ); + throw new RangeError( format('null03') ); } if ( isFloat16Array( value ) ) { sbuf = value._buffer; // eslint-disable-line no-underscore-dangle @@ -1814,7 +1814,7 @@ setReadOnly( Float16Array.prototype, 'slice', function slice( begin, end ) { end = len; } else { if ( !isInteger( begin ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', begin ) ); + throw new TypeError( format( 'null7e', begin ) ); } if ( begin < 0 ) { begin += len; @@ -1826,7 +1826,7 @@ setReadOnly( Float16Array.prototype, 'slice', function slice( begin, end ) { end = len; } else { if ( !isInteger( end ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', end ) ); + throw new TypeError( format( 'null7f', end ) ); } if ( end < 0 ) { end += len; @@ -1881,7 +1881,7 @@ setReadOnly( Float16Array.prototype, 'some', function some( predicate, thisArg ) throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( 'null3c', predicate ) ); } buf = this._buffer; for ( i = 0; i < this._length; i++ ) { @@ -1939,7 +1939,7 @@ setReadOnly( Float16Array.prototype, 'sort', function sort( compareFcn ) { return this; } if ( !isFunction( compareFcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', compareFcn ) ); + throw new TypeError( format( 'null3c', compareFcn ) ); } buf.sort( compare ); return this; @@ -2044,7 +2044,7 @@ setReadOnly( Float16Array.prototype, 'subarray', function subarray( begin, end ) end = len; } else { if ( !isInteger( begin ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', begin ) ); + throw new TypeError( format( 'null7e', begin ) ); } if ( begin < 0 ) { begin += len; @@ -2056,7 +2056,7 @@ setReadOnly( Float16Array.prototype, 'subarray', function subarray( begin, end ) end = len; } else { if ( !isInteger( end ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', end ) ); + throw new TypeError( format( 'null7f', end ) ); } if ( end < 0 ) { end += len; @@ -2122,7 +2122,7 @@ setReadOnly( Float16Array.prototype, 'toLocaleString', function toLocaleString( } else if ( isObject( options ) ) { opts = options; } else { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( 'null2V', options ) ); } buf = this._buffer; out = []; @@ -2387,14 +2387,14 @@ setReadOnly( Float16Array.prototype, 'with', function copyWith( index, value ) { throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isInteger( index ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', index ) ); + throw new TypeError( format( 'null7e', index ) ); } len = this._length; if ( index < 0 ) { index += len; } if ( index < 0 || index >= len ) { - throw new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%s`.', index ) ); + throw new RangeError( format( 'nullFP', index ) ); } if ( !isNumber( value ) ) { throw new TypeError( format( 'invalid argument. Second argument must be a floating-point number. Value: `%s`.', value ) ); diff --git a/package.json b/package.json index 7f32128..0ed7acd 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "@stdlib/number-float16-base-from-word": "^0.2.1", "@stdlib/number-float16-base-to-word": "^0.1.1", "@stdlib/number-float64-base-to-float16": "^0.1.2", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/symbol-iterator": "^0.2.3", "@stdlib/types": "^0.4.3", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.4", From 04fd49408f13650d124838e16a5359bfe343b043 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 13 May 2026 08:24:58 +0000 Subject: [PATCH 04/14] Remove files --- index.d.ts | 1312 -------------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 6159 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index ed52b06..0000000 --- a/index.d.ts +++ /dev/null @@ -1,1312 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2026 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. -*/ - -/* eslint-disable max-lines */ - -// TypeScript Version: 4.1 - -/// - -import { Iterator as Iter, IterableIterator, TypedIterator } from '@stdlib/types/iter'; -import { ArrayLike } from '@stdlib/types/array'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = Iter | IterableIterator; - -/** -* Locale-specific configuration options. -*/ -interface LocaleOptions { - /** - * Configuration property. - */ - [ key: string | symbol | number ]: T | undefined; -} - -/** -* Callback invoked for each element in a source object. -* -* @returns transformed value -*/ -type FromNullary = ( this: U ) => number; - -/** -* Callback invoked for each element in a source object. -* -* @param value - source element -* @returns transformed value -*/ -type FromUnary = ( this: U, value: number ) => number; - -/** -* Callback invoked for each element in a source object. -* -* @param value - source element -* @param index - source element index -* @returns transformed value -*/ -type FromBinary = ( this: U, value: number, index: number ) => number; - -/** -* Callback invoked for each element in a source object. -* -* @param value - source element -* @param index - source element index -* @returns transformed value -*/ -type FromCallback = FromNullary | FromUnary | FromBinary; - -/** -* Checks whether an element in an array passes a test. -* -* @returns boolean indicating whether an element in an array passes a test -*/ -type NullaryPredicate = ( this: U ) => boolean; - -/** -* Checks whether an element in an array passes a test. -* -* @param value - current array element -* @returns boolean indicating whether an element in an array passes a test -*/ -type UnaryPredicate = ( this: U, value: number ) => boolean; - -/** -* Checks whether an element in an array passes a test. -* -* @param value - current array element -* @param index - current array element index -* @returns boolean indicating whether an element in an array passes a test -*/ -type BinaryPredicate = ( this: U, value: number, index: number ) => boolean; - -/** -* Checks whether an element in an array passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - array on which the method was called -* @returns boolean indicating whether an element in an array passes a test -*/ -type TernaryPredicate = ( this: U, value: number, index: number, arr: Float16Array ) => boolean; - -/** -* Checks whether an element in an array passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - array on which the method was called -* @returns boolean indicating whether an element in an array passes a test -*/ -type Predicate = NullaryPredicate | UnaryPredicate | BinaryPredicate | TernaryPredicate; - -/** -* Callback invoked for each element in an array. -* -* @returns undefined -*/ -type NullaryCallback = ( this: U ) => void; - -/** -* Callback invoked for each element in an array. -* -* @param value - current array element -* @returns undefined -*/ -type UnaryCallback = ( this: U, value: number ) => void; - -/** -* Callback invoked for each element in an array. -* -* @param value - current array element -* @param index - current array element index -* @returns undefined -*/ -type BinaryCallback = ( this: U, value: number, index: number ) => void; - -/** -* Callback invoked for each element in an array. -* -* @param value - current array element -* @param index - current array element index -* @param arr - array on which the method was called -* @returns undefined -*/ -type TernaryCallback = ( this: U, value: number, index: number, arr: Float16Array ) => void; - -/** -* Callback invoked for each element in an array. -* -* @param value - current array element -* @param index - current array element index -* @param arr - array on which the method was called -* @returns undefined -*/ -type Callback = NullaryCallback | UnaryCallback | BinaryCallback | TernaryCallback; - -/** -* Callback invoked for each element in an array. -* -* @returns returned value -*/ -type NullaryMapFcn = ( this: U ) => number; - -/** -* Callback invoked for each element in an array. -* -* @param value - current array element -* @returns returned value -*/ -type UnaryMapFcn = ( this: U, value: number ) => number; - -/** -* Callback invoked for each element in an array. -* -* @param value - current array element -* @param index - current array element index -* @returns returned value -*/ -type BinaryMapFcn = ( this: U, value: number, index: number ) => number; - -/** -* Callback invoked for each element in an array. -* -* @param value - current array element -* @param index - current array element index -* @param arr - array on which the method was called -* @returns returned value -*/ -type TernaryMapFcn = ( this: U, value: number, index: number, arr: Float16Array ) => number; - -/** -* Callback invoked for each element in an array. -* -* @param value - current array element -* @param index - current array element index -* @param arr - array on which the method was called -* @returns returned value -*/ -type MapFcn = NullaryMapFcn | UnaryMapFcn | BinaryMapFcn | TernaryMapFcn; - -/** -* Reducer function invoked for each element in an array. -* -* @returns accumulated result -*/ -type NullaryReducer = () => U; - -/** -* Reducer function invoked for each element in an array. -* -* @param acc - accumulated result -* @returns accumulated result -*/ -type UnaryReducer = ( acc: U ) => U; - -/** -* Reducer function invoked for each element in an array. -* -* @param acc - accumulated result -* @param value - current array element -* @returns accumulated result -*/ -type BinaryReducer = ( acc: U, value: number ) => U; - -/** -* Reducer function invoked for each element in an array. -* -* @param acc - accumulated result -* @param value - current array element -* @param index - current array element index -* @returns accumulated result -*/ -type TernaryReducer = ( acc: U, value: number, index: number ) => U; - -/** -* @param acc - accumulated result -* @param value - current array element -* @param index - current array element index -* @param arr - array on which the method was called -* @returns accumulated result -*/ -type QuaternaryReducer = ( acc: U, value: number, index: number, arr: Float16Array ) => U; - -/** -* Reducer function invoked for each element in an array. -* -* @param acc - accumulated result -* @param value - current array element -* @param index - current array element index -* @param arr - array on which the method was called -* @returns accumulated result -*/ -type Reducer = NullaryReducer | UnaryReducer | BinaryReducer | TernaryReducer | QuaternaryReducer; - -/** -* Comparator function. -* -* @param a - first number for comparison -* @param b - second number for comparison -* @returns number indicating comparison result -*/ -type CompareFcn = ( a: number, b: number ) => number; - -/** -* Class for creating a half-precision floating-point number array. -*/ -declare class Float16Array { - /** - * Half-precision floating-point number array constructor. - * - * @param arg - length, typed array, array-like object, or buffer - * @param byteOffset - byte offset (default: 0) - * @param length - view length - * @throws ArrayBuffer byte length must be a multiple of `2` - * @throws if provided only a single argument, must provide a valid argument - * @throws byte offset must be a nonnegative integer - * @throws view length must be a positive multiple of `2` - * @throws must provide sufficient memory to accommodate byte offset and view length requirements - * @returns half-precision floating-point number array - * - * @example - * var arr = new Float16Array(); - * // returns - * - * var len = arr.length; - * // returns 0 - * - * @example - * var arr = new Float16Array( 2 ); - * // returns - * - * var len = arr.length; - * // returns 2 - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0 ] ); - * // returns - * - * var len = arr.length; - * // returns 2 - * - * @example - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = new Float16Array( buf ); - * // returns - * - * var len = arr.length; - * // returns 8 - * - * @example - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = new Float16Array( buf, 8 ); - * // returns - * - * var len = arr.length; - * // returns 4 - * - * @example - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = new Float16Array( buf, 8, 2 ); - * // returns - * - * var len = arr.length; - * // returns 2 - */ - constructor( arg?: number | ArrayLike | ArrayBuffer | Iterable, byteOffset?: number, length?: number ); - - /** - * Returns an array element located at integer position (index) `i`, with support for both nonnegative and negative integer indices. - * - * @param i - element index - * @throws index argument must be an integer - * @returns array element - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var v = arr.at( 0 ); - * // returns 1.0 - * - * v = arr.at( -1 ); - * // returns 3.0 - * - * v = arr.at( 100 ); - * // returns undefined - */ - at( i: number ): number | void; - - /** - * Pointer to the underlying data buffer. - * - * @example - * var arr = new Float16Array( 10 ); - * - * var buf = arr.buffer; - * // returns - */ - readonly buffer: ArrayBuffer; - - /** - * Length (in bytes) of the array. - * - * @example - * var arr = new Float16Array( 10 ); - * - * var byteLength = arr.byteLength; - * // returns 20 - */ - readonly byteLength: number; - - /** - * Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`. - * - * @example - * var arr = new Float16Array( 10 ); - * - * var byteOffset = arr.byteOffset; - * // returns 0 - */ - readonly byteOffset: number; - - /** - * Size (in bytes) of each array element. - * - * @example - * var arr = new Float16Array( 10 ); - * - * var nbytes = arr.BYTES_PER_ELEMENT; - * // returns 2 - */ - readonly BYTES_PER_ELEMENT: 2; - - /** - * Number of array elements. - * - * @example - * var arr = new Float16Array( 10 ); - * - * var len = arr.length; - * // returns 10 - */ - readonly length: number; - - /** - * Copies a sequence of elements within the array to the position starting at `target`. - * - * @param target - index at which to start copying elements - * @param start - source index at which to copy elements from - * @param end - source index at which to stop copying elements from - * @returns modified array - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - * - * // Copy the first two elements to the last two elements: - * arr.copyWithin( 2, 0, 2 ); - * - * var v = arr[ 2 ]; - * // returns 1.0 - * - * v = arr[ 3 ]; - * // returns 2.0 - */ - copyWithin( target: number, start: number, end?: number ): Float16Array; - - /** - * Returns an iterator for iterating over array key-value pairs. - * - * @returns iterator - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var it = arr.entries(); - * - * var v = it.next().value; - * // returns [ 0, 1.0 ] - * - * v = it.next().value; - * // returns [ 1, 2.0 ] - * - * v = it.next().value; - * // returns [ 2, 3.0 ] - * - * var bool = it.next().done; - * // returns true - */ - entries(): TypedIterator<[number, number]>; - - /** - * Tests whether all elements in an array pass a test implemented by a predicate function. - * - * @param predicate - predicate function - * @param thisArg - predicate function execution context - * @returns boolean indicating whether all elements pass a test - * - * @example - * function predicate( v ) { - * return v >= 0.0; - * } - * - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var bool = arr.every( predicate ); - * // returns true - */ - every( predicate: Predicate, thisArg?: ThisParameterType> ): boolean; - - /** - * Returns a modified typed array filled with a fill value. - * - * @param value - fill value - * @param start - starting index (inclusive) - * @param end - ending index (exclusive) - * @returns modified typed array - * - * @example - * var arr = new Float16Array( 3 ); - * - * arr.fill( 1.0, 1 ); - * - * var v = arr[ 0 ]; - * // returns 0.0 - * - * v = arr[ 1 ]; - * // returns 1.0 - * - * v = arr[ 2 ]; - * // returns 1.0 - */ - fill( value: number, start?: number, end?: number ): Float16Array; - - /** - * Returns a new array containing the elements of an array which pass a test implemented by a predicate function. - * - * @param predicate - test function - * @param thisArg - execution context - * @returns new array containing elements which pass a test implemented by a predicate function - * - * @example - * function predicate( v ) { - * return ( v >= 2.0 ); - * } - * - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var out = arr.filter( predicate ); - * // returns - * - * var len = out.length; - * // returns 2 - * - * var v = out[ 0 ]; - * // returns 2.0 - * - * v = out[ 1 ]; - * // returns 3.0 - */ - filter( predicate: Predicate, thisArg?: ThisParameterType> ): Float16Array; - - /** - * Returns the first element in an array for which a predicate function returns a truthy value. - * - * @param predicate - predicate function - * @param thisArg - predicate function execution context - * @returns array element or undefined - * - * @example - * function predicate( v ) { - * return v > 1.0; - * } - * - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var v = arr.find( predicate ); - * // returns 2.0 - */ - find( predicate: Predicate, thisArg?: ThisParameterType> ): number | void; - - /** - * Returns the index of the first element in an array for which a predicate function returns a truthy value. - * - * @param predicate - predicate function - * @param thisArg - predicate function execution context - * @returns array index or -1 - * - * @example - * function predicate( v ) { - * return v > 1.0; - * } - * - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var v = arr.findIndex( predicate ); - * // returns 1 - */ - findIndex( predicate: Predicate, thisArg?: ThisParameterType> ): number; - - /** - * Returns the last element in an array for which a predicate function returns a truthy value. - * - * @param predicate - predicate function - * @param thisArg - predicate function execution context - * @returns array element or undefined - * - * @example - * function predicate( v ) { - * return v > 1.0; - * } - * - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var v = arr.findLast( predicate ); - * // returns 3.0 - */ - findLast( predicate: Predicate, thisArg?: ThisParameterType> ): number | void; - - /** - * Returns the index of the last element in an array for which a predicate function returns a truthy value. - * - * @param predicate - predicate function - * @param thisArg - predicate function execution context - * @returns array index or -1 - * - * @example - * function predicate( v ) { - * return v > 1.0; - * } - * - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var v = arr.findLastIndex( predicate ); - * // returns 2 - */ - findLastIndex( predicate: Predicate, thisArg?: ThisParameterType> ): number; - - /** - * Invokes a function once for each array element. - * - * @param fcn - function to invoke - * @param thisArg - execution context - * @returns undefined - * - * @example - * function log( v, i ) { - * console.log( '%s: %s', i, v.toString() ); - * } - * - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * arr.forEach( log ); - */ - forEach( fcn: Callback, thisArg?: ThisParameterType> ): void; - - /** - * Returns a boolean indicating whether an array includes a provided value. - * - * @param searchElement - element to search for - * @param fromIndex - starting index (inclusive) - * @returns boolean indicating whether an array includes a value - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - * - * var bool = arr.includes( 3.0 ); - * // returns true - * - * bool = arr.includes( 3.0, 3 ); - * // returns false - */ - includes( searchElement: number, fromIndex?: number ): boolean; - - /** - * Returns the first index at which a given element can be found. - * - * @param searchElement - element to find - * @param fromIndex - starting index (inclusive) - * @returns index or -1 - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - * - * var idx = arr.indexOf( 3.0 ); - * // returns 2 - * - * idx = arr.indexOf( 3.0, 3 ); - * // returns -1 - * - * idx = arr.indexOf( 6.0 ); - * // returns -1 - */ - indexOf( searchElement: number, fromIndex?: number ): number; - - /** - * Returns a new string by concatenating all array elements. - * - * @param separator - value separator (default: ',') - * @returns string - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var str = arr.join(); - * // returns '1,2,3' - * - * str = arr.join( '|' ); - * // returns '1|2|3' - */ - join( separator?: string ): string; - - /** - * Returns an iterator for iterating over each index key in a typed array. - * - * @returns iterator - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0 ] ); - * - * var iter = arr.keys(); - * - * var v = iter.next().value; - * // returns 0 - * - * v = iter.next().value; - * // returns 1 - * - * var bool = iter.next().done; - * // returns true - */ - keys(): TypedIterator; - - /** - * Returns the last index at which a given element can be found. - * - * @param searchElement - element to find - * @param fromIndex - index at which to start searching backward (inclusive) - * @returns index or -1 - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0, 3.0, 2.0, 1.0 ] ); - * - * var idx = arr.lastIndexOf( 2.0 ); - * // returns 3 - * - * idx = arr.lastIndexOf( 2.0, 2 ); - * // returns 1 - * - * idx = arr.lastIndexOf( 5.0 ); - * // returns -1 - */ - lastIndexOf( searchElement: number, fromIndex?: number ): number; - - /** - * Returns a new array with each element being the result of a provided callback function. - * - * @param fcn - callback function - * @param thisArg - callback function execution context - * @returns new half-precision floating-point number array - * - * @example - * function scale( v ) { - * return v * 2.0; - * } - * - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var out = arr.map( scale ); - * // returns - * - * var v = out[ 0 ]; - * // returns 2.0 - * - * v = out[ 1 ]; - * // returns 4.0 - * - * v = out[ 2 ]; - * // returns 6.0 - */ - map( fcn: MapFcn, thisArg?: ThisParameterType> ): Float16Array; - - /** - * Applies a provided callback function to each element of the array, in order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion. - * - * @param reducer - callback function - * @param initialValue - initial value - * @returns accumulated result - * - * @example - * function reducer( acc, v ) { - * return acc + v; - * } - * - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var out = arr.reduce( reducer, 0.0 ); - * // returns 6.0 - */ - reduce( reducer: Reducer, initialValue?: U ): U; - - /** - * Applies a provided callback function to each element of the array, in reverse order, passing in the return value from the calculation on the following element and returning the accumulated result upon completion. - * - * @param reducer - callback function - * @param initialValue - initial value - * @returns accumulated result - * - * @example - * function reducer( acc, v ) { - * return acc + v; - * } - * - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var out = arr.reduceRight( reducer, 0.0 ); - * // returns 6.0 - */ - reduceRight( reducer: Reducer, initialValue?: U ): U; - - /** - * Reverses an array in-place. - * - * @returns reversed array - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var out = arr.reverse(); - * // returns - * - * var v = out[ 0 ]; - * // returns 3.0 - * - * v = out[ 1 ]; - * // returns 2.0 - * - * v = out[ 2 ]; - * // returns 1.0 - */ - reverse(): Float16Array; - - /** - * Sets one or more array elements. - * - * ## Notes - * - * - When provided a typed array, we must check whether the source array shares the same buffer as the target array and whether the underlying memory overlaps. In particular, we are concerned with the following scenario: - * - * ```text - * buf: --------------------- - * src: --------------------- - * ``` - * - * In the above, as we copy values from `src`, we will overwrite values in the `src` view, resulting in duplicated values copied into the end of `buf`, which is not intended. Hence, to avoid overwriting source values, we must **copy** source values to a temporary array. - * - * In the other overlapping scenario, - * - * ```text - * buf: --------------------- - * src: --------------------- - * ``` - * - * by the time we begin copying into the overlapping region, we are copying from the end of `src`, a non-overlapping region, which means we don't run the risk of copying copied values, rather than the original `src` values as intended. - * - * - * @param value - value(s) - * @param i - element index at which to start writing values (default: 0) - * @throws index argument must be a nonnegative integer - * @throws index argument is out-of-bounds - * @throws target array lacks sufficient storage to accommodate source values - * - * @example - * var arr = new Float16Array( 10 ); - * - * var v = arr[ 0 ]; - * // returns 0.0 - * - * arr.set( [ 1.0 ], 0 ); - * - * v = arr[ 0 ]; - * // returns 1.0 - */ - set( value: ArrayLike, i?: number ): void; - - /** - * Copies a portion of a typed array to a new typed array. - * - * @param start - starting index (inclusive) - * @param end - ending index (exclusive) - * @throws indices must be integers - * @returns output array - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - * - * var out = arr.slice(); - * // returns - * - * var len = out.length; - * // returns 5 - * - * var v = out[ 0 ]; - * // returns 1.0 - * - * v = out[ len-1 ]; - * // returns 5.0 - * - * out = arr.slice( 1, -2 ); - * // returns - * - * len = out.length; - * // returns 2 - * - * v = out[ 0 ]; - * // returns 2.0 - * - * v = out[ len-1 ]; - * // returns 3.0 - */ - slice( start?: number, end?: number ): Float16Array; - - /** - * Tests whether at least one element in an array passes a test implemented by a predicate function. - * - * @param predicate - predicate function - * @param thisArg - predicate function execution context - * @returns boolean indicating whether at least one element passes a test - * - * @example - * function predicate( v ) { - * return v > 2.0; - * } - * - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var bool = arr.some( predicate ); - * // returns true - */ - some( predicate: Predicate, thisArg?: ThisParameterType> ): boolean; - - /** - * Sorts an array in-place. - * - * @param compareFcn - comparison function - * @returns sorted array - * - * @example - * function compare( a, b ) { - * if ( a < b ) { - * return -1; - * } - * if ( a > b ) { - * return 1; - * } - * return 0; - * } - * - * var arr = new Float16Array( [ 3.0, 1.0, 2.0 ] ); - * - * arr.sort( compare ); - * - * var v = arr[ 0 ]; - * // returns 1.0 - * - * v = arr[ 1 ]; - * // returns 2.0 - * - * v = arr[ 2 ]; - * // returns 3.0 - */ - sort( compareFcn?: CompareFcn ): Float16Array; - - /** - * Creates a new typed array view over the same underlying `ArrayBuffer` and with the same underlying data type as the host array. - * - * @param begin - starting index (inclusive) - * @param end - ending index (exclusive) - * @throws indices must be integers - * @returns subarray - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - * - * var subarr = arr.subarray(); - * // returns - * - * var len = subarr.length; - * // returns 5 - * - * var v = subarr[ 0 ]; - * // returns 1.0 - * - * v = subarr[ len-1 ]; - * // returns 5.0 - * - * subarr = arr.subarray( 1, -2 ); - * // returns - * - * len = subarr.length; - * // returns 2 - * - * v = subarr[ 0 ]; - * // returns 2.0 - * - * v = subarr[ len-1 ]; - * // returns 3.0 - */ - subarray( begin?: number, end?: number ): Float16Array; - - /** - * Serializes an array as a locale-specific string. - * - * @param locales - locale identifier(s) - * @param options - configuration options - * @returns string - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var str = arr.toLocaleString(); - * // returns '1,2,3' - */ - toLocaleString( locales?: string | Array, options?: LocaleOptions ): string; - - /** - * Returns a new typed array containing the elements in reversed order. - * - * @returns reversed array - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var out = arr.toReversed(); - * // returns - * - * var v = out[ 0 ]; - * // returns 3.0 - * - * v = out[ 1 ]; - * // returns 2.0 - * - * v = out[ 2 ]; - * // returns 1.0 - */ - toReversed(): Float16Array; - - /** - * Returns a new typed array containing the elements in sorted order. - * - * @param compareFcn - comparison function - * @returns sorted array - * - * @example - * function compare( a, b ) { - * if ( a < b ) { - * return -1; - * } - * if ( a > b ) { - * return 1; - * } - * return 0; - * } - * - * var arr = new Float16Array( [ 3.0, 1.0, 2.0 ] ); - * - * var out = arr.toSorted( compare ); - * // returns - * - * var v = out[ 0 ]; - * // returns 1.0 - * - * v = out[ 1 ]; - * // returns 2.0 - * - * v = out[ 2 ]; - * // returns 3.0 - */ - toSorted( compareFcn?: CompareFcn ): Float16Array; - - /** - * Serializes an array as a string. - * - * @returns string - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var str = arr.toString(); - * // returns '1,2,3' - */ - toString(): string; - - /** - * Returns an iterator for iterating over each value in a typed array. - * - * @returns iterator - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0 ] ); - * - * var iter = arr.values(); - * - * var v = iter.next().value; - * // returns 1.0 - * - * v = iter.next().value; - * // returns 2.0 - * - * var bool = iter.next().done; - * // returns true - */ - values(): TypedIterator; - - /** - * Returns a new typed array with the element at a provided index replaced with a provided value. - * - * @param index - element index - * @param value - new value - * @throws first argument must be an integer - * @throws second argument must be a number - * @throws index argument is out-of-bounds - * @returns modified typed array - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var out = arr.with( 0, 4.0 ); - * // returns - * - * var v = out[ 0 ]; - * // returns 4.0 - */ - with( index: number, value: number ): Float16Array; -} - -/** -* Interface defining a Float16Array constructor which is both "newable" and "callable". -*/ -interface Float16ArrayConstructor { - /** - * Half-precision floating-point number array constructor. - * - * @param arg - length, typed array, array-like object, or buffer - * @param byteOffset - byte offset (default: 0) - * @param length - view length - * @throws ArrayBuffer byte length must be a multiple of `2` - * @throws if provided only a single argument, must provide a valid argument - * @throws byte offset must be a nonnegative integer - * @throws byte offset must be a multiple of `2` - * @throws view length must be a positive multiple of `2` - * @throws must provide sufficient memory to accommodate byte offset and view length requirements - * @returns half-precision floating-point number array - * - * @example - * var arr = new Float16Array(); - * // returns - * - * var len = arr.length; - * // returns 0 - * - * @example - * var arr = new Float16Array( 2 ); - * // returns - * - * var len = arr.length; - * // returns 2 - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0 ] ); - * // returns - * - * var len = arr.length; - * // returns 2 - * - * @example - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = new Float16Array( buf ); - * // returns - * - * var len = arr.length; - * // returns 8 - * - * @example - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = new Float16Array( buf, 8 ); - * // returns - * - * var len = arr.length; - * // returns 4 - * - * @example - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = new Float16Array( buf, 8, 2 ); - * // returns - * - * var len = arr.length; - * // returns 2 - */ - new( arg?: number | ArrayLike | ArrayBuffer | Iterable, byteOffset?: number, length?: number ): Float16Array; - - /** - * Constructor name. - * - * @example - * var str = Float16Array.name; - * // returns 'Float16Array' - */ - readonly name: 'Float16Array'; - - /** - * Size (in bytes) of each array element. - * - * @example - * var nbytes = Float16Array.BYTES_PER_ELEMENT; - * // returns 2 - */ - readonly BYTES_PER_ELEMENT: 2; - - /** - * Creates a new half-precision floating-point number array from an array-like object or an iterable. - * - * @param src - array-like object or iterable - * @param clbk - callback to invoke for each source element - * @param thisArg - context - * @returns half-precision floating-point number array - * - * @example - * var arr = Float16Array.from( [ 1.0, 2.0 ] ); - * // returns - * - * var len = arr.length; - * // returns 2 - * - * @example - * function clbk( v ) { - * return v * 2.0; - * } - * - * var arr = Float16Array.from( [ 1.0, 2.0 ], clbk ); - * // returns - * - * var len = arr.length; - * // returns 2 - */ - from( src: ArrayLike | Iterable, clbk?: FromCallback, thisArg?: ThisParameterType> ): Float16Array; - - /** - * Creates a new half-precision floating-point number array from a variable number of arguments. - * - * @param elements - array elements - * @returns half-precision floating-point number array - * - * @example - * var arr = Float16Array.of( 1.0, 2.0, 3.0, 4.0 ); - * // returns - * - * var len = arr.length; - * // returns 4 - */ - of( ...elements: Array ): Float16Array; -} - -/** -* Half-precision floating-point number array constructor. -* -* @param arg - length, typed array, array-like object, or buffer -* @param byteOffset - byte offset (default: 0) -* @param length - view length -* @throws ArrayBuffer byte length must be a multiple of `2` -* @throws if provided only a single argument, must provide a valid argument -* @throws byte offset must be a nonnegative integer -* @throws byte offset must be a multiple of `2` -* @throws view length must be a positive multiple of `2` -* @throws must provide sufficient memory to accommodate byte offset and view length requirements -* @returns half-precision floating-point number array -* -* @example -* var arr = new Float16Array(); -* // returns -* -* var len = arr.length; -* // returns 0 -* -* @example -* var arr = new Float16Array( 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var arr = new Float16Array( [ 1.0, 2.0 ] ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float16Array( buf ); -* // returns -* -* var len = arr.length; -* // returns 8 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float16Array( buf, 8 ); -* // returns -* -* var len = arr.length; -* // returns 4 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = new Float16Array( buf, 8, 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -*/ -declare var ctor: Float16ArrayConstructor; - - -// EXPORTS // - -export = ctor; - -// eslint-doctest-alias: Float16Array diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 16ac68e..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-float16array-support@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.3-esm/index.mjs";import{isPrimitive as n}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.3-esm/index.mjs";import{primitives as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string-array@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.3-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.3-esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.3-esm/index.mjs";import{isPrimitive as h}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.3-esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.3-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-assert-is-nan@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.4-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.3-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@v0.2.4-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint16@v0.2.3-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-float16@v0.1.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float16-base-to-word@v0.1.1-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float16-base-from-word@v0.2.1-esm/index.mjs";import T from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-base-gcopy@v0.2.3-esm/index.mjs";function _(t){var r,n;for(r=[];!(n=t.next()).done;)r.push(b(m(n.value)));return r}var j=g.BYTES_PER_ELEMENT,x=r();function L(t){return"object"==typeof t&&null!==t&&"Float16Array"===t.constructor.name&&t.BYTES_PER_ELEMENT===j}function R(t){return t===A}function O(t,r){return function(){return t._get(r)}}function S(t,r){return function(n){t.set([n],r)}}function A(){var t,r,i,h,l,u;if(r=arguments.length,!(this instanceof A))return 0===r?new A:1===r?new A(arguments[0]):2===r?new A(arguments[0],arguments[1]):new A(arguments[0],arguments[1],arguments[2]);if(0===r)i=new g(0);else if(1===r)if(n(l=arguments[0]))i=new g(l);else if(e(l))L(l)?(i=new g(l.length),T.ndarray(l.length,new g(l.buffer,l.byteOffset,l.length),1,0,i,1,0)):i=function(t,r){var n,i;for(n=r.length,i=0;ii.byteLength-t)throw new RangeError(d("null2G",h*j));i=new g(i,t,h)}}for(y(this,"_buffer",i),y(this,"_length",i.length),u=0;u1){if(!s(i=arguments[1]))throw new TypeError(d("null2H",i));n>2&&(r=arguments[2])}if(e(t)){if(i){for(f=(o=new this(l=t.length))._buffer,u=0;u=this._length))return E(this._buffer[t])})),w(A.prototype,"buffer",(function(){return this._buffer.buffer})),w(A.prototype,"byteLength",(function(){return this._buffer.byteLength})),w(A.prototype,"byteOffset",(function(){return this._buffer.byteOffset})),y(A.prototype,"BYTES_PER_ELEMENT",A.BYTES_PER_ELEMENT),y(A.prototype,"copyWithin",(function(t,r){if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");return 2===arguments.length?this._buffer.copyWithin(t,r):this._buffer.copyWithin(t,r,arguments[2]),this})),y(A.prototype,"entries",(function(){var t,r,n,i,e,o;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");return t=this,i=this._buffer,n=this._length,o=-1,y(r={},"next",(function(){if(o+=1,e||o>=n)return{done:!0};return{value:[o,E(i[o])],done:!1}})),y(r,"return",(function(t){if(e=!0,arguments.length)return{value:t,done:!0};return{done:!0}})),p&&y(r,p,(function(){return t.entries()})),r})),y(A.prototype,"every",(function(t,r){var n,i;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!s(t))throw new TypeError(d("null3c",t));for(n=this._buffer,i=0;i1){if(!f(r))throw new TypeError(d("null7f",r));if(r<0&&(r+=e)<0&&(r=0),arguments.length>2){if(!f(n))throw new TypeError(d("null2z",n));n<0&&(n+=e)<0&&(n=0),n>e&&(n=e)}else n=e}else r=0,n=e;for(s=b(t),o=r;o=0;e--)if(i=E(n[e]),t.call(r,i,e,this))return i})),y(A.prototype,"findLastIndex",(function(t,r){var n,i,e;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!s(t))throw new TypeError(d("null3c",t));for(n=this._buffer,e=this._length-1;e>=0;e--)if(i=E(n[e]),t.call(r,i,e,this))return e;return-1})),y(A.prototype,"forEach",(function(t,r){var n,i;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!s(t))throw new TypeError(d("null3c",t));for(n=this._buffer,i=0;i=this._length))return E(this._buffer[t])})),y(A.prototype,"includes",(function(t,r){var n,i,e;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!h(t))throw new TypeError(d("null49",t));if(arguments.length>1){if(!f(r))throw new TypeError(d("null7f",r));r<0&&(r+=this._length)<0&&(r=0)}else r=0;for(n=this._buffer,e=b(t),i=r;i1){if(!f(r))throw new TypeError(d("null7f",r));r<0&&(r+=this._length)<0&&(r=0)}else r=0;for(n=this._buffer,e=b(t),i=r;i0){if(!l(t))throw new TypeError(d("null3F",t))}else t=",";for(r=this._buffer,n=[],i=0;i=n)return{done:!0};return{value:e,done:!1}})),y(r,"return",(function(t){if(i=!0,arguments.length)return{value:t,done:!0};return{done:!0}})),p&&y(r,p,(function(){return t.keys()})),r})),y(A.prototype,"lastIndexOf",(function(t,r){var n,i,e;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!h(t))throw new TypeError(d("null49",t));if(arguments.length>1){if(!f(r))throw new TypeError(d("null7f",r));r>=this._length?r=this._length-1:r<0&&(r+=this._length)}else r=this._length-1;for(n=this._buffer,e=b(t),i=r;i>=0;i--)if(e===n[i])return i;return-1})),w(A.prototype,"length",(function(){return this._length})),y(A.prototype,"map",(function(t,r){var n,i,e,o;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!s(t))throw new TypeError(d("null3c"),t);for(e=this._buffer,n=(i=new this.constructor(this._length))._buffer,o=0;o1)e=r,o=0;else{if(0===i)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");e=E(n[0]),o=1}for(;o1)e=r,o=i-1;else{if(0===i)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");e=E(n[i-1]),o=i-2}for(;o>=0;o--)e=t(e,E(n[o]),o,this);return e})),y(A.prototype,"reverse",(function(){var t,r,n,i,e,o;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");for(t=this._buffer,n=this._length,i=v(n/2),e=0;e1){if(!n(i=arguments[1]))throw new TypeError(d("null2L",i))}else i=0;if(i+(h=t.length)>this._length)throw new RangeError(d("null03"));if(L(t)?(r=t._buffer,f=!0):(r=t,f=!1),a=o.byteOffset+i*j,r.buffer===o.buffer&&r.byteOffseta){for(s=new g(r.length),l=0;ls&&(r=s)}}for(n=ti)return 1;return 0})),this;if(!s(t))throw new TypeError(d("null3c",t));return r.sort((function(r,n){return t(E(r),E(n))})),this})),y(A.prototype,"subarray",(function(t,r){var n,i,e;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(i=this._buffer,e=this._length,0===arguments.length)t=0,r=e;else{if(!f(t))throw new TypeError(d("null7e",t));if(t<0&&(t+=e)<0&&(t=0),1===arguments.length)r=e;else{if(!f(r))throw new TypeError(d("null7f",r));r<0?(r+=e)<0&&(r=0):r>e&&(r=e)}}return t>=e?(e=0,n=i.byteLength):t>=r?(e=0,n=i.byteOffset+t*j):(e=r-t,n=i.byteOffset+t*j),new this.constructor(i.buffer,n,e<0?0:e)})),y(A.prototype,"toLocaleString",(function(t,r){var n,e,o,s,f;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(0===arguments.length)e=[];else{if(!l(t)&&!i(t))throw new TypeError(d("invalid argument. First argument must be a string or an array of strings. Value: `%s`.",t));e=t}if(arguments.length<2)n={};else{if(!a(r))throw new TypeError(d("null2V",r));n=r}for(s=this._buffer,o=[],f=0;f=n)return{done:!0};return{value:E(e[o]),done:!1}})),y(t,"return",(function(t){if(i=!0,arguments.length)return{value:t,done:!0};return{done:!0}})),p&&y(t,p,(function(){return r.values()})),t})),y(A.prototype,"with",(function(t,r){var n,i;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!f(t))throw new TypeError(d("null7e",t));if(i=this._length,t<0&&(t+=i),t<0||t>=i)throw new RangeError(d("nullFP",t));if(!h(r))throw new TypeError(d("invalid argument. Second argument must be a floating-point number. Value: `%s`.",r));return(n=new this.constructor(this))[t]=r,n}));var P="function"==typeof Float16Array?Float16Array:void 0,F=t()?P:A;export{F as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index d0d8a32..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/polyfill/from_iterator.js","../lib/polyfill/index.js","../lib/polyfill/from_array.js","../lib/polyfill/from_iterator_map.js","../lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport f16 from '@stdlib/number-float64-base-to-float16';\nimport toWord from '@stdlib/number-float16-base-to-word';\n\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @returns {Array} output array\n*/\nfunction fromIterator( it ) {\n\tvar out;\n\tvar v;\n\n\tout = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tout.push( toWord( f16( v.value ) ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIterator;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this, stdlib/jsdoc-typedef-typos, max-lines */\n\n'use strict';\n\n// MODULES //\n\nimport hasIteratorSymbolSupport from '@stdlib/assert-has-iterator-symbol-support';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport { primitives as isStringArray } from '@stdlib/assert-is-string-array';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isFunction from '@stdlib/assert-is-function';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isObject from '@stdlib/assert-is-object';\nimport isnan from '@stdlib/math-base-assert-is-nan';\nimport ITERATOR_SYMBOL from '@stdlib/symbol-iterator';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadWriteAccessor from '@stdlib/utils-define-read-write-accessor';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport Uint16Array from '@stdlib/array-uint16';\nimport f16 from '@stdlib/number-float64-base-to-float16';\nimport toWord from '@stdlib/number-float16-base-to-word';\nimport fromWord from '@stdlib/number-float16-base-from-word';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport fromArray from './from_array.js';\nimport fromIterator from './from_iterator.js';\nimport fromIteratorMap from './from_iterator_map.js';\n\n\n// VARIABLES //\n\nvar BYTES_PER_ELEMENT = Uint16Array.BYTES_PER_ELEMENT;\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\n\n\n// FUNCTIONS //\n\n/**\n* Returns a boolean indicating if a value is a `Float16Array`.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `Float16Array`\n*/\nfunction isFloat16Array( value ) {\n\treturn (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\tvalue.constructor.name === 'Float16Array' &&\n\t\tvalue.BYTES_PER_ELEMENT === BYTES_PER_ELEMENT\n\t);\n}\n\n/**\n* Returns a boolean indicating if a value is a floating-point typed array constructor.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a floating-point typed array constructor\n*/\nfunction isFloatingPointArrayConstructor( value ) { // eslint-disable-line id-length\n\treturn ( value === Float16Array );\n}\n\n/**\n* Returns a getter.\n*\n* @private\n* @param {Float16Array} ctx - typed array instance\n* @param {NonNegativeInteger} idx - element index\n* @returns {Function} getter\n*/\nfunction getter( ctx, idx ) {\n\treturn get;\n\n\t/**\n\t* Returns an array element.\n\t*\n\t* @private\n\t* @returns {(number|void)} array element\n\t*/\n\tfunction get() {\n\t\treturn ctx._get( idx ); // eslint-disable-line no-underscore-dangle\n\t}\n}\n\n/**\n* Returns a setter.\n*\n* @private\n* @param {Float16Array} ctx - typed array instance\n* @param {NonNegativeInteger} idx - element index\n* @returns {Function} setter\n*/\nfunction setter( ctx, idx ) {\n\treturn set;\n\n\t/**\n\t* Sets an array element.\n\t*\n\t* @private\n\t* @param {number} value - value to set\n\t*/\n\tfunction set( value ) {\n\t\tctx.set( [ value ], idx );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* 16-bit floating-point number array constructor.\n*\n* @constructor\n* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable\n* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n* @param {NonNegativeInteger} [length] - view length\n* @throws {RangeError} ArrayBuffer byte length must be a multiple of `2`\n* @throws {TypeError} if provided only a single argument, must provide a valid argument\n* @throws {TypeError} byte offset must be a nonnegative integer\n* @throws {RangeError} byte offset must be a multiple of `2`\n* @throws {TypeError} view length must be a positive multiple of `2`\n* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n* @returns {Float16Array} half-precision floating-point number array\n*\n* @example\n* var arr = new Float16Array();\n* // returns \n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var arr = new Float16Array( 5 );\n* // returns \n*\n* var len = arr.length;\n* // returns 5\n*\n* @example\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 5\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float16Array( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 8\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float16Array( buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 4\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Float16Array( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nfunction Float16Array() {\n\tvar byteOffset;\n\tvar nargs;\n\tvar buf;\n\tvar len;\n\tvar arg;\n\tvar i;\n\n\tnargs = arguments.length;\n\tif ( !(this instanceof Float16Array) ) {\n\t\tif ( nargs === 0 ) {\n\t\t\treturn new Float16Array();\n\t\t}\n\t\tif ( nargs === 1 ) {\n\t\t\treturn new Float16Array( arguments[0] );\n\t\t}\n\t\tif ( nargs === 2 ) {\n\t\t\treturn new Float16Array( arguments[0], arguments[1] );\n\t\t}\n\t\treturn new Float16Array( arguments[0], arguments[1], arguments[2] );\n\t}\n\t// Create the underlying data buffer...\n\tif ( nargs === 0 ) {\n\t\tbuf = new Uint16Array( 0 ); // backward-compatibility\n\t} else if ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\t\tif ( isNonNegativeInteger( arg ) ) {\n\t\t\tbuf = new Uint16Array( arg );\n\t\t} else if ( isCollection( arg ) ) {\n\t\t\tif ( isFloat16Array( arg ) ) {\n\t\t\t\tbuf = new Uint16Array( arg.length );\n\t\t\t\tgcopy.ndarray( arg.length, new Uint16Array( arg.buffer, arg.byteOffset, arg.length ), 1, 0, buf, 1, 0 ); // eslint-disable-line max-len\n\t\t\t} else {\n\t\t\t\tbuf = fromArray( new Uint16Array( arg.length ), arg );\n\t\t\t}\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tif ( !isInteger( arg.byteLength/BYTES_PER_ELEMENT ) ) {\n\t\t\t\tthrow new RangeError( format( 'nullE9', BYTES_PER_ELEMENT, arg.byteLength ) );\n\t\t\t}\n\t\t\tbuf = new Uint16Array( arg );\n\t\t} else if ( isObject( arg ) ) {\n\t\t\tif ( HAS_ITERATOR_SYMBOL === false ) {\n\t\t\t\tthrow new TypeError( format( 'null29', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2A', arg ) );\n\t\t\t}\n\t\t\tbuf = arg[ ITERATOR_SYMBOL ]();\n\t\t\tif ( !isFunction( buf.next ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2A', arg ) );\n\t\t\t}\n\t\t\tbuf = new Uint16Array( fromIterator( buf ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( 'null2A', arg ) );\n\t\t}\n\t} else {\n\t\tbuf = arguments[ 0 ];\n\t\tif ( !isArrayBuffer( buf ) ) {\n\t\t\tthrow new TypeError( format( 'null2B', buf ) );\n\t\t}\n\t\tbyteOffset = arguments[ 1 ];\n\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\tthrow new TypeError( format( 'null2C', byteOffset ) );\n\t\t}\n\t\tif ( !isInteger( byteOffset/BYTES_PER_ELEMENT ) ) {\n\t\t\tthrow new RangeError( format( 'nullEA', BYTES_PER_ELEMENT, byteOffset ) );\n\t\t}\n\t\tif ( nargs === 2 ) {\n\t\t\tlen = buf.byteLength - byteOffset;\n\t\t\tif ( !isInteger( len/BYTES_PER_ELEMENT ) ) {\n\t\t\t\tthrow new RangeError( format( 'null2E', BYTES_PER_ELEMENT, len ) );\n\t\t\t}\n\t\t\tbuf = new Uint16Array( buf, byteOffset );\n\t\t} else {\n\t\t\tlen = arguments[ 2 ];\n\t\t\tif ( !isNonNegativeInteger( len ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2F', len ) );\n\t\t\t}\n\t\t\tif ( (len*BYTES_PER_ELEMENT) > (buf.byteLength-byteOffset) ) {\n\t\t\t\tthrow new RangeError( format( 'null2G', len*BYTES_PER_ELEMENT ) );\n\t\t\t}\n\t\t\tbuf = new Uint16Array( buf, byteOffset, len );\n\t\t}\n\t}\n\tsetReadOnly( this, '_buffer', buf );\n\tsetReadOnly( this, '_length', buf.length );\n\tfor ( i = 0; i < buf.length; i++ ) {\n\t\tsetReadWriteAccessor( this, i, getter( this, i ), setter( this, i ) );\n\t}\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each array element.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Float16Array\n* @readonly\n* @type {PositiveInteger}\n* @default 2\n*\n* @example\n* var nbytes = Float16Array.BYTES_PER_ELEMENT;\n* // returns 2\n*/\nsetReadOnly( Float16Array, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT );\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof Float16Array\n* @readonly\n* @type {string}\n* @default 'Float16Array'\n*\n* @example\n* var str = Float16Array.name;\n* // returns 'Float16Array'\n*/\nsetReadOnly( Float16Array, 'name', 'Float16Array' );\n\n/**\n* Creates a new 16-bit floating-point number array from an array-like object or an iterable.\n*\n* @name from\n* @memberof Float16Array\n* @type {Function}\n* @param {(Collection|Iterable)} src - array-like object or iterable\n* @param {Function} [clbk] - callback to invoke for each source element\n* @param {*} [thisArg] - context\n* @throws {TypeError} `this` context must be a constructor\n* @throws {TypeError} `this` must be a floating-point array\n* @throws {TypeError} first argument must be an array-like object or an iterable\n* @throws {TypeError} second argument must be a function\n* @returns {Float16Array} half-precision floating-point number array\n*\n* @example\n* var arr = Float16Array.from( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* function clbk( v ) {\n* return v * 2.0;\n* }\n*\n* var arr = Float16Array.from( [ 1.0, 2.0 ], clbk );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nsetReadOnly( Float16Array, 'from', function from( src ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar clbk;\n\tvar out;\n\tvar buf;\n\tvar tmp;\n\tvar len;\n\tvar i;\n\tif ( !isFunction( this ) ) {\n\t\tthrow new TypeError( format('null01') );\n\t}\n\tif ( !isFloatingPointArrayConstructor( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point array.' );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs > 1 ) {\n\t\tclbk = arguments[ 1 ];\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'null2H', clbk ) );\n\t\t}\n\t\tif ( nargs > 2 ) {\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( isCollection( src ) ) {\n\t\tif ( clbk ) {\n\t\t\tlen = src.length;\n\t\t\tout = new this( len );\n\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tbuf[ i ] = toWord( f16( clbk.call( thisArg, src[ i ], i ) ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\treturn new this( src );\n\t}\n\tif ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) { // eslint-disable-line max-len\n\t\tbuf = src[ ITERATOR_SYMBOL ]();\n\t\tif ( !isFunction( buf.next ) ) {\n\t\t\tthrow new TypeError( format( 'null2J', src ) );\n\t\t}\n\t\tif ( clbk ) {\n\t\t\ttmp = fromIteratorMap( buf, clbk, thisArg );\n\t\t} else {\n\t\t\ttmp = fromIterator( buf );\n\t\t}\n\t\tif ( tmp instanceof Error ) {\n\t\t\tthrow tmp;\n\t\t}\n\t\tlen = tmp.length;\n\t\tout = new this( len );\n\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tbuf[ i ] = tmp[ i ];\n\t\t}\n\t\treturn out;\n\t}\n\tthrow new TypeError( format( 'null2J', src ) );\n});\n\n/**\n* Creates a new 16-bit floating-point number array from a variable number of arguments.\n*\n* @name of\n* @memberof Float16Array\n* @type {Function}\n* @param {...*} element - array elements\n* @throws {TypeError} `this` context must be a constructor\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Float16Array} half-precision floating-point number array\n*\n* @example\n* var arr = Float16Array.of( 1.0, 1.0, 1.0, 1.0 );\n* // returns \n*\n* var x = arr[ 0 ];\n* // returns 1.0\n*\n* var len = arr.length;\n* // returns 4\n*/\nsetReadOnly( Float16Array, 'of', function of() {\n\tvar args;\n\tvar i;\n\tif ( !isFunction( this ) ) {\n\t\tthrow new TypeError( format('null01') );\n\t}\n\tif ( !isFloatingPointArrayConstructor( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\targs = [];\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\targs.push( arguments[ i ] );\n\t}\n\treturn new this( args );\n});\n\n/**\n* Returns an array element with support for both nonnegative and negative integer indices.\n*\n* @name at\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} must provide an integer\n* @returns {(number|void)} array element\n*\n* @example\n* var arr = new Float16Array( [ 10.0, 20.0, 30.0 ] );\n*\n* var v = arr.at( 0 );\n* // returns 10.0\n*\n* v = arr.at( -1 );\n* // returns 30.0\n*\n* v = arr.at( 100 );\n* // returns undefined\n*/\nsetReadOnly( Float16Array.prototype, 'at', function at( idx ) {\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'null8A', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += this._length;\n\t}\n\tif ( idx < 0 || idx >= this._length ) {\n\t\treturn;\n\t}\n\treturn fromWord( this._buffer[ idx ] );\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name buffer\n* @memberof Float16Array.prototype\n* @readonly\n* @type {ArrayBuffer}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var buf = arr.buffer;\n* // returns \n*/\nsetReadOnlyAccessor( Float16Array.prototype, 'buffer', function get() {\n\treturn this._buffer.buffer;\n});\n\n/**\n* Size (in bytes) of the array.\n*\n* @name byteLength\n* @memberof Float16Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var byteLength = arr.byteLength;\n* // returns 20\n*/\nsetReadOnlyAccessor( Float16Array.prototype, 'byteLength', function get() {\n\treturn this._buffer.byteLength;\n});\n\n/**\n* Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`.\n*\n* @name byteOffset\n* @memberof Float16Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var byteOffset = arr.byteOffset;\n* // returns 0\n*/\nsetReadOnlyAccessor( Float16Array.prototype, 'byteOffset', function get() {\n\treturn this._buffer.byteOffset;\n});\n\n/**\n* Size (in bytes) of each array element.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Float16Array.prototype\n* @readonly\n* @type {PositiveInteger}\n* @default 2\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var nbytes = arr.BYTES_PER_ELEMENT;\n* // returns 2\n*/\nsetReadOnly( Float16Array.prototype, 'BYTES_PER_ELEMENT', Float16Array.BYTES_PER_ELEMENT );\n\n/**\n* Copies a sequence of elements within the array to the position starting at `target`.\n*\n* @name copyWithin\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} target - index at which to start copying elements\n* @param {integer} start - source index at which to copy elements from\n* @param {integer} [end] - source index at which to stop copying elements from\n* @throws {TypeError} `this` must be a floating-point array\n* @returns {Float16Array} modified array\n*\n* @example\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0 ] );\n*\n* // Copy the first two elements to the last two elements:\n* arr.copyWithin( 2, 0, 2 );\n*\n* var v = arr[ 2 ];\n* // returns 1.0\n*\n* v = arr[ 3 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'copyWithin', function copyWithin( target, start ) {\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\t// FIXME: prefer a functional `copyWithin` implementation which addresses lack of universal browser support (e.g., IE11 and Safari) or ensure that typed arrays are polyfilled\n\tif ( arguments.length === 2 ) {\n\t\tthis._buffer.copyWithin( target, start );\n\t} else {\n\t\tthis._buffer.copyWithin( target, start, arguments[2] );\n\t}\n\treturn this;\n});\n\n/**\n* Returns an iterator for iterating over array key-value pairs.\n*\n* @name entries\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] );\n*\n* var it = arr.entries();\n*\n* var v = it.next().value;\n* // returns [ 0, 1.0 ]\n*\n* v = it.next().value;\n* // returns [ 1, 2.0 ]\n*\n* v = it.next().value;\n* // returns [ 2, 3.0 ]\n*\n* var bool = it.next().done;\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'entries', function entries() {\n\tvar self;\n\tvar iter;\n\tvar len;\n\tvar buf;\n\tvar FLG;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tself = this;\n\tbuf = this._buffer;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': [ i, fromWord( buf[ i ] ) ],\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.entries();\n\t}\n});\n\n/**\n* Tests whether all elements in an array pass a test implemented by a predicate function.\n*\n* @name every\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {boolean} boolean indicating whether all elements pass a test\n*\n* @example\n* function predicate( v ) {\n* return v === 0.0;\n* }\n*\n* var arr = new Float16Array( 3 );\n*\n* var bool = arr.every( predicate );\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'every', function every( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( !predicate.call( thisArg, fromWord( buf[ i ] ), i, this ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n});\n\n/**\n* Returns a modified typed array filled with a fill value.\n*\n* @name fill\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {number} value - fill value\n* @param {integer} [start=0] - starting index (inclusive)\n* @param {integer} [end] - ending index (exclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a floating-point number\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be an integer\n* @returns {Float16Array} modified array\n*\n* @example\n* var arr = new Float16Array( 3 );\n*\n* arr.fill( 1.0, 1 );\n*\n* var v = arr[ 0 ];\n* // returns 0.0\n*\n* v = arr[ 1 ];\n* // returns 1.0\n*\n* v = arr[ 2 ];\n* // returns 1.0\n*/\nsetReadOnly( Float16Array.prototype, 'fill', function fill( value, start, end ) {\n\tvar buf;\n\tvar len;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNumber( value ) ) {\n\t\tthrow new TypeError( format( 'null49', value ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( start ) ) {\n\t\t\tthrow new TypeError( format( 'null7f', start ) );\n\t\t}\n\t\tif ( start < 0 ) {\n\t\t\tstart += len;\n\t\t\tif ( start < 0 ) {\n\t\t\t\tstart = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length > 2 ) {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2z', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t} else {\n\t\t\tend = len;\n\t\t}\n\t} else {\n\t\tstart = 0;\n\t\tend = len;\n\t}\n\tv = toWord( value );\n\tfor ( i = start; i < end; i++ ) {\n\t\tbuf[ i ] = v;\n\t}\n\treturn this;\n});\n\n/**\n* Returns a new array containing the elements of an array which pass a test implemented by a predicate function.\n*\n* @name filter\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {Float16Array} floating-point number array\n*\n* @example\n* function predicate( v ) {\n* return ( v === 0.0 );\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] );\n*\n* var out = arr.filter( predicate );\n* // returns \n*\n* var len = out.length;\n* // returns 2\n*\n* var v = out[ 0 ];\n* // returns 0.0\n*\n* v = out[ 1 ];\n* // returns 0.0\n*/\nsetReadOnly( Float16Array.prototype, 'filter', function filter( predicate, thisArg ) {\n\tvar buf;\n\tvar out;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\tout.push( v );\n\t\t}\n\t}\n\treturn new this.constructor( out );\n});\n\n/**\n* Returns the first element in an array for which a predicate function returns a truthy value.\n*\n* @name find\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {(boolean|void)} array element or undefined\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] );\n*\n* var v = arr.find( predicate );\n* // returns 1.0\n*/\nsetReadOnly( Float16Array.prototype, 'find', function find( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn v;\n\t\t}\n\t}\n});\n\n/**\n* Returns the index of the first element in an array for which a predicate function returns a truthy value.\n*\n* @name findIndex\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {integer} index or -1\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var v = arr.findIndex( predicate );\n* // returns 1\n*/\nsetReadOnly( Float16Array.prototype, 'findIndex', function findIndex( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Returns the last element in an array for which a predicate function returns a truthy value.\n*\n* @name findLast\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {(boolean|void)} array element or undefined\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] );\n*\n* var v = arr.findLast( predicate );\n* // returns 1.0\n*/\nsetReadOnly( Float16Array.prototype, 'findLast', function findLast( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = this._length-1; i >= 0; i-- ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn v;\n\t\t}\n\t}\n});\n\n/**\n* Returns the index of the last element in an array for which a predicate function returns a truthy value.\n*\n* @name findLastIndex\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {integer} index or -1\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] );\n*\n* var v = arr.findLastIndex( predicate );\n* // returns 1\n*/\nsetReadOnly( Float16Array.prototype, 'findLastIndex', function findLastIndex( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = this._length-1; i >= 0; i-- ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Invokes a function once for each array element.\n*\n* @name forEach\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} fcn - function to invoke\n* @param {*} [thisArg] - function invocation context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n*\n* @example\n* function log( v, i ) {\n* console.log( '%s: %s', i, v.toString() );\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* arr.forEach( log );\n*/\nsetReadOnly( Float16Array.prototype, 'forEach', function forEach( fcn, thisArg ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( fcn ) ) {\n\t\tthrow new TypeError( format( 'null3c', fcn ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tfcn.call( thisArg, fromWord( buf[ i ] ), i, this );\n\t}\n});\n\n/**\n* Returns an array element.\n*\n* @private\n* @name _get\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {NonNegativeInteger} idx - element index\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} must provide a nonnegative integer\n* @returns {(number|void)} array element\n*/\nsetReadOnly( Float16Array.prototype, '_get', function get( idx ) {\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNonNegativeInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'null2K', idx ) );\n\t}\n\tif ( idx >= this._length ) {\n\t\treturn;\n\t}\n\treturn fromWord( this._buffer[ idx ] );\n});\n\n/**\n* Returns a boolean indicating whether an array includes a provided value.\n*\n* @name includes\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {number} searchElement - search element\n* @param {integer} [fromIndex=0] - starting index (inclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a floating-point number\n* @throws {TypeError} second argument must be an integer\n* @returns {boolean} boolean indicating whether an array includes a value\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] );\n*\n* var bool = arr.includes( 1.0 );\n* // returns true\n*\n* bool = arr.includes( 1.0, 2 );\n* // returns false\n*\n* bool = arr.includes( 5.0 );\n* // returns false\n*/\nsetReadOnly( Float16Array.prototype, 'includes', function includes( searchElement, fromIndex ) {\n\tvar buf;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNumber( searchElement ) ) {\n\t\tthrow new TypeError( format( 'null49', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'null7f', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\tfromIndex = 0;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfromIndex = 0;\n\t}\n\tbuf = this._buffer;\n\tv = toWord( searchElement );\n\tfor ( i = fromIndex; i < this._length; i++ ) {\n\t\tif ( v === buf[ i ] ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n});\n\n/**\n* Returns the first index at which a given element can be found.\n*\n* @name indexOf\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {float16} searchElement - element to find\n* @param {integer} [fromIndex=0] - starting index (inclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a floating-point number\n* @throws {TypeError} second argument must be an integer\n* @returns {integer} index or -1\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] );\n*\n* var idx = arr.indexOf( 2.0 );\n* // returns 2\n*\n* idx = arr.indexOf( 2.0, 3 );\n* // returns -1\n*\n* idx = arr.indexOf( 3.0, 3 );\n* // returns 3\n*/\nsetReadOnly( Float16Array.prototype, 'indexOf', function indexOf( searchElement, fromIndex ) {\n\tvar buf;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNumber( searchElement ) ) {\n\t\tthrow new TypeError( format( 'null49', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'null7f', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\tfromIndex = 0;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfromIndex = 0;\n\t}\n\tbuf = this._buffer;\n\tv = toWord( searchElement );\n\tfor ( i = fromIndex; i < this._length; i++ ) {\n\t\tif ( v === buf[ i ] ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Returns a new string by concatenating all array elements.\n*\n* @name join\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {string} [separator=','] - element separator\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a string\n* @returns {string} string representation\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var str = arr.join();\n* // returns '0,1,2'\n*\n* str = arr.join( '|' );\n* // returns '0|1|2'\n*/\nsetReadOnly( Float16Array.prototype, 'join', function join( separator ) {\n\tvar buf;\n\tvar out;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( arguments.length > 0 ) {\n\t\tif ( !isString( separator ) ) {\n\t\t\tthrow new TypeError( format( 'null3F', separator ) );\n\t\t}\n\t} else {\n\t\tseparator = ',';\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( fromWord( buf[ i ] ) );\n\t}\n\treturn out.join( separator );\n});\n\n/**\n* Returns an iterator for iterating over each index key in a typed array.\n*\n* @name keys\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new Float16Array( [ 1.0, 2.0 ] );\n*\n* var iter = arr.keys();\n*\n* var v = iter.next().value;\n* // returns 0\n*\n* v = iter.next().value;\n* // returns 1\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'keys', function keys() {\n\tvar self;\n\tvar iter;\n\tvar len;\n\tvar FLG;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tself = this;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': i,\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.keys();\n\t}\n});\n\n/**\n* Returns the last index at which a given element can be found.\n*\n* @name lastIndexOf\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {number} searchElement - element to find\n* @param {integer} [fromIndex] - starting index (inclusive)\n* @throws {TypeError} `this` must be a floating-point number\n* @throws {TypeError} first argument must be a numeric value\n* @throws {TypeError} second argument must be an integer\n* @returns {integer} index or -1\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 2.0 ] );\n*\n* var idx = arr.lastIndexOf( 2.0 );\n* // returns 4\n*\n* idx = arr.lastIndexOf( 2.0, 3 );\n* // returns 2\n*\n* idx = arr.lastIndexOf( 4.0, 3 );\n* // returns -1\n*\n* idx = arr.lastIndexOf( 1.0, -3 );\n* // returns 1\n*/\nsetReadOnly( Float16Array.prototype, 'lastIndexOf', function lastIndexOf( searchElement, fromIndex ) {\n\tvar buf;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNumber( searchElement ) ) {\n\t\tthrow new TypeError( format( 'null49', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'null7f', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex >= this._length ) {\n\t\t\tfromIndex = this._length - 1;\n\t\t} else if ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t}\n\t} else {\n\t\tfromIndex = this._length - 1;\n\t}\n\tbuf = this._buffer;\n\tv = toWord( searchElement );\n\tfor ( i = fromIndex; i >= 0; i-- ) {\n\t\tif ( v === buf[ i ] ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Number of array elements.\n*\n* @name length\n* @memberof Float16Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var len = arr.length;\n* // returns 10\n*/\nsetReadOnlyAccessor( Float16Array.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Returns a new array with each element being the result of a provided callback function.\n*\n* @name map\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} fcn - callback function\n* @param {*} [thisArg] - callback function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {Float16Array} new floating-point number array\n*\n* @example\n* function scale( v ) {\n* return v * 2.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var out = arr.map( scale );\n* // returns \n*\n* var z = out[ 0 ];\n* // returns 0.0\n*\n* z = out[ 1 ];\n* // returns 2.0\n*\n* z = out[ 2 ];\n* // returns 4.0\n*/\nsetReadOnly( Float16Array.prototype, 'map', function map( fcn, thisArg ) {\n\tvar outbuf;\n\tvar out;\n\tvar buf;\n\tvar i;\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( fcn ) ) {\n\t\tthrow new TypeError( format('null3c'), fcn );\n\t}\n\tbuf = this._buffer;\n\tout = new this.constructor( this._length );\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\toutbuf[ i ] = toWord( fcn.call( thisArg, fromWord( buf[ i ] ), i, this ) ); // eslint-disable-line max-len\n\t}\n\treturn out;\n});\n\n/**\n* Applies a provided callback function to each element of the array, in order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion.\n*\n* @name reduce\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} reducer - callback function\n* @param {*} [initialValue] - initial value\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {Error} if not provided an initial value, the array must have at least one element\n* @returns {*} accumulated result\n*\n* @example\n* function add( acc, v ) {\n* return acc + v;\n* }\n*\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] );\n*\n* var out = arr.reduce( add, 0 );\n* // returns 6.0\n*/\nsetReadOnly( Float16Array.prototype, 'reduce', function reduce( reducer, initialValue ) {\n\tvar buf;\n\tvar len;\n\tvar acc;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( reducer ) ) {\n\t\tthrow new TypeError( format( 'null3c', reducer ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tacc = initialValue;\n\t\ti = 0;\n\t} else {\n\t\tif ( len === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' );\n\t\t}\n\t\tacc = fromWord( buf[ 0 ] );\n\t\ti = 1;\n\t}\n\tfor ( ; i < len; i++ ) {\n\t\tacc = reducer( acc, fromWord( buf[ i ] ), i, this );\n\t}\n\treturn acc;\n});\n\n/**\n* Applies a provided callback function to each element of the array, in reverse order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion.\n*\n* @name reduceRight\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} reducer - callback function\n* @param {*} [initialValue] - initial value\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {Error} if not provided an initial value, the array must have at least one element\n* @returns {*} accumulated result\n*\n* @example\n* function add( acc, v ) {\n* return acc + v;\n* }\n*\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] );\n*\n* var out = arr.reduceRight( add, 0 );\n* // returns 6.0\n*/\nsetReadOnly( Float16Array.prototype, 'reduceRight', function reduceRight( reducer, initialValue ) {\n\tvar buf;\n\tvar len;\n\tvar acc;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( reducer ) ) {\n\t\tthrow new TypeError( format( 'null3c', reducer ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tacc = initialValue;\n\t\ti = len - 1;\n\t} else {\n\t\tif ( len === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' );\n\t\t}\n\t\tacc = fromWord( buf[ len-1 ] );\n\t\ti = len - 2;\n\t}\n\tfor ( ; i >= 0; i-- ) {\n\t\tacc = reducer( acc, fromWord( buf[ i ] ), i, this );\n\t}\n\treturn acc;\n});\n\n/**\n* Reverses an array in-place.\n*\n* @name reverse\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Float16Array} reversed array\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var out = arr.reverse();\n* // returns \n*\n* var v = out[ 0 ];\n* // returns 2.0\n*\n* v = out[ 1 ];\n* // returns 1.0\n*\n* v = out[ 2 ];\n* // returns 0.0\n*/\nsetReadOnly( Float16Array.prototype, 'reverse', function reverse() {\n\tvar buf;\n\tvar tmp;\n\tvar len;\n\tvar N;\n\tvar i;\n\tvar j;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tN = floor( len / 2 );\n\tfor ( i = 0; i < N; i++ ) {\n\t\tj = len - i - 1;\n\t\ttmp = buf[ i ];\n\t\tbuf[ i ] = buf[ j ];\n\t\tbuf[ j ] = tmp;\n\t}\n\treturn this;\n});\n\n/**\n* Sets one or more array elements.\n*\n* ## Notes\n*\n* - When provided a typed array, we must check whether the source array shares the same buffer as the target array and whether the underlying memory overlaps. In particular, we are concerned with the following scenario:\n*\n* ```text\n* buf: ---------------------\n* src: ---------------------\n* ```\n*\n* In the above, as we copy values from `src`, we will overwrite values in the `src` view, resulting in duplicated values copied into the end of `buf`, which is not intended. Hence, to avoid overwriting source values, we must **copy** source values to a temporary array.\n*\n* In the other overlapping scenario,\n*\n* ```text\n* buf: ---------------------\n* src: ---------------------\n* ```\n*\n* by the time we begin copying into the overlapping region, we are copying from the end of `src`, a non-overlapping region, which means we don't run the risk of copying copied values, rather than the original `src` values, as intended.\n*\n* @name set\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {(Collection|Float16Array)} value - value(s)\n* @param {NonNegativeInteger} [i=0] - element index at which to start writing values\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a collection\n* @throws {TypeError} index argument must be a nonnegative integer\n* @throws {RangeError} index argument is out-of-bounds\n* @throws {RangeError} target array lacks sufficient storage to accommodate source values\n* @returns {void}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var v = arr[ 0 ];\n* // returns 0.0\n*\n* arr.set( [ 1.0, 2.0 ], 0 );\n*\n* v = arr[ 0 ];\n* // returns 1.0\n*/\nsetReadOnly( Float16Array.prototype, 'set', function set( value ) {\n\tvar sbuf;\n\tvar idx;\n\tvar buf;\n\tvar tmp;\n\tvar flg;\n\tvar N;\n\tvar i;\n\tvar j;\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isCollection( value ) ) {\n\t\tthrow new TypeError( format( 'null2O', value ) );\n\t}\n\tbuf = this._buffer;\n\tif ( arguments.length > 1 ) {\n\t\tidx = arguments[ 1 ];\n\t\tif ( !isNonNegativeInteger( idx ) ) {\n\t\t\tthrow new TypeError( format( 'null2L', idx ) );\n\t\t}\n\t} else {\n\t\tidx = 0;\n\t}\n\tN = value.length;\n\tif ( idx+N > this._length ) {\n\t\tthrow new RangeError( format('null03') );\n\t}\n\tif ( isFloat16Array( value ) ) {\n\t\tsbuf = value._buffer; // eslint-disable-line no-underscore-dangle\n\t\tflg = true;\n\t} else {\n\t\tsbuf = value;\n\t\tflg = false;\n\t}\n\t// Check for overlapping memory...\n\tj = buf.byteOffset + (idx*BYTES_PER_ELEMENT);\n\tif (\n\t\tsbuf.buffer === buf.buffer &&\n\t\t(\n\t\t\tsbuf.byteOffset < j &&\n\t\t\tsbuf.byteOffset+sbuf.byteLength > j\n\t\t)\n\t) {\n\t\t// We need to copy source values...\n\t\ttmp = new Uint16Array( sbuf.length );\n\t\tfor ( i = 0; i < sbuf.length; i++ ) {\n\t\t\ttmp[ i ] = sbuf[ i ];\n\t\t}\n\t\tsbuf = tmp;\n\t}\n\tif ( flg ) {\n\t\tfor ( i = 0; i < N; idx++, i++ ) {\n\t\t\tbuf[ idx ] = sbuf[ i ];\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < N; idx++, i++ ) {\n\t\t\tbuf[ idx ] = toWord( sbuf[ i ] );\n\t\t}\n\t}\n});\n\n/**\n* Copies a portion of a typed array to a new typed array.\n*\n* @name slice\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} [begin] - start index (inclusive)\n* @param {integer} [end] - end index (exclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be integer\n* @throws {TypeError} second argument must be integer\n* @returns {Float16Array} floating-point number array\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] );\n*\n* var out = arr.slice();\n* // returns \n*\n* var len = out.length;\n* // returns 5\n*\n* var v = out[ 0 ];\n* // returns 0.0\n*\n* v = out[ len-1 ];\n* // returns 4.0\n*\n* out = arr.slice( 1, -2 );\n* // returns \n*\n* len = out.length;\n* // returns 2\n*\n* v = out[ 0 ];\n* // returns 1.0\n*\n* v = out[ len-1 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'slice', function slice( begin, end ) {\n\tvar outlen;\n\tvar outbuf;\n\tvar out;\n\tvar buf;\n\tvar len;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length === 0 ) {\n\t\tbegin = 0;\n\t\tend = len;\n\t} else {\n\t\tif ( !isInteger( begin ) ) {\n\t\t\tthrow new TypeError( format( 'null7e', begin ) );\n\t\t}\n\t\tif ( begin < 0 ) {\n\t\t\tbegin += len;\n\t\t\tif ( begin < 0 ) {\n\t\t\t\tbegin = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\tend = len;\n\t\t} else {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'null7f', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t} else if ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t}\n\t}\n\tif ( begin < end ) {\n\t\toutlen = end - begin;\n\t} else {\n\t\toutlen = 0;\n\t}\n\tout = new this.constructor( outlen );\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < outlen; i++ ) {\n\t\toutbuf[ i ] = buf[ i+begin ];\n\t}\n\treturn out;\n});\n\n/**\n* Tests whether at least one element in an array passes a test implemented by a predicate function.\n*\n* @name some\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {boolean} boolean indicating whether at least one element passes a test\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var bool = arr.some( predicate );\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'some', function some( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( predicate.call( thisArg, fromWord( buf[ i ] ), i, this ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n});\n\n/**\n* Sorts an array in-place.\n*\n* @name sort\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} [compareFcn] - comparison function\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {Float16Array} sorted array\n*\n* @example\n* function compare( a, b ) {\n* if ( a < b ) {\n* return -1;\n* }\n* if ( a > b ) {\n* return 1;\n* }\n* return 0;\n* }\n*\n* var arr = new Float16Array( [ 1.0, 0.0, 2.0 ] );\n*\n* arr.sort( compare );\n*\n* var v = arr[ 0 ];\n* // returns 0.0\n*\n* v = arr[ 1 ];\n* // returns 1.0\n*\n* v = arr[ 2 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'sort', function sort( compareFcn ) {\n\tvar buf;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tif ( arguments.length === 0 ) {\n\t\tbuf.sort( defaultCompare );\n\t\treturn this;\n\t}\n\tif ( !isFunction( compareFcn ) ) {\n\t\tthrow new TypeError( format( 'null3c', compareFcn ) );\n\t}\n\tbuf.sort( compare );\n\treturn this;\n\n\t/**\n\t* Default comparison function for float16 values.\n\t*\n\t* @private\n\t* @param {unsigned16} a - unsigned 16-bit integer for comparison\n\t* @param {unsigned16} b - unsigned 16-bit integer for comparison\n\t* @returns {number} comparison result\n\t*/\n\tfunction defaultCompare( a, b ) { // eslint-disable-line stdlib/no-unnecessary-nested-functions\n\t\tvar x = fromWord( a );\n\t\tvar y = fromWord( b );\n\n\t\t// Handle NaN...\n\t\tif ( isnan( x ) && isnan( y ) ) {\n\t\t\treturn 0;\n\t\t}\n\t\tif ( isnan( x ) ) {\n\t\t\treturn 1;\n\t\t}\n\t\tif ( isnan( y ) ) {\n\t\t\treturn -1;\n\t\t}\n\t\t// Normal comparison\n\t\tif ( x < y ) {\n\t\t\treturn -1;\n\t\t}\n\t\tif ( x > y ) {\n\t\t\treturn 1;\n\t\t}\n\t\treturn 0;\n\t}\n\n\t/**\n\t* Comparison function wrapper.\n\t*\n\t* @private\n\t* @param {unsigned16} a - unsigned 16-bit integer for comparison\n\t* @param {unsigned16} b - unsigned 16-bit integer for comparison\n\t* @returns {number} comparison result\n\t*/\n\tfunction compare( a, b ) {\n\t\treturn compareFcn( fromWord( a ), fromWord( b ) );\n\t}\n});\n\n/**\n* Creates a new typed array view over the same underlying `ArrayBuffer` and with the same underlying data type as the host array.\n*\n* @name subarray\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} [begin] - start index (inclusive)\n* @param {integer} [end] - end index (exclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be an integer\n* @throws {TypeError} second argument must be an integer\n* @returns {Float16Array} subarray\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] );\n*\n* var subarr = arr.subarray();\n* // returns \n*\n* var len = subarr.length;\n* // returns 5\n*\n* var bool = subarr[ 0 ];\n* // returns 0.0\n*\n* bool = subarr[ len-1 ];\n* // returns 4.0\n*\n* subarr = arr.subarray( 1, -2 );\n* // returns \n*\n* len = subarr.length;\n* // returns 2\n*\n* bool = subarr[ 0 ];\n* // returns 1.0\n*\n* bool = subarr[ len-1 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'subarray', function subarray( begin, end ) {\n\tvar offset;\n\tvar buf;\n\tvar len;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length === 0 ) {\n\t\tbegin = 0;\n\t\tend = len;\n\t} else {\n\t\tif ( !isInteger( begin ) ) {\n\t\t\tthrow new TypeError( format( 'null7e', begin ) );\n\t\t}\n\t\tif ( begin < 0 ) {\n\t\t\tbegin += len;\n\t\t\tif ( begin < 0 ) {\n\t\t\t\tbegin = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\tend = len;\n\t\t} else {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'null7f', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t} else if ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t}\n\t}\n\tif ( begin >= len ) {\n\t\tlen = 0;\n\t\toffset = buf.byteLength;\n\t} else if ( begin >= end ) {\n\t\tlen = 0;\n\t\toffset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT );\n\t} else {\n\t\tlen = end - begin;\n\t\toffset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT );\n\t}\n\treturn new this.constructor( buf.buffer, offset, ( len < 0 ) ? 0 : len );\n});\n\n/**\n* Serializes an array as a locale-specific string.\n*\n* @name toLocaleString\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {(string|Array)} [locales] - locale identifier(s)\n* @param {Object} [options] - configuration options\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a string or an array of strings\n* @throws {TypeError} options argument must be an object\n* @returns {string} string representation\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var str = arr.toLocaleString();\n* // returns '0,1,2'\n*/\nsetReadOnly( Float16Array.prototype, 'toLocaleString', function toLocaleString( locales, options ) {\n\tvar opts;\n\tvar loc;\n\tvar out;\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( arguments.length === 0 ) {\n\t\tloc = [];\n\t} else if ( isString( locales ) || isStringArray( locales ) ) {\n\t\tloc = locales;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a string or an array of strings. Value: `%s`.', locales ) );\n\t}\n\tif ( arguments.length < 2 ) {\n\t\topts = {};\n\t} else if ( isObject( options ) ) {\n\t\topts = options;\n\t} else {\n\t\tthrow new TypeError( format( 'null2V', options ) );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( fromWord( buf[ i ] ) );\n\t}\n\treturn out.toLocaleString( loc, opts );\n});\n\n/**\n* Returns a new typed array containing the elements in reversed order.\n*\n* @name toReversed\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Float16Array} reversed array\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var out = arr.toReversed();\n* // returns \n*\n* var v = out[ 0 ];\n* // returns 2.0\n*\n* v = out[ 1 ];\n* // returns 1.0\n*\n* v = out[ 2 ];\n* // returns 0.0\n*/\nsetReadOnly( Float16Array.prototype, 'toReversed', function toReversed() {\n\tvar outbuf;\n\tvar out;\n\tvar len;\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tlen = this._length;\n\tout = new this.constructor( len );\n\tbuf = this._buffer;\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < len; i++ ) {\n\t\toutbuf[ i ] = buf[ len - i - 1 ];\n\t}\n\treturn out;\n});\n\n/**\n* Returns a new typed array containing the elements in sorted order.\n*\n* @name toSorted\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} [compareFcn] - comparison function\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {Float16Array} sorted array\n*\n* @example\n* function compare( a, b ) {\n* if ( a > b ) {\n* return 1;\n* }\n* if ( a < b ) {\n* return -1;\n* }\n* return 0;\n* }\n*\n* var arr = new Float16Array( [ 2.0, 0.0, 1.0 ] );\n*\n* var out = arr.toSorted( compare );\n* // returns \n*\n* var v = out[ 0 ];\n* // returns 0.0\n*\n* v = out[ 1 ];\n* // returns 1.0\n*\n* v = out[ 2 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'toSorted', function toSorted( compareFcn ) {\n\tvar out;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tout = new this.constructor( this );\n\tif ( arguments.length === 0 ) {\n\t\treturn out.sort();\n\t}\n\treturn out.sort( compareFcn );\n});\n\n/**\n* Serializes an array as a string.\n*\n* @name toString\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {string} string representation\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var str = arr.toString();\n* // returns '0,1,2'\n*/\nsetReadOnly( Float16Array.prototype, 'toString', function toString() {\n\tvar out;\n\tvar buf;\n\tvar i;\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( fromWord( buf[ i ] ) );\n\t}\n\treturn out.join( ',' );\n});\n\n/**\n* Returns an iterator for iterating over each value in a typed array.\n*\n* @name values\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0 ] );\n*\n* var iter = arr.values();\n*\n* var v = iter.next().value;\n* // returns 0.0\n*\n* v = iter.next().value;\n* // returns 1.0\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'values', function values() {\n\tvar iter;\n\tvar self;\n\tvar len;\n\tvar FLG;\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tself = this;\n\tbuf = this._buffer;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': fromWord( buf[ i ] ),\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.values();\n\t}\n});\n\n/**\n* Returns a new typed array with the element at a provided index replaced with a provided value.\n*\n* @name with\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} index - element index\n* @param {number} value - new value\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be an integer\n* @throws {RangeError} index argument is out-of-bounds\n* @throws {TypeError} second argument must be a floating-point number\n* @returns {Float16Array} new typed array\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var out = arr.with( 0, 3.0 );\n* // returns \n*\n* var v = out[ 0 ];\n* // returns 3.0\n*/\nsetReadOnly( Float16Array.prototype, 'with', function copyWith( index, value ) {\n\tvar out;\n\tvar len;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isInteger( index ) ) {\n\t\tthrow new TypeError( format( 'null7e', index ) );\n\t}\n\tlen = this._length;\n\tif ( index < 0 ) {\n\t\tindex += len;\n\t}\n\tif ( index < 0 || index >= len ) {\n\t\tthrow new RangeError( format( 'nullFP', index ) );\n\t}\n\tif ( !isNumber( value ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a floating-point number. Value: `%s`.', value ) );\n\t}\n\tout = new this.constructor( this );\n\tout[ index ] = value;\n\treturn out;\n});\n\n\n// EXPORTS //\n\nexport default Float16Array;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport f16 from '@stdlib/number-float64-base-to-float16';\nimport toWord from '@stdlib/number-float16-base-to-word';\n\n\n// MAIN //\n\n/**\n* Fills an output array with unsigned 16-bit integers corresponding to the IEEE 754 binary representation of respective half-precision floating-point numbers.\n*\n* @private\n* @param {Uint16Array} buf - output array\n* @param {Array} arr - input array\n* @returns {Uint16Array} output array\n*/\nfunction fromArray( buf, arr ) {\n\tvar len;\n\tvar i;\n\n\tlen = arr.length;\n\tfor ( i = 0; i < len; i++ ) {\n\t\tbuf[ i ] = toWord( f16( arr[ i ] ) );\n\t}\n\treturn buf;\n}\n\n\n// EXPORTS //\n\nexport default fromArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport f16 from '@stdlib/number-float64-base-to-float16';\nimport toWord from '@stdlib/number-float16-base-to-word';\n\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @param {Function} clbk - callback to invoke for each iterated value\n* @param {*} thisArg - invocation context\n* @returns {Array} output array\n*/\nfunction fromIteratorMap( it, clbk, thisArg ) {\n\tvar out;\n\tvar v;\n\tvar i;\n\n\tout = [];\n\ti = -1;\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\ti += 1;\n\t\tout.push( toWord( f16( clbk.call( thisArg, v.value, i ) ) ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIteratorMap;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Float16Array === 'function' ) ? Float16Array : void 0; // eslint-disable-line no-undef, stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* 16-bit floating-point number array constructor.\n*\n* @module @stdlib/array-float16\n*\n* @example\n* import Float16Array from '@stdlib/array-float16';\n*\n* var arr = new Float16Array();\n* // returns \n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* import Float16Array from '@stdlib/array-float16';\n*\n* var arr = new Float16Array( 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import Float16Array from '@stdlib/array-float16';\n*\n* var arr = new Float16Array( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n* import Float16Array from '@stdlib/array-float16';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float16Array( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 8\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n* import Float16Array from '@stdlib/array-float16';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float16Array( buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 4\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n* import Float16Array from '@stdlib/array-float16';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Float16Array( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\n\n// MODULES //\n\nimport hasFloat16ArraySupport from '@stdlib/assert-has-float16array-support';\nimport polyfill from './polyfill';\nimport builtin from './main.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasFloat16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n"],"names":["fromIterator","it","out","v","next","done","push","toWord","f16","value","BYTES_PER_ELEMENT","Uint16Array","HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","isFloat16Array","constructor","name","isFloatingPointArrayConstructor","Float16Array","getter","ctx","idx","_get","setter","set","byteOffset","nargs","buf","len","arg","i","arguments","length","this","isNonNegativeInteger","isCollection","gcopy","ndarray","buffer","arr","fromArray","isArrayBuffer","isInteger","byteLength","RangeError","format","isObject","TypeError","isFunction","ITERATOR_SYMBOL","setReadOnly","setReadWriteAccessor","src","thisArg","clbk","tmp","_buffer","call","fromIteratorMap","Error","args","prototype","_length","fromWord","setReadOnlyAccessor","target","start","copyWithin","self","iter","FLG","entries","predicate","end","isNumber","fcn","searchElement","fromIndex","separator","isString","join","keys","outbuf","reducer","initialValue","acc","N","j","floor","sbuf","flg","begin","outlen","compareFcn","sort","a","b","x","y","isnan","offset","locales","options","opts","loc","isStringArray","toLocaleString","values","index","ctor","ctor$1","hasFloat16ArraySupport","builtin","polyfill"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 41ab3bb..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 21bc068b639ced8a5f58a13429de58227942f08d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 13 May 2026 08:25:19 +0000 Subject: [PATCH 05/14] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 204 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 52 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 49 +- SECURITY.md | 5 - benchmark/benchmark.at.js | 79 - benchmark/benchmark.copy_within.js | 52 - benchmark/benchmark.copy_within.length.js | 95 - benchmark/benchmark.entries.js | 52 - benchmark/benchmark.every.js | 83 - benchmark/benchmark.every.length.js | 107 - benchmark/benchmark.fill.js | 53 - benchmark/benchmark.fill.length.js | 97 - benchmark/benchmark.filter.js | 82 - benchmark/benchmark.filter.length.js | 106 - benchmark/benchmark.find.js | 84 - benchmark/benchmark.find.length.js | 106 - benchmark/benchmark.find_index.js | 84 - benchmark/benchmark.find_index.length.js | 106 - benchmark/benchmark.find_last.js | 84 - benchmark/benchmark.find_last.length.js | 106 - benchmark/benchmark.find_last_index.js | 84 - benchmark/benchmark.find_last_index.length.js | 110 - benchmark/benchmark.for_each.js | 90 - benchmark/benchmark.for_each.length.js | 108 - benchmark/benchmark.from.js | 238 - benchmark/benchmark.get.js | 55 - benchmark/benchmark.includes.js | 54 - benchmark/benchmark.includes.length.js | 97 - benchmark/benchmark.index_of.js | 54 - benchmark/benchmark.index_of.length.js | 96 - benchmark/benchmark.join.js | 53 - benchmark/benchmark.join.length.js | 96 - benchmark/benchmark.js | 338 -- benchmark/benchmark.keys.js | 52 - benchmark/benchmark.keys.length.js | 96 - benchmark/benchmark.last_index_of.js | 53 - benchmark/benchmark.last_index_of.length.js | 95 - benchmark/benchmark.length.js | 93 - benchmark/benchmark.map.js | 82 - benchmark/benchmark.map.length.js | 106 - benchmark/benchmark.of.js | 48 - benchmark/benchmark.reduce.js | 82 - benchmark/benchmark.reduce.length.js | 107 - benchmark/benchmark.reduce_right.js | 82 - benchmark/benchmark.reduce_right.length.js | 107 - benchmark/benchmark.reverse.js | 53 - benchmark/benchmark.reverse.length.js | 96 - benchmark/benchmark.set.js | 95 - benchmark/benchmark.set.length.js | 110 - benchmark/benchmark.slice.js | 53 - benchmark/benchmark.slice.length.js | 96 - benchmark/benchmark.some.js | 83 - benchmark/benchmark.some.length.js | 107 - benchmark/benchmark.sort.js | 53 - benchmark/benchmark.sort.length.js | 96 - benchmark/benchmark.subarray.js | 52 - benchmark/benchmark.subarray.length.js | 95 - benchmark/benchmark.to_locale_string.js | 53 - .../benchmark.to_locale_string.length.js | 96 - benchmark/benchmark.to_reversed.js | 52 - benchmark/benchmark.to_reversed.length.js | 95 - benchmark/benchmark.to_sorted.js | 53 - benchmark/benchmark.to_sorted.length.js | 96 - benchmark/benchmark.to_string.js | 53 - benchmark/benchmark.to_string.length.js | 96 - benchmark/benchmark.values.js | 52 - benchmark/benchmark.values.length.js | 96 - benchmark/benchmark.with.js | 54 - benchmark/benchmark.with.length.js | 98 - benchmark/polyfill/benchmark.at.js | 79 - benchmark/polyfill/benchmark.copy_within.js | 52 - .../polyfill/benchmark.copy_within.length.js | 95 - benchmark/polyfill/benchmark.entries.js | 52 - benchmark/polyfill/benchmark.every.js | 83 - benchmark/polyfill/benchmark.every.length.js | 107 - benchmark/polyfill/benchmark.fill.js | 53 - benchmark/polyfill/benchmark.fill.length.js | 97 - benchmark/polyfill/benchmark.filter.js | 82 - benchmark/polyfill/benchmark.filter.length.js | 106 - benchmark/polyfill/benchmark.find.js | 84 - benchmark/polyfill/benchmark.find.length.js | 106 - benchmark/polyfill/benchmark.find_index.js | 84 - .../polyfill/benchmark.find_index.length.js | 106 - benchmark/polyfill/benchmark.find_last.js | 84 - .../polyfill/benchmark.find_last.length.js | 106 - .../polyfill/benchmark.find_last_index.js | 84 - .../benchmark.find_last_index.length.js | 110 - benchmark/polyfill/benchmark.for_each.js | 90 - .../polyfill/benchmark.for_each.length.js | 108 - benchmark/polyfill/benchmark.from.js | 238 - benchmark/polyfill/benchmark.get.js | 55 - benchmark/polyfill/benchmark.includes.js | 54 - .../polyfill/benchmark.includes.length.js | 97 - benchmark/polyfill/benchmark.index_of.js | 54 - .../polyfill/benchmark.index_of.length.js | 96 - benchmark/polyfill/benchmark.join.js | 53 - benchmark/polyfill/benchmark.join.length.js | 96 - benchmark/polyfill/benchmark.js | 338 -- benchmark/polyfill/benchmark.keys.js | 52 - benchmark/polyfill/benchmark.keys.length.js | 96 - benchmark/polyfill/benchmark.last_index_of.js | 53 - .../benchmark.last_index_of.length.js | 95 - benchmark/polyfill/benchmark.length.js | 93 - benchmark/polyfill/benchmark.map.js | 82 - benchmark/polyfill/benchmark.map.length.js | 106 - benchmark/polyfill/benchmark.of.js | 48 - benchmark/polyfill/benchmark.reduce.js | 82 - benchmark/polyfill/benchmark.reduce.length.js | 107 - benchmark/polyfill/benchmark.reduce_right.js | 82 - .../polyfill/benchmark.reduce_right.length.js | 107 - benchmark/polyfill/benchmark.reverse.js | 53 - .../polyfill/benchmark.reverse.length.js | 96 - benchmark/polyfill/benchmark.set.js | 95 - benchmark/polyfill/benchmark.set.length.js | 110 - benchmark/polyfill/benchmark.slice.js | 53 - benchmark/polyfill/benchmark.slice.length.js | 96 - benchmark/polyfill/benchmark.some.js | 83 - benchmark/polyfill/benchmark.some.length.js | 107 - benchmark/polyfill/benchmark.sort.js | 53 - benchmark/polyfill/benchmark.sort.length.js | 96 - benchmark/polyfill/benchmark.subarray.js | 52 - .../polyfill/benchmark.subarray.length.js | 95 - .../polyfill/benchmark.to_locale_string.js | 53 - .../benchmark.to_locale_string.length.js | 96 - benchmark/polyfill/benchmark.to_reversed.js | 52 - .../polyfill/benchmark.to_reversed.length.js | 95 - benchmark/polyfill/benchmark.to_sorted.js | 53 - .../polyfill/benchmark.to_sorted.length.js | 96 - benchmark/polyfill/benchmark.to_string.js | 53 - .../polyfill/benchmark.to_string.length.js | 96 - benchmark/polyfill/benchmark.values.js | 52 - benchmark/polyfill/benchmark.values.length.js | 96 - benchmark/polyfill/benchmark.with.js | 54 - benchmark/polyfill/benchmark.with.length.js | 98 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 1222 ----- docs/types/test.ts | 129 - examples/index.js | 42 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 106 - lib/main.js | 28 - lib/polyfill/from_array.js | 51 - lib/polyfill/from_iterator.js | 54 - lib/polyfill/from_iterator_map.js | 59 - lib/polyfill/index.js | 2410 -------- package.json | 86 +- stats.html | 4842 +++++++++++++++++ test/dist/test.js | 33 - test/polyfill/test.at.js | 144 - test/polyfill/test.copy_within.js | 281 - test/polyfill/test.entries.js | 238 - test/polyfill/test.every.js | 174 - test/polyfill/test.fill.js | 305 -- test/polyfill/test.filter.js | 226 - test/polyfill/test.find.js | 174 - test/polyfill/test.find_index.js | 173 - test/polyfill/test.find_last.js | 174 - test/polyfill/test.find_last_index.js | 173 - test/polyfill/test.for_each.js | 196 - test/polyfill/test.from.js | 654 --- test/polyfill/test.includes.js | 222 - test/polyfill/test.index_of.js | 222 - test/polyfill/test.join.js | 173 - test/polyfill/test.js | 740 --- test/polyfill/test.keys.js | 261 - test/polyfill/test.last_index_of.js | 211 - test/polyfill/test.map.js | 178 - test/polyfill/test.of.js | 130 - test/polyfill/test.reduce.js | 189 - test/polyfill/test.reduce_right.js | 192 - test/polyfill/test.reverse.js | 122 - test/polyfill/test.set.js | 259 - test/polyfill/test.slice.js | 311 -- test/polyfill/test.some.js | 196 - test/polyfill/test.sort.js | 189 - test/polyfill/test.subarray.js | 308 -- test/polyfill/test.to_locale_string.js | 187 - test/polyfill/test.to_reversed.js | 121 - test/polyfill/test.to_sorted.js | 172 - test/polyfill/test.to_string.js | 97 - test/polyfill/test.values.js | 264 - test/polyfill/test.with.js | 213 - test/test.at.js | 111 - test/test.copy_within.js | 279 - test/test.entries.js | 96 - test/test.every.js | 172 - test/test.fill.js | 212 - test/test.filter.js | 224 - test/test.find.js | 172 - test/test.find_index.js | 171 - test/test.find_last.js | 172 - test/test.find_last_index.js | 171 - test/test.for_each.js | 194 - test/test.from.js | 309 -- test/test.includes.js | 160 - test/test.index_of.js | 160 - test/test.join.js | 141 - test/test.js | 320 -- test/test.keys.js | 144 - test/test.last_index_of.js | 149 - test/test.map.js | 176 - test/test.of.js | 128 - test/test.polyfill.js | 80 - test/test.reduce.js | 187 - test/test.reduce_right.js | 190 - test/test.reverse.js | 120 - test/test.set.js | 225 - test/test.slice.js | 249 - test/test.some.js | 194 - test/test.sort.js | 186 - test/test.subarray.js | 246 - test/test.to_locale_string.js | 95 - test/test.to_reversed.js | 119 - test/test.to_sorted.js | 169 - test/test.to_string.js | 87 - test/test.values.js | 147 - test/test.with.js | 151 - 244 files changed, 4870 insertions(+), 33232 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.at.js delete mode 100644 benchmark/benchmark.copy_within.js delete mode 100644 benchmark/benchmark.copy_within.length.js delete mode 100644 benchmark/benchmark.entries.js delete mode 100644 benchmark/benchmark.every.js delete mode 100644 benchmark/benchmark.every.length.js delete mode 100644 benchmark/benchmark.fill.js delete mode 100644 benchmark/benchmark.fill.length.js delete mode 100644 benchmark/benchmark.filter.js delete mode 100644 benchmark/benchmark.filter.length.js delete mode 100644 benchmark/benchmark.find.js delete mode 100644 benchmark/benchmark.find.length.js delete mode 100644 benchmark/benchmark.find_index.js delete mode 100644 benchmark/benchmark.find_index.length.js delete mode 100644 benchmark/benchmark.find_last.js delete mode 100644 benchmark/benchmark.find_last.length.js delete mode 100644 benchmark/benchmark.find_last_index.js delete mode 100644 benchmark/benchmark.find_last_index.length.js delete mode 100644 benchmark/benchmark.for_each.js delete mode 100644 benchmark/benchmark.for_each.length.js delete mode 100644 benchmark/benchmark.from.js delete mode 100644 benchmark/benchmark.get.js delete mode 100644 benchmark/benchmark.includes.js delete mode 100644 benchmark/benchmark.includes.length.js delete mode 100644 benchmark/benchmark.index_of.js delete mode 100644 benchmark/benchmark.index_of.length.js delete mode 100644 benchmark/benchmark.join.js delete mode 100644 benchmark/benchmark.join.length.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.keys.js delete mode 100644 benchmark/benchmark.keys.length.js delete mode 100644 benchmark/benchmark.last_index_of.js delete mode 100644 benchmark/benchmark.last_index_of.length.js delete mode 100644 benchmark/benchmark.length.js delete mode 100644 benchmark/benchmark.map.js delete mode 100644 benchmark/benchmark.map.length.js delete mode 100644 benchmark/benchmark.of.js delete mode 100644 benchmark/benchmark.reduce.js delete mode 100644 benchmark/benchmark.reduce.length.js delete mode 100644 benchmark/benchmark.reduce_right.js delete mode 100644 benchmark/benchmark.reduce_right.length.js delete mode 100644 benchmark/benchmark.reverse.js delete mode 100644 benchmark/benchmark.reverse.length.js delete mode 100644 benchmark/benchmark.set.js delete mode 100644 benchmark/benchmark.set.length.js delete mode 100644 benchmark/benchmark.slice.js delete mode 100644 benchmark/benchmark.slice.length.js delete mode 100644 benchmark/benchmark.some.js delete mode 100644 benchmark/benchmark.some.length.js delete mode 100644 benchmark/benchmark.sort.js delete mode 100644 benchmark/benchmark.sort.length.js delete mode 100644 benchmark/benchmark.subarray.js delete mode 100644 benchmark/benchmark.subarray.length.js delete mode 100644 benchmark/benchmark.to_locale_string.js delete mode 100644 benchmark/benchmark.to_locale_string.length.js delete mode 100644 benchmark/benchmark.to_reversed.js delete mode 100644 benchmark/benchmark.to_reversed.length.js delete mode 100644 benchmark/benchmark.to_sorted.js delete mode 100644 benchmark/benchmark.to_sorted.length.js delete mode 100644 benchmark/benchmark.to_string.js delete mode 100644 benchmark/benchmark.to_string.length.js delete mode 100644 benchmark/benchmark.values.js delete mode 100644 benchmark/benchmark.values.length.js delete mode 100644 benchmark/benchmark.with.js delete mode 100644 benchmark/benchmark.with.length.js delete mode 100644 benchmark/polyfill/benchmark.at.js delete mode 100644 benchmark/polyfill/benchmark.copy_within.js delete mode 100644 benchmark/polyfill/benchmark.copy_within.length.js delete mode 100644 benchmark/polyfill/benchmark.entries.js delete mode 100644 benchmark/polyfill/benchmark.every.js delete mode 100644 benchmark/polyfill/benchmark.every.length.js delete mode 100644 benchmark/polyfill/benchmark.fill.js delete mode 100644 benchmark/polyfill/benchmark.fill.length.js delete mode 100644 benchmark/polyfill/benchmark.filter.js delete mode 100644 benchmark/polyfill/benchmark.filter.length.js delete mode 100644 benchmark/polyfill/benchmark.find.js delete mode 100644 benchmark/polyfill/benchmark.find.length.js delete mode 100644 benchmark/polyfill/benchmark.find_index.js delete mode 100644 benchmark/polyfill/benchmark.find_index.length.js delete mode 100644 benchmark/polyfill/benchmark.find_last.js delete mode 100644 benchmark/polyfill/benchmark.find_last.length.js delete mode 100644 benchmark/polyfill/benchmark.find_last_index.js delete mode 100644 benchmark/polyfill/benchmark.find_last_index.length.js delete mode 100644 benchmark/polyfill/benchmark.for_each.js delete mode 100644 benchmark/polyfill/benchmark.for_each.length.js delete mode 100644 benchmark/polyfill/benchmark.from.js delete mode 100644 benchmark/polyfill/benchmark.get.js delete mode 100644 benchmark/polyfill/benchmark.includes.js delete mode 100644 benchmark/polyfill/benchmark.includes.length.js delete mode 100644 benchmark/polyfill/benchmark.index_of.js delete mode 100644 benchmark/polyfill/benchmark.index_of.length.js delete mode 100644 benchmark/polyfill/benchmark.join.js delete mode 100644 benchmark/polyfill/benchmark.join.length.js delete mode 100644 benchmark/polyfill/benchmark.js delete mode 100644 benchmark/polyfill/benchmark.keys.js delete mode 100644 benchmark/polyfill/benchmark.keys.length.js delete mode 100644 benchmark/polyfill/benchmark.last_index_of.js delete mode 100644 benchmark/polyfill/benchmark.last_index_of.length.js delete mode 100644 benchmark/polyfill/benchmark.length.js delete mode 100644 benchmark/polyfill/benchmark.map.js delete mode 100644 benchmark/polyfill/benchmark.map.length.js delete mode 100644 benchmark/polyfill/benchmark.of.js delete mode 100644 benchmark/polyfill/benchmark.reduce.js delete mode 100644 benchmark/polyfill/benchmark.reduce.length.js delete mode 100644 benchmark/polyfill/benchmark.reduce_right.js delete mode 100644 benchmark/polyfill/benchmark.reduce_right.length.js delete mode 100644 benchmark/polyfill/benchmark.reverse.js delete mode 100644 benchmark/polyfill/benchmark.reverse.length.js delete mode 100644 benchmark/polyfill/benchmark.set.js delete mode 100644 benchmark/polyfill/benchmark.set.length.js delete mode 100644 benchmark/polyfill/benchmark.slice.js delete mode 100644 benchmark/polyfill/benchmark.slice.length.js delete mode 100644 benchmark/polyfill/benchmark.some.js delete mode 100644 benchmark/polyfill/benchmark.some.length.js delete mode 100644 benchmark/polyfill/benchmark.sort.js delete mode 100644 benchmark/polyfill/benchmark.sort.length.js delete mode 100644 benchmark/polyfill/benchmark.subarray.js delete mode 100644 benchmark/polyfill/benchmark.subarray.length.js delete mode 100644 benchmark/polyfill/benchmark.to_locale_string.js delete mode 100644 benchmark/polyfill/benchmark.to_locale_string.length.js delete mode 100644 benchmark/polyfill/benchmark.to_reversed.js delete mode 100644 benchmark/polyfill/benchmark.to_reversed.length.js delete mode 100644 benchmark/polyfill/benchmark.to_sorted.js delete mode 100644 benchmark/polyfill/benchmark.to_sorted.length.js delete mode 100644 benchmark/polyfill/benchmark.to_string.js delete mode 100644 benchmark/polyfill/benchmark.to_string.length.js delete mode 100644 benchmark/polyfill/benchmark.values.js delete mode 100644 benchmark/polyfill/benchmark.values.length.js delete mode 100644 benchmark/polyfill/benchmark.with.js delete mode 100644 benchmark/polyfill/benchmark.with.length.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill/from_array.js delete mode 100644 lib/polyfill/from_iterator.js delete mode 100644 lib/polyfill/from_iterator_map.js delete mode 100644 lib/polyfill/index.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/polyfill/test.at.js delete mode 100644 test/polyfill/test.copy_within.js delete mode 100644 test/polyfill/test.entries.js delete mode 100644 test/polyfill/test.every.js delete mode 100644 test/polyfill/test.fill.js delete mode 100644 test/polyfill/test.filter.js delete mode 100644 test/polyfill/test.find.js delete mode 100644 test/polyfill/test.find_index.js delete mode 100644 test/polyfill/test.find_last.js delete mode 100644 test/polyfill/test.find_last_index.js delete mode 100644 test/polyfill/test.for_each.js delete mode 100644 test/polyfill/test.from.js delete mode 100644 test/polyfill/test.includes.js delete mode 100644 test/polyfill/test.index_of.js delete mode 100644 test/polyfill/test.join.js delete mode 100644 test/polyfill/test.js delete mode 100644 test/polyfill/test.keys.js delete mode 100644 test/polyfill/test.last_index_of.js delete mode 100644 test/polyfill/test.map.js delete mode 100644 test/polyfill/test.of.js delete mode 100644 test/polyfill/test.reduce.js delete mode 100644 test/polyfill/test.reduce_right.js delete mode 100644 test/polyfill/test.reverse.js delete mode 100644 test/polyfill/test.set.js delete mode 100644 test/polyfill/test.slice.js delete mode 100644 test/polyfill/test.some.js delete mode 100644 test/polyfill/test.sort.js delete mode 100644 test/polyfill/test.subarray.js delete mode 100644 test/polyfill/test.to_locale_string.js delete mode 100644 test/polyfill/test.to_reversed.js delete mode 100644 test/polyfill/test.to_sorted.js delete mode 100644 test/polyfill/test.to_string.js delete mode 100644 test/polyfill/test.values.js delete mode 100644 test/polyfill/test.with.js delete mode 100644 test/test.at.js delete mode 100644 test/test.copy_within.js delete mode 100644 test/test.entries.js delete mode 100644 test/test.every.js delete mode 100644 test/test.fill.js delete mode 100644 test/test.filter.js delete mode 100644 test/test.find.js delete mode 100644 test/test.find_index.js delete mode 100644 test/test.find_last.js delete mode 100644 test/test.find_last_index.js delete mode 100644 test/test.for_each.js delete mode 100644 test/test.from.js delete mode 100644 test/test.includes.js delete mode 100644 test/test.index_of.js delete mode 100644 test/test.join.js delete mode 100644 test/test.js delete mode 100644 test/test.keys.js delete mode 100644 test/test.last_index_of.js delete mode 100644 test/test.map.js delete mode 100644 test/test.of.js delete mode 100644 test/test.polyfill.js delete mode 100644 test/test.reduce.js delete mode 100644 test/test.reduce_right.js delete mode 100644 test/test.reverse.js delete mode 100644 test/test.set.js delete mode 100644 test/test.slice.js delete mode 100644 test/test.some.js delete mode 100644 test/test.sort.js delete mode 100644 test/test.subarray.js delete mode 100644 test/test.to_locale_string.js delete mode 100644 test/test.to_reversed.js delete mode 100644 test/test.to_sorted.js delete mode 100644 test/test.to_string.js delete mode 100644 test/test.values.js delete mode 100644 test/test.with.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index f756a5e..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/float16) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 44e2d76..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/float16) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 4584730..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '9 21 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -1587,7 +1578,7 @@ logEach( '%s', out ); ## Notice -This package is part of [stdlib][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. +This package is part of [stdlib][stdlib], a standard library 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][stdlib], see the main project [repository][stdlib]. @@ -1652,9 +1643,9 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. [mdn-iterator-protocol]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterator_protocol -[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed +[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed/tree/esm -[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer +[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.at.js b/benchmark/benchmark.at.js deleted file mode 100644 index 7068020..0000000 --- a/benchmark/benchmark.at.js +++ /dev/null @@ -1,79 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s::nonnegative_indices:at', pkg ), function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float16Array( uniform( 10, 0.0, 10.0 ) ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.at( i%N ); - if ( typeof v !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNumber( v ) ) { - b.fail( 'should return a number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::negative_indices:at', pkg ), function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float16Array( uniform( 10, 1.0, 10.0 ) ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.at( -(i%N)-1 ); - if ( typeof v !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNumber( v ) ) { - b.fail( 'should return a number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.copy_within.js b/benchmark/benchmark.copy_within.js deleted file mode 100644 index 2182e0d..0000000 --- a/benchmark/benchmark.copy_within.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:copyWithin', pkg ), function benchmark( b ) { - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.copy_within.length.js b/benchmark/benchmark.copy_within.length.js deleted file mode 100644 index 9c952bb..0000000 --- a/benchmark/benchmark.copy_within.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - 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( format( '%s:copyWithin:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.entries.js b/benchmark/benchmark.entries.js deleted file mode 100644 index ddef73f..0000000 --- a/benchmark/benchmark.entries.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:entries', pkg ), function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.every.js b/benchmark/benchmark.every.js deleted file mode 100644 index ec830e9..0000000 --- a/benchmark/benchmark.every.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:every', pkg ), function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0.0; - } -}); - -bench( format( '%s::this_context:every', pkg ), function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0.0; - } -}); diff --git a/benchmark/benchmark.every.length.js b/benchmark/benchmark.every.length.js deleted file mode 100644 index a0f3d94..0000000 --- a/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,107 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - 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( format( '%s:every:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.fill.js b/benchmark/benchmark.fill.js deleted file mode 100644 index 7b27d39..0000000 --- a/benchmark/benchmark.fill.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:fill', pkg ), function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = [ 1.0, 2.0, 3.0 ]; - arr = new Float16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.fill( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.fill.length.js b/benchmark/benchmark.fill.length.js deleted file mode 100644 index 612d1b9..0000000 --- a/benchmark/benchmark.fill.length.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var values; - var out; - var i; - - values = [ 1.0, 2.0, 3.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.fill( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s:fill:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.filter.js b/benchmark/benchmark.filter.js deleted file mode 100644 index 555ad11..0000000 --- a/benchmark/benchmark.filter.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:filter', pkg ), function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0.0; - } -}); - -bench( format( '%s::this_context:filter', pkg ), function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0.0; - } -}); diff --git a/benchmark/benchmark.filter.length.js b/benchmark/benchmark.filter.length.js deleted file mode 100644 index 89f5124..0000000 --- a/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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 = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:filter:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.find.js b/benchmark/benchmark.find.js deleted file mode 100644 index b15c9fa..0000000 --- a/benchmark/benchmark.find.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:find', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); - -bench( format( '%s::this_context:find', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); diff --git a/benchmark/benchmark.find.length.js b/benchmark/benchmark.find.length.js deleted file mode 100644 index 58997d9..0000000 --- a/benchmark/benchmark.find.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value < 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - 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( format( '%s:find:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.find_index.js b/benchmark/benchmark.find_index.js deleted file mode 100644 index 4491bb3..0000000 --- a/benchmark/benchmark.find_index.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:findIndex', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); - -bench( format( '%s::this_context:findIndex', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); diff --git a/benchmark/benchmark.find_index.length.js b/benchmark/benchmark.find_index.length.js deleted file mode 100644 index 4bed308..0000000 --- a/benchmark/benchmark.find_index.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value < 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - 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( format( '%s:findIndex:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.find_last.js b/benchmark/benchmark.find_last.js deleted file mode 100644 index e134fbb..0000000 --- a/benchmark/benchmark.find_last.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:findLast', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findLast( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); - -bench( format( '%s::this_context:findLast', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findLast( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); diff --git a/benchmark/benchmark.find_last.length.js b/benchmark/benchmark.find_last.length.js deleted file mode 100644 index 50aad42..0000000 --- a/benchmark/benchmark.find_last.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value < 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.findLast( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - 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( format( '%s:findLast:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.find_last_index.js b/benchmark/benchmark.find_last_index.js deleted file mode 100644 index 85217bd..0000000 --- a/benchmark/benchmark.find_last_index.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:findLastIndex', pkg ), function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findLastIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -bench( format( '%s::this_context:findLastIndex', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findLastIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); diff --git a/benchmark/benchmark.find_last_index.length.js b/benchmark/benchmark.find_last_index.length.js deleted file mode 100644 index 69468cd..0000000 --- a/benchmark/benchmark.find_last_index.length.js +++ /dev/null @@ -1,110 +0,0 @@ -/** - * @license Apache-2.0 -* -* Copyright (c) 2026 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. -*/ - -/* eslint-disable stdlib/jsdoc-typedef-typos */ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {boolean} value - array element -* @param {NonNegativeInteger} idx - array element index -* @param {Float16Array} arr - array instance -* @returns {boolean} boolean indicating whether a value passes a test -*/ -function predicate( value ) { - return value < 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.findLastIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - 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( format( '%s:findLastIndex:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.for_each.js b/benchmark/benchmark.for_each.js deleted file mode 100644 index af73bce..0000000 --- a/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:forEach', pkg ), function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( format( '%s::this_context:forEach', pkg ), function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/benchmark/benchmark.for_each.length.js b/benchmark/benchmark.for_each.length.js deleted file mode 100644 index 935da80..0000000 --- a/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// 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( format( '%s:forEach:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.from.js b/benchmark/benchmark.from.js deleted file mode 100644 index 2242134..0000000 --- a/benchmark/benchmark.from.js +++ /dev/null @@ -1,238 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( format( '%s::typed_array:from', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::typed_array,clbk:from', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1.0; - } -}); - -bench( format( '%s::array:from', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1.0, 2.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::array,clbk:from', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1.0, 2.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1.0; - } -}); - -bench( format( '%s::iterable:from', pkg ), opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0.0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( format( '%s::iterable,clbk:from:', pkg ), opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1.0, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1.0; - } -}); diff --git a/benchmark/benchmark.get.js b/benchmark/benchmark.get.js deleted file mode 100644 index 90788e1..0000000 --- a/benchmark/benchmark.get.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:get', pkg ), function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float16Array( uniform( 10, 0.0, 10.0 ) ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( typeof v !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNumber( v ) ) { - b.fail( 'should return a number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.includes.js b/benchmark/benchmark.includes.js deleted file mode 100644 index c24dcc3..0000000 --- a/benchmark/benchmark.includes.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:includes', pkg ), function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Float16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1.0; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.includes.length.js b/benchmark/benchmark.includes.length.js deleted file mode 100644 index db686a1..0000000 --- a/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1.0; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - 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( format( '%s:includes:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.index_of.js b/benchmark/benchmark.index_of.js deleted file mode 100644 index 222370c..0000000 --- a/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:indexOf', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.indexOf( 11.0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( out ) ) { - b.fail( 'should return an integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.index_of.length.js b/benchmark/benchmark.index_of.length.js deleted file mode 100644 index ca2c5ee..0000000 --- a/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.indexOf( 11.0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( out ) ) { - b.fail( 'should return an integer' ); - } - 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( format( '%s:indexOf:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.join.js b/benchmark/benchmark.join.js deleted file mode 100644 index ce25730..0000000 --- a/benchmark/benchmark.join.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:join', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.join.length.js b/benchmark/benchmark.join.length.js deleted file mode 100644 index 26092d0..0000000 --- a/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - 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( format( '%s:join:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 1d756ec..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,338 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( format( '%s::instantiation,new', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array(); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::instantiation,no_new', pkg ), function benchmark( b ) { - var ctor; - var arr; - var i; - - ctor = Float16Array; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = ctor(); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::instantiation,length', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::instantiation,typed_array', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::instantiation,array', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = []; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::instantiation,iterable', pkg ), opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( createIterable() ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - return { - 'done': true - }; - } - } -}); - -bench( format( '%s::instantiation,arraybuffer', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::instantiation,arraybuffer,byte_offset', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 8 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( buf, 8 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::instantiation,arraybuffer,byte_offset,length', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 8 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( buf, 8, 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::get:buffer', pkg ), function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float16Array(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::get:byteLength', pkg ), function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float16Array(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::get:byteOffset', pkg ), function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float16Array(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::get:length', pkg ), function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float16Array(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.keys.js b/benchmark/benchmark.keys.js deleted file mode 100644 index 9bd4d5f..0000000 --- a/benchmark/benchmark.keys.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:keys', pkg ), function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.keys.length.js b/benchmark/benchmark.keys.length.js deleted file mode 100644 index a9b25c9..0000000 --- a/benchmark/benchmark.keys.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var iter; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isIteratorLike( iter ) ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - 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( format( '%s:keys:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.last_index_of.js b/benchmark/benchmark.last_index_of.js deleted file mode 100644 index 96d9d71..0000000 --- a/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:lastIndexOf', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.lastIndexOf( 11.0 ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.length.js b/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index 230c543..0000000 --- a/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.lastIndexOf( 11.0 ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - 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( format( '%s:lastIndexOf:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index c67eb26..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.map.js b/benchmark/benchmark.map.js deleted file mode 100644 index 7968e8c..0000000 --- a/benchmark/benchmark.map.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:map', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1.0; - } -}); - -bench( format( '%s::this_context:map', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1.0; - } -}); diff --git a/benchmark/benchmark.map.length.js b/benchmark/benchmark.map.length.js deleted file mode 100644 index 3948193..0000000 --- a/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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 = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:map:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.of.js b/benchmark/benchmark.of.js deleted file mode 100644 index 3b8ae26..0000000 --- a/benchmark/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:of', pkg ), function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.of( i, 2.0 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reduce.js b/benchmark/benchmark.reduce.js deleted file mode 100644 index 39ce31c..0000000 --- a/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:reduce', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1.0; - } -}); - -bench( format( '%s::initial_value:reduce', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3.14 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1.0; - } -}); diff --git a/benchmark/benchmark.reduce.length.js b/benchmark/benchmark.reduce.length.js deleted file mode 100644 index 763b4c2..0000000 --- a/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,107 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - 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( format( '%s:reduce:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.reduce_right.js b/benchmark/benchmark.reduce_right.js deleted file mode 100644 index 8a71b79..0000000 --- a/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:reduceRight', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1.0; - } -}); - -bench( format( '%s::initial_value:reduceRight', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3.14 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1.0; - } -}); diff --git a/benchmark/benchmark.reduce_right.length.js b/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index 2001fe5..0000000 --- a/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,107 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - 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( format( '%s:reduceRight:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.reverse.js b/benchmark/benchmark.reverse.js deleted file mode 100644 index a2a239c..0000000 --- a/benchmark/benchmark.reverse.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:reverse', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reverse.length.js b/benchmark/benchmark.reverse.length.js deleted file mode 100644 index 3b526c7..0000000 --- a/benchmark/benchmark.reverse.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s:reverse:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.set.js b/benchmark/benchmark.set.js deleted file mode 100644 index 7648c39..0000000 --- a/benchmark/benchmark.set.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s::array:set', pkg ), function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Float16Array( 2 ); - buf = [ 0.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::typed_array:set', pkg ), function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Float16Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Float16Array( 2 ); - buf = new Float16Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.set.length.js b/benchmark/benchmark.set.length.js deleted file mode 100644 index f174a4a..0000000 --- a/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - - arr1 = uniform( len, 0.0, 10.0 ); - arr2 = uniform( len, 0.0, 10.0 ); - arr = new Float16Array( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - 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( format( '%s:set:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.slice.js b/benchmark/benchmark.slice.js deleted file mode 100644 index 9f5005a..0000000 --- a/benchmark/benchmark.slice.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:slice', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.slice.length.js b/benchmark/benchmark.slice.length.js deleted file mode 100644 index 2374b1b..0000000 --- a/benchmark/benchmark.slice.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s:slice:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.some.js b/benchmark/benchmark.some.js deleted file mode 100644 index 0c81afa..0000000 --- a/benchmark/benchmark.some.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:some', pkg ), function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); - -bench( format( '%s::this_context:some', pkg ), function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); diff --git a/benchmark/benchmark.some.length.js b/benchmark/benchmark.some.length.js deleted file mode 100644 index dd32df4..0000000 --- a/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,107 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value < 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - 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( format( '%s:some:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.sort.js b/benchmark/benchmark.sort.js deleted file mode 100644 index d9e6c30..0000000 --- a/benchmark/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:sort', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.sort.length.js b/benchmark/benchmark.sort.length.js deleted file mode 100644 index 508049c..0000000 --- a/benchmark/benchmark.sort.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ i%len ] = i; - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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 = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:sort:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.subarray.js b/benchmark/benchmark.subarray.js deleted file mode 100644 index 9d6a26b..0000000 --- a/benchmark/benchmark.subarray.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:subarray', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.subarray.length.js b/benchmark/benchmark.subarray.length.js deleted file mode 100644 index c40760b..0000000 --- a/benchmark/benchmark.subarray.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s:subarray:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_locale_string.js b/benchmark/benchmark.to_locale_string.js deleted file mode 100644 index 682ca77..0000000 --- a/benchmark/benchmark.to_locale_string.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:toLocaleString', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_locale_string.length.js b/benchmark/benchmark.to_locale_string.length.js deleted file mode 100644 index 20f510e..0000000 --- a/benchmark/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - 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 = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:toLocaleString:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_reversed.js b/benchmark/benchmark.to_reversed.js deleted file mode 100644 index 1b78c11..0000000 --- a/benchmark/benchmark.to_reversed.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:toReversed', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - 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 ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_reversed.length.js b/benchmark/benchmark.to_reversed.length.js deleted file mode 100644 index 66bf5dc..0000000 --- a/benchmark/benchmark.to_reversed.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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 ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s:toReversed:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_sorted.js b/benchmark/benchmark.to_sorted.js deleted file mode 100644 index d2021b5..0000000 --- a/benchmark/benchmark.to_sorted.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:toSorted', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toSorted(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_sorted.length.js b/benchmark/benchmark.to_sorted.length.js deleted file mode 100644 index b74ea43..0000000 --- a/benchmark/benchmark.to_sorted.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ i%len ] = i; - out = arr.toSorted(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a isFloat16Array' ); - } - 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( format( '%s:toSorted:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_string.js b/benchmark/benchmark.to_string.js deleted file mode 100644 index 6a31520..0000000 --- a/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:toString', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_string.length.js b/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 375cc12..0000000 --- a/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - 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 = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:toString:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.values.js b/benchmark/benchmark.values.js deleted file mode 100644 index 4352d26..0000000 --- a/benchmark/benchmark.values.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:values', pkg ), function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.values.length.js b/benchmark/benchmark.values.length.js deleted file mode 100644 index e0ac1ed..0000000 --- a/benchmark/benchmark.values.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var iter; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isIteratorLike( iter ) ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - 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( format( '%s:values:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.with.js b/benchmark/benchmark.with.js deleted file mode 100644 index 0ca8231..0000000 --- a/benchmark/benchmark.with.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:with', pkg ), function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = uniform( 2, 0.0, 1.0 ); - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.with( i%arr.length, values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.with.length.js b/benchmark/benchmark.with.length.js deleted file mode 100644 index efdf808..0000000 --- a/benchmark/benchmark.with.length.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var values; - var out; - var i; - - values = uniform( 2, 0.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.with( i%len, values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s:with:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.at.js b/benchmark/polyfill/benchmark.at.js deleted file mode 100644 index f0b2b78..0000000 --- a/benchmark/polyfill/benchmark.at.js +++ /dev/null @@ -1,79 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill::nonnegative_indices:at', pkg ), function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float16Array( uniform( 10, 0.0, 10.0 ) ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.at( i%N ); - if ( typeof v !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNumber( v ) ) { - b.fail( 'should return a number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::negative_indices:at', pkg ), function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float16Array( uniform( 10, 1.0, 10.0 ) ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.at( -(i%N)-1 ); - if ( typeof v !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNumber( v ) ) { - b.fail( 'should return a number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.copy_within.js b/benchmark/polyfill/benchmark.copy_within.js deleted file mode 100644 index 867e40a..0000000 --- a/benchmark/polyfill/benchmark.copy_within.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:copyWithin', pkg ), function benchmark( b ) { - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.copy_within.length.js b/benchmark/polyfill/benchmark.copy_within.length.js deleted file mode 100644 index 86bd362..0000000 --- a/benchmark/polyfill/benchmark.copy_within.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - 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( format( '%s::polyfill:copyWithin:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.entries.js b/benchmark/polyfill/benchmark.entries.js deleted file mode 100644 index 013036c..0000000 --- a/benchmark/polyfill/benchmark.entries.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:entries', pkg ), function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.every.js b/benchmark/polyfill/benchmark.every.js deleted file mode 100644 index 2b505c5..0000000 --- a/benchmark/polyfill/benchmark.every.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:every', pkg ), function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0.0; - } -}); - -bench( format( '%s::polyfill::this_context:every', pkg ), function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0.0; - } -}); diff --git a/benchmark/polyfill/benchmark.every.length.js b/benchmark/polyfill/benchmark.every.length.js deleted file mode 100644 index df08cff..0000000 --- a/benchmark/polyfill/benchmark.every.length.js +++ /dev/null @@ -1,107 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - 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( format( '%s::polyfill:every:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.fill.js b/benchmark/polyfill/benchmark.fill.js deleted file mode 100644 index 0c6e740..0000000 --- a/benchmark/polyfill/benchmark.fill.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:fill', pkg ), function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = [ 1.0, 2.0, 3.0 ]; - arr = new Float16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.fill( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.fill.length.js b/benchmark/polyfill/benchmark.fill.length.js deleted file mode 100644 index 6e72c6a..0000000 --- a/benchmark/polyfill/benchmark.fill.length.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var values; - var out; - var i; - - values = [ 1.0, 2.0, 3.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.fill( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s::polyfill:fill:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.filter.js b/benchmark/polyfill/benchmark.filter.js deleted file mode 100644 index 328c3d1..0000000 --- a/benchmark/polyfill/benchmark.filter.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:filter', pkg ), function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0.0; - } -}); - -bench( format( '%s::polyfill::this_context:filter', pkg ), function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0.0; - } -}); diff --git a/benchmark/polyfill/benchmark.filter.length.js b/benchmark/polyfill/benchmark.filter.length.js deleted file mode 100644 index 8673396..0000000 --- a/benchmark/polyfill/benchmark.filter.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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 = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s::polyfill:filter:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.find.js b/benchmark/polyfill/benchmark.find.js deleted file mode 100644 index aef5da9..0000000 --- a/benchmark/polyfill/benchmark.find.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:find', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); - -bench( format( '%s::polyfill::this_context:find', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); diff --git a/benchmark/polyfill/benchmark.find.length.js b/benchmark/polyfill/benchmark.find.length.js deleted file mode 100644 index 0059567..0000000 --- a/benchmark/polyfill/benchmark.find.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value < 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - 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( format( '%s::polyfill:find:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.find_index.js b/benchmark/polyfill/benchmark.find_index.js deleted file mode 100644 index 183c1e4..0000000 --- a/benchmark/polyfill/benchmark.find_index.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:findIndex', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); - -bench( format( '%s::polyfill::this_context:findIndex', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); diff --git a/benchmark/polyfill/benchmark.find_index.length.js b/benchmark/polyfill/benchmark.find_index.length.js deleted file mode 100644 index c9d2887..0000000 --- a/benchmark/polyfill/benchmark.find_index.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value < 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - 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( format( '%s::polyfill:findIndex:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.find_last.js b/benchmark/polyfill/benchmark.find_last.js deleted file mode 100644 index 1d79bb8..0000000 --- a/benchmark/polyfill/benchmark.find_last.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:findLast', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findLast( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); - -bench( format( '%s::polyfill::this_context:findLast', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findLast( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); diff --git a/benchmark/polyfill/benchmark.find_last.length.js b/benchmark/polyfill/benchmark.find_last.length.js deleted file mode 100644 index 5abddac..0000000 --- a/benchmark/polyfill/benchmark.find_last.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value < 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.findLast( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - 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( format( '%s::polyfill:findLast:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.find_last_index.js b/benchmark/polyfill/benchmark.find_last_index.js deleted file mode 100644 index 9fc8543..0000000 --- a/benchmark/polyfill/benchmark.find_last_index.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:findLastIndex', pkg ), function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findLastIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -bench( format( '%s::polyfill::this_context:findLastIndex', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findLastIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); diff --git a/benchmark/polyfill/benchmark.find_last_index.length.js b/benchmark/polyfill/benchmark.find_last_index.length.js deleted file mode 100644 index cd49c40..0000000 --- a/benchmark/polyfill/benchmark.find_last_index.length.js +++ /dev/null @@ -1,110 +0,0 @@ -/** - * @license Apache-2.0 -* -* Copyright (c) 2026 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. -*/ - -/* eslint-disable stdlib/jsdoc-typedef-typos */ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {boolean} value - array element -* @param {NonNegativeInteger} idx - array element index -* @param {Float16Array} arr - array instance -* @returns {boolean} boolean indicating whether a value passes a test -*/ -function predicate( value ) { - return value < 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.findLastIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - 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( format( '%s::polyfill:findLastIndex:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.for_each.js b/benchmark/polyfill/benchmark.for_each.js deleted file mode 100644 index d16383b..0000000 --- a/benchmark/polyfill/benchmark.for_each.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:forEach', pkg ), function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( format( '%s::polyfill::this_context:forEach', pkg ), function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/benchmark/polyfill/benchmark.for_each.length.js b/benchmark/polyfill/benchmark.for_each.length.js deleted file mode 100644 index 5b4f977..0000000 --- a/benchmark/polyfill/benchmark.for_each.length.js +++ /dev/null @@ -1,108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// 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( format( '%s::polyfill:forEach:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.from.js b/benchmark/polyfill/benchmark.from.js deleted file mode 100644 index 8af766a..0000000 --- a/benchmark/polyfill/benchmark.from.js +++ /dev/null @@ -1,238 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( format( '%s::polyfill::typed_array:from', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::typed_array,clbk:from', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1.0; - } -}); - -bench( format( '%s::polyfill::array:from', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1.0, 2.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::array,clbk:from', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1.0, 2.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1.0; - } -}); - -bench( format( '%s::polyfill::iterable:from', pkg ), opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0.0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( format( '%s::polyfill::iterable,clbk:from:', pkg ), opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1.0, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1.0; - } -}); diff --git a/benchmark/polyfill/benchmark.get.js b/benchmark/polyfill/benchmark.get.js deleted file mode 100644 index 2bc111b..0000000 --- a/benchmark/polyfill/benchmark.get.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:get', pkg ), function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float16Array( uniform( 10, 0.0, 10.0 ) ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( typeof v !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNumber( v ) ) { - b.fail( 'should return a number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.includes.js b/benchmark/polyfill/benchmark.includes.js deleted file mode 100644 index 30fc8c4..0000000 --- a/benchmark/polyfill/benchmark.includes.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:includes', pkg ), function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Float16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1.0; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.includes.length.js b/benchmark/polyfill/benchmark.includes.length.js deleted file mode 100644 index 8ac1374..0000000 --- a/benchmark/polyfill/benchmark.includes.length.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1.0; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - 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( format( '%s::polyfill:includes:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.index_of.js b/benchmark/polyfill/benchmark.index_of.js deleted file mode 100644 index c11797c..0000000 --- a/benchmark/polyfill/benchmark.index_of.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:indexOf', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.indexOf( 11.0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( out ) ) { - b.fail( 'should return an integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.index_of.length.js b/benchmark/polyfill/benchmark.index_of.length.js deleted file mode 100644 index 96dfe78..0000000 --- a/benchmark/polyfill/benchmark.index_of.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.indexOf( 11.0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( out ) ) { - b.fail( 'should return an integer' ); - } - 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( format( '%s::polyfill:indexOf:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.join.js b/benchmark/polyfill/benchmark.join.js deleted file mode 100644 index d3d5a47..0000000 --- a/benchmark/polyfill/benchmark.join.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:join', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.join.length.js b/benchmark/polyfill/benchmark.join.length.js deleted file mode 100644 index ca50459..0000000 --- a/benchmark/polyfill/benchmark.join.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - 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( format( '%s::polyfill:join:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.js b/benchmark/polyfill/benchmark.js deleted file mode 100644 index 7c38bae..0000000 --- a/benchmark/polyfill/benchmark.js +++ /dev/null @@ -1,338 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( format( '%s::polyfill::instantiation,new', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array(); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::instantiation,no_new', pkg ), function benchmark( b ) { - var ctor; - var arr; - var i; - - ctor = Float16Array; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = ctor(); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::instantiation,length', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::instantiation,typed_array', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::instantiation,array', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = []; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::instantiation,iterable', pkg ), opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( createIterable() ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - return { - 'done': true - }; - } - } -}); - -bench( format( '%s::polyfill::instantiation,arraybuffer', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::instantiation,arraybuffer,byte_offset', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 8 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( buf, 8 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::instantiation,arraybuffer,byte_offset,length', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 8 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( buf, 8, 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::get:buffer', pkg ), function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float16Array(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::get:byteLength', pkg ), function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float16Array(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::get:byteOffset', pkg ), function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float16Array(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::get:length', pkg ), function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float16Array(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.keys.js b/benchmark/polyfill/benchmark.keys.js deleted file mode 100644 index b51d241..0000000 --- a/benchmark/polyfill/benchmark.keys.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:keys', pkg ), function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.keys.length.js b/benchmark/polyfill/benchmark.keys.length.js deleted file mode 100644 index c6ac13c..0000000 --- a/benchmark/polyfill/benchmark.keys.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var iter; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isIteratorLike( iter ) ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - 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( format( '%s::polyfill:keys:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.last_index_of.js b/benchmark/polyfill/benchmark.last_index_of.js deleted file mode 100644 index 950c98b..0000000 --- a/benchmark/polyfill/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:lastIndexOf', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.lastIndexOf( 11.0 ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.last_index_of.length.js b/benchmark/polyfill/benchmark.last_index_of.length.js deleted file mode 100644 index bf069bb..0000000 --- a/benchmark/polyfill/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.lastIndexOf( 11.0 ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - 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( format( '%s::polyfill:lastIndexOf:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.length.js b/benchmark/polyfill/benchmark.length.js deleted file mode 100644 index 488b91b..0000000 --- a/benchmark/polyfill/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s::polyfill:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.map.js b/benchmark/polyfill/benchmark.map.js deleted file mode 100644 index 810ce41..0000000 --- a/benchmark/polyfill/benchmark.map.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:map', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1.0; - } -}); - -bench( format( '%s::polyfill::this_context:map', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1.0; - } -}); diff --git a/benchmark/polyfill/benchmark.map.length.js b/benchmark/polyfill/benchmark.map.length.js deleted file mode 100644 index 6156472..0000000 --- a/benchmark/polyfill/benchmark.map.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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 = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s::polyfill:map:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.of.js b/benchmark/polyfill/benchmark.of.js deleted file mode 100644 index 165e244..0000000 --- a/benchmark/polyfill/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:of', pkg ), function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.of( i, 2.0 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.reduce.js b/benchmark/polyfill/benchmark.reduce.js deleted file mode 100644 index b8215bd..0000000 --- a/benchmark/polyfill/benchmark.reduce.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:reduce', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1.0; - } -}); - -bench( format( '%s::polyfill::initial_value:reduce', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3.14 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1.0; - } -}); diff --git a/benchmark/polyfill/benchmark.reduce.length.js b/benchmark/polyfill/benchmark.reduce.length.js deleted file mode 100644 index 6d74ccc..0000000 --- a/benchmark/polyfill/benchmark.reduce.length.js +++ /dev/null @@ -1,107 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - 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( format( '%s::polyfill:reduce:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.reduce_right.js b/benchmark/polyfill/benchmark.reduce_right.js deleted file mode 100644 index f2686f6..0000000 --- a/benchmark/polyfill/benchmark.reduce_right.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:reduceRight', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1.0; - } -}); - -bench( format( '%s::polyfill::initial_value:reduceRight', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3.14 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1.0; - } -}); diff --git a/benchmark/polyfill/benchmark.reduce_right.length.js b/benchmark/polyfill/benchmark.reduce_right.length.js deleted file mode 100644 index 62948e3..0000000 --- a/benchmark/polyfill/benchmark.reduce_right.length.js +++ /dev/null @@ -1,107 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - 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( format( '%s::polyfill:reduceRight:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.reverse.js b/benchmark/polyfill/benchmark.reverse.js deleted file mode 100644 index 386b361..0000000 --- a/benchmark/polyfill/benchmark.reverse.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:reverse', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.reverse.length.js b/benchmark/polyfill/benchmark.reverse.length.js deleted file mode 100644 index 5f051b7..0000000 --- a/benchmark/polyfill/benchmark.reverse.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s::polyfill:reverse:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.set.js b/benchmark/polyfill/benchmark.set.js deleted file mode 100644 index e2394cf..0000000 --- a/benchmark/polyfill/benchmark.set.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill::array:set', pkg ), function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Float16Array( 2 ); - buf = [ 0.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::typed_array:set', pkg ), function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Float16Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Float16Array( 2 ); - buf = new Float16Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.set.length.js b/benchmark/polyfill/benchmark.set.length.js deleted file mode 100644 index 72a56e7..0000000 --- a/benchmark/polyfill/benchmark.set.length.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - - arr1 = uniform( len, 0.0, 10.0 ); - arr2 = uniform( len, 0.0, 10.0 ); - arr = new Float16Array( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - 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( format( '%s::polyfill:set:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.slice.js b/benchmark/polyfill/benchmark.slice.js deleted file mode 100644 index 8ee2df0..0000000 --- a/benchmark/polyfill/benchmark.slice.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:slice', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.slice.length.js b/benchmark/polyfill/benchmark.slice.length.js deleted file mode 100644 index 232cff3..0000000 --- a/benchmark/polyfill/benchmark.slice.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s::polyfill:slice:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.some.js b/benchmark/polyfill/benchmark.some.js deleted file mode 100644 index c987ef3..0000000 --- a/benchmark/polyfill/benchmark.some.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:some', pkg ), function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); - -bench( format( '%s::polyfill::this_context:some', pkg ), function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); diff --git a/benchmark/polyfill/benchmark.some.length.js b/benchmark/polyfill/benchmark.some.length.js deleted file mode 100644 index fb689b5..0000000 --- a/benchmark/polyfill/benchmark.some.length.js +++ /dev/null @@ -1,107 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value < 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - 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( format( '%s::polyfill:some:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.sort.js b/benchmark/polyfill/benchmark.sort.js deleted file mode 100644 index 1ffaac3..0000000 --- a/benchmark/polyfill/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:sort', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.sort.length.js b/benchmark/polyfill/benchmark.sort.length.js deleted file mode 100644 index ec66cc2..0000000 --- a/benchmark/polyfill/benchmark.sort.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ i%len ] = i; - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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 = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s::polyfill:sort:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.subarray.js b/benchmark/polyfill/benchmark.subarray.js deleted file mode 100644 index b07f552..0000000 --- a/benchmark/polyfill/benchmark.subarray.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:subarray', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.subarray.length.js b/benchmark/polyfill/benchmark.subarray.length.js deleted file mode 100644 index 7313db0..0000000 --- a/benchmark/polyfill/benchmark.subarray.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s::polyfill:subarray:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.to_locale_string.js b/benchmark/polyfill/benchmark.to_locale_string.js deleted file mode 100644 index 7add18e..0000000 --- a/benchmark/polyfill/benchmark.to_locale_string.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:toLocaleString', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.to_locale_string.length.js b/benchmark/polyfill/benchmark.to_locale_string.length.js deleted file mode 100644 index 3f98d03..0000000 --- a/benchmark/polyfill/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - 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 = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s::polyfill:toLocaleString:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.to_reversed.js b/benchmark/polyfill/benchmark.to_reversed.js deleted file mode 100644 index ca7d6b5..0000000 --- a/benchmark/polyfill/benchmark.to_reversed.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:toReversed', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - 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 ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.to_reversed.length.js b/benchmark/polyfill/benchmark.to_reversed.length.js deleted file mode 100644 index e9fee39..0000000 --- a/benchmark/polyfill/benchmark.to_reversed.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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 ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s::polyfill:toReversed:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.to_sorted.js b/benchmark/polyfill/benchmark.to_sorted.js deleted file mode 100644 index 736fcf1..0000000 --- a/benchmark/polyfill/benchmark.to_sorted.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:toSorted', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toSorted(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.to_sorted.length.js b/benchmark/polyfill/benchmark.to_sorted.length.js deleted file mode 100644 index 32884b3..0000000 --- a/benchmark/polyfill/benchmark.to_sorted.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ i%len ] = i; - out = arr.toSorted(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a isFloat16Array' ); - } - 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( format( '%s::polyfill:toSorted:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.to_string.js b/benchmark/polyfill/benchmark.to_string.js deleted file mode 100644 index a2f7647..0000000 --- a/benchmark/polyfill/benchmark.to_string.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:toString', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.to_string.length.js b/benchmark/polyfill/benchmark.to_string.length.js deleted file mode 100644 index a772983..0000000 --- a/benchmark/polyfill/benchmark.to_string.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - 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 = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s::polyfill:toString:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.values.js b/benchmark/polyfill/benchmark.values.js deleted file mode 100644 index 59a4470..0000000 --- a/benchmark/polyfill/benchmark.values.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:values', pkg ), function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.values.length.js b/benchmark/polyfill/benchmark.values.length.js deleted file mode 100644 index f300b23..0000000 --- a/benchmark/polyfill/benchmark.values.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var iter; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isIteratorLike( iter ) ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - 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( format( '%s::polyfill:values:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.with.js b/benchmark/polyfill/benchmark.with.js deleted file mode 100644 index 05edb05..0000000 --- a/benchmark/polyfill/benchmark.with.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:with', pkg ), function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = uniform( 2, 0.0, 1.0 ); - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.with( i%arr.length, values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.with.length.js b/benchmark/polyfill/benchmark.with.length.js deleted file mode 100644 index cf76a7d..0000000 --- a/benchmark/polyfill/benchmark.with.length.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var values; - var out; - var i; - - values = uniform( 2, 0.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.with( i%len, values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s::polyfill:with:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 62eb7f0..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/float16" -%% click B href "https://github.com/stdlib-js/array-float16/tree/main" -%% click C href "https://github.com/stdlib-js/array-float16/tree/production" -%% click D href "https://github.com/stdlib-js/array-float16/tree/esm" -%% click E href "https://github.com/stdlib-js/array-float16/tree/deno" -%% click F href "https://github.com/stdlib-js/array-float16/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/float16 -[production-url]: https://github.com/stdlib-js/array-float16/tree/production -[deno-url]: https://github.com/stdlib-js/array-float16/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-float16/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-float16/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-float16/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-float16/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-float16/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 0b44231..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ctor from '../docs/types/index'; -export = ctor; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c93dada..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var T=function(o,r){return function(){return r||o((r={exports:{}}).exports,r),r.exports}};var O=T(function(pr,R){"use strict";var D=require("@stdlib/number-float64-base-to-float16"),J=require("@stdlib/number-float16-base-to-word");function K(o,r){var t,i;for(t=r.length,i=0;it.byteLength-o)throw new RangeError(s("invalid arguments. ArrayBuffer has insufficient capacity. Either decrease the array length or provide a bigger buffer. Minimum capacity: `%u`.",i*w));t=new b(t,o,i)}}for(f(this,"_buffer",t),f(this,"_length",t.length),n=0;n1){if(e=arguments[1],!p(e))throw new TypeError(s("invalid argument. Second argument must be a function. Value: `%s`.",e));i>2&&(t=arguments[2])}if(S(r)){if(e){for(h=r.length,n=new this(h),a=n._buffer,y=0;y=this._length))return g(this._buffer[r])});F(u.prototype,"buffer",function(){return this._buffer.buffer});F(u.prototype,"byteLength",function(){return this._buffer.byteLength});F(u.prototype,"byteOffset",function(){return this._buffer.byteOffset});f(u.prototype,"BYTES_PER_ELEMENT",u.BYTES_PER_ELEMENT);f(u.prototype,"copyWithin",function(r,t){if(!v(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");return arguments.length===2?this._buffer.copyWithin(r,t):this._buffer.copyWithin(r,t,arguments[2]),this});f(u.prototype,"entries",function(){var r,t,i,e,n,a;if(!v(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");return r=this,e=this._buffer,i=this._length,a=-1,t={},f(t,"next",l),f(t,"return",h),c&&f(t,c,y),t;function l(){return a+=1,n||a>=i?{done:!0}:{value:[a,g(e[a])],done:!1}}function h(q){return n=!0,arguments.length?{value:q,done:!0}:{done:!0}}function y(){return r.entries()}});f(u.prototype,"every",function(r,t){var i,e;if(!v(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!p(r))throw new TypeError(s("invalid argument. First argument must be a function. Value: `%s`.",r));for(i=this._buffer,e=0;e1){if(!m(t))throw new TypeError(s("invalid argument. Second argument must be an integer. Value: `%s`.",t));if(t<0&&(t+=n,t<0&&(t=0)),arguments.length>2){if(!m(i))throw new TypeError(s("invalid argument. Third argument must be an integer. Value: `%s`.",i));i<0&&(i+=n,i<0&&(i=0)),i>n&&(i=n)}else i=n}else t=0,i=n;for(l=E(r),a=t;a=0;n--)if(e=g(i[n]),r.call(t,e,n,this))return e});f(u.prototype,"findLastIndex",function(r,t){var i,e,n;if(!v(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!p(r))throw new TypeError(s("invalid argument. First argument must be a function. Value: `%s`.",r));for(i=this._buffer,n=this._length-1;n>=0;n--)if(e=g(i[n]),r.call(t,e,n,this))return n;return-1});f(u.prototype,"forEach",function(r,t){var i,e;if(!v(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!p(r))throw new TypeError(s("invalid argument. First argument must be a function. Value: `%s`.",r));for(i=this._buffer,e=0;e=this._length))return g(this._buffer[r])});f(u.prototype,"includes",function(r,t){var i,e,n;if(!v(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!d(r))throw new TypeError(s("invalid argument. First argument must be a number. Value: `%s`.",r));if(arguments.length>1){if(!m(t))throw new TypeError(s("invalid argument. Second argument must be an integer. Value: `%s`.",t));t<0&&(t+=this._length,t<0&&(t=0))}else t=0;for(i=this._buffer,n=E(r),e=t;e1){if(!m(t))throw new TypeError(s("invalid argument. Second argument must be an integer. Value: `%s`.",t));t<0&&(t+=this._length,t<0&&(t=0))}else t=0;for(i=this._buffer,n=E(r),e=t;e0){if(!P(r))throw new TypeError(s("invalid argument. First argument must be a string. Value: `%s`.",r))}else r=",";for(t=this._buffer,i=[],e=0;e=i?{done:!0}:{value:n,done:!1}}function l(y){return e=!0,arguments.length?{value:y,done:!0}:{done:!0}}function h(){return r.keys()}});f(u.prototype,"lastIndexOf",function(r,t){var i,e,n;if(!v(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!d(r))throw new TypeError(s("invalid argument. First argument must be a number. Value: `%s`.",r));if(arguments.length>1){if(!m(t))throw new TypeError(s("invalid argument. Second argument must be an integer. Value: `%s`.",t));t>=this._length?t=this._length-1:t<0&&(t+=this._length)}else t=this._length-1;for(i=this._buffer,n=E(r),e=t;e>=0;e--)if(n===i[e])return e;return-1});F(u.prototype,"length",function(){return this._length});f(u.prototype,"map",function(r,t){var i,e,n,a;if(!v(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!p(r))throw new TypeError("invalid argument. First argument must be a function. Value: `%s`.",r);for(n=this._buffer,e=new this.constructor(this._length),i=e._buffer,a=0;a1)n=t,a=0;else{if(e===0)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");n=g(i[0]),a=1}for(;a1)n=t,a=e-1;else{if(e===0)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");n=g(i[e-1]),a=e-2}for(;a>=0;a--)n=r(n,g(i[a]),a,this);return n});f(u.prototype,"reverse",function(){var r,t,i,e,n,a;if(!v(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");for(r=this._buffer,i=this._length,e=ir(i/2),n=0;n1){if(i=arguments[1],!_(i))throw new TypeError(s("invalid argument. Index argument must be a nonnegative integer. Value: `%s`.",i))}else i=0;if(l=r.length,i+l>this._length)throw new RangeError("invalid arguments. Target array lacks sufficient storage to accommodate source values.");if(v(r)?(t=r._buffer,a=!0):(t=r,a=!1),y=e.byteOffset+i*w,t.buffer===e.buffer&&t.byteOffsety){for(n=new b(t.length),h=0;hl&&(t=l)}}for(rh?1:0}function e(n,a){return r(g(n),g(a))}});f(u.prototype,"subarray",function(r,t){var i,e,n;if(!v(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(e=this._buffer,n=this._length,arguments.length===0)r=0,t=n;else{if(!m(r))throw new TypeError(s("invalid argument. First argument must be an integer. Value: `%s`.",r));if(r<0&&(r+=n,r<0&&(r=0)),arguments.length===1)t=n;else{if(!m(t))throw new TypeError(s("invalid argument. Second argument must be an integer. Value: `%s`.",t));t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n)}}return r>=n?(n=0,i=e.byteLength):r>=t?(n=0,i=e.byteOffset+r*w):(n=t-r,i=e.byteOffset+r*w),new this.constructor(e.buffer,i,n<0?0:n)});f(u.prototype,"toLocaleString",function(r,t){var i,e,n,a,l;if(!v(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(arguments.length===0)e=[];else if(P(r)||tr(r))e=r;else throw new TypeError(s("invalid argument. First argument must be a string or an array of strings. Value: `%s`.",r));if(arguments.length<2)i={};else if(A(t))i=t;else throw new TypeError(s("invalid argument. Options argument must be an object. Value: `%s`.",t));for(a=this._buffer,n=[],l=0;l=i?{done:!0}:{value:g(n[a]),done:!1}}function h(q){return e=!0,arguments.length?{value:q,done:!0}:{done:!0}}function y(){return t.values()}});f(u.prototype,"with",function(r,t){var i,e;if(!v(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!m(r))throw new TypeError(s("invalid argument. First argument must be an integer. Value: `%s`.",r));if(e=this._length,r<0&&(r+=e),r<0||r>=e)throw new RangeError(s("invalid argument. Index argument is out-of-bounds. Value: `%s`.",r));if(!d(t))throw new TypeError(s("invalid argument. Second argument must be a floating-point number. Value: `%s`.",t));return i=new this.constructor(this),i[r]=t,i});G.exports=u});var z=T(function(cr,U){"use strict";var lr=typeof Float16Array=="function"?Float16Array:void 0;U.exports=lr});var hr=require("@stdlib/assert-has-float16array-support"),vr=H(),gr=z(),L;hr()?L=gr:L=vr;module.exports=L; -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index c463d30..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/polyfill/from_array.js", "../lib/polyfill/from_iterator.js", "../lib/polyfill/from_iterator_map.js", "../lib/polyfill/index.js", "../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar f16 = require( '@stdlib/number-float64-base-to-float16' );\nvar toWord = require( '@stdlib/number-float16-base-to-word' );\n\n\n// MAIN //\n\n/**\n* Fills an output array with unsigned 16-bit integers corresponding to the IEEE 754 binary representation of respective half-precision floating-point numbers.\n*\n* @private\n* @param {Uint16Array} buf - output array\n* @param {Array} arr - input array\n* @returns {Uint16Array} output array\n*/\nfunction fromArray( buf, arr ) {\n\tvar len;\n\tvar i;\n\n\tlen = arr.length;\n\tfor ( i = 0; i < len; i++ ) {\n\t\tbuf[ i ] = toWord( f16( arr[ i ] ) );\n\t}\n\treturn buf;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fromArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar f16 = require( '@stdlib/number-float64-base-to-float16' );\nvar toWord = require( '@stdlib/number-float16-base-to-word' );\n\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @returns {Array} output array\n*/\nfunction fromIterator( it ) {\n\tvar out;\n\tvar v;\n\n\tout = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tout.push( toWord( f16( v.value ) ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fromIterator;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar f16 = require( '@stdlib/number-float64-base-to-float16' );\nvar toWord = require( '@stdlib/number-float16-base-to-word' );\n\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @param {Function} clbk - callback to invoke for each iterated value\n* @param {*} thisArg - invocation context\n* @returns {Array} output array\n*/\nfunction fromIteratorMap( it, clbk, thisArg ) {\n\tvar out;\n\tvar v;\n\tvar i;\n\n\tout = [];\n\ti = -1;\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\ti += 1;\n\t\tout.push( toWord( f16( clbk.call( thisArg, v.value, i ) ) ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fromIteratorMap;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this, stdlib/jsdoc-typedef-typos, max-lines */\n\n'use strict';\n\n// MODULES //\n\nvar hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' );\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar isStringArray = require( '@stdlib/assert-is-string-array' ).primitives;\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isObject = require( '@stdlib/assert-is-object' );\nvar isnan = require( '@stdlib/math-base-assert-is-nan' );\nvar ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' );\nvar floor = require( '@stdlib/math-base-special-floor' );\nvar format = require( '@stdlib/string-format' );\nvar Uint16Array = require( '@stdlib/array-uint16' );\nvar f16 = require( '@stdlib/number-float64-base-to-float16' );\nvar toWord = require( '@stdlib/number-float16-base-to-word' );\nvar fromWord = require( '@stdlib/number-float16-base-from-word' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar fromArray = require( './from_array.js' );\nvar fromIterator = require( './from_iterator.js' );\nvar fromIteratorMap = require( './from_iterator_map.js' );\n\n\n// VARIABLES //\n\nvar BYTES_PER_ELEMENT = Uint16Array.BYTES_PER_ELEMENT;\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\n\n\n// FUNCTIONS //\n\n/**\n* Returns a boolean indicating if a value is a `Float16Array`.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `Float16Array`\n*/\nfunction isFloat16Array( value ) {\n\treturn (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\tvalue.constructor.name === 'Float16Array' &&\n\t\tvalue.BYTES_PER_ELEMENT === BYTES_PER_ELEMENT\n\t);\n}\n\n/**\n* Returns a boolean indicating if a value is a floating-point typed array constructor.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a floating-point typed array constructor\n*/\nfunction isFloatingPointArrayConstructor( value ) { // eslint-disable-line id-length\n\treturn ( value === Float16Array );\n}\n\n/**\n* Returns a getter.\n*\n* @private\n* @param {Float16Array} ctx - typed array instance\n* @param {NonNegativeInteger} idx - element index\n* @returns {Function} getter\n*/\nfunction getter( ctx, idx ) {\n\treturn get;\n\n\t/**\n\t* Returns an array element.\n\t*\n\t* @private\n\t* @returns {(number|void)} array element\n\t*/\n\tfunction get() {\n\t\treturn ctx._get( idx ); // eslint-disable-line no-underscore-dangle\n\t}\n}\n\n/**\n* Returns a setter.\n*\n* @private\n* @param {Float16Array} ctx - typed array instance\n* @param {NonNegativeInteger} idx - element index\n* @returns {Function} setter\n*/\nfunction setter( ctx, idx ) {\n\treturn set;\n\n\t/**\n\t* Sets an array element.\n\t*\n\t* @private\n\t* @param {number} value - value to set\n\t*/\n\tfunction set( value ) {\n\t\tctx.set( [ value ], idx );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* 16-bit floating-point number array constructor.\n*\n* @constructor\n* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable\n* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n* @param {NonNegativeInteger} [length] - view length\n* @throws {RangeError} ArrayBuffer byte length must be a multiple of `2`\n* @throws {TypeError} if provided only a single argument, must provide a valid argument\n* @throws {TypeError} byte offset must be a nonnegative integer\n* @throws {RangeError} byte offset must be a multiple of `2`\n* @throws {TypeError} view length must be a positive multiple of `2`\n* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n* @returns {Float16Array} half-precision floating-point number array\n*\n* @example\n* var arr = new Float16Array();\n* // returns \n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var arr = new Float16Array( 5 );\n* // returns \n*\n* var len = arr.length;\n* // returns 5\n*\n* @example\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 5\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float16Array( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 8\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float16Array( buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 4\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Float16Array( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nfunction Float16Array() {\n\tvar byteOffset;\n\tvar nargs;\n\tvar buf;\n\tvar len;\n\tvar arg;\n\tvar i;\n\n\tnargs = arguments.length;\n\tif ( !(this instanceof Float16Array) ) {\n\t\tif ( nargs === 0 ) {\n\t\t\treturn new Float16Array();\n\t\t}\n\t\tif ( nargs === 1 ) {\n\t\t\treturn new Float16Array( arguments[0] );\n\t\t}\n\t\tif ( nargs === 2 ) {\n\t\t\treturn new Float16Array( arguments[0], arguments[1] );\n\t\t}\n\t\treturn new Float16Array( arguments[0], arguments[1], arguments[2] );\n\t}\n\t// Create the underlying data buffer...\n\tif ( nargs === 0 ) {\n\t\tbuf = new Uint16Array( 0 ); // backward-compatibility\n\t} else if ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\t\tif ( isNonNegativeInteger( arg ) ) {\n\t\t\tbuf = new Uint16Array( arg );\n\t\t} else if ( isCollection( arg ) ) {\n\t\t\tif ( isFloat16Array( arg ) ) {\n\t\t\t\tbuf = new Uint16Array( arg.length );\n\t\t\t\tgcopy.ndarray( arg.length, new Uint16Array( arg.buffer, arg.byteOffset, arg.length ), 1, 0, buf, 1, 0 ); // eslint-disable-line max-len\n\t\t\t} else {\n\t\t\t\tbuf = fromArray( new Uint16Array( arg.length ), arg );\n\t\t\t}\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tif ( !isInteger( arg.byteLength/BYTES_PER_ELEMENT ) ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer byte length must be a multiple of %u. Byte length: `%u`.', BYTES_PER_ELEMENT, arg.byteLength ) );\n\t\t\t}\n\t\t\tbuf = new Uint16Array( arg );\n\t\t} else if ( isObject( arg ) ) {\n\t\t\tif ( HAS_ITERATOR_SYMBOL === false ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, ArrayBuffer, typed array, or array-like object. Value: `%s`.', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t\t}\n\t\t\tbuf = arg[ ITERATOR_SYMBOL ]();\n\t\t\tif ( !isFunction( buf.next ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t\t}\n\t\t\tbuf = new Uint16Array( fromIterator( buf ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t}\n\t} else {\n\t\tbuf = arguments[ 0 ];\n\t\tif ( !isArrayBuffer( buf ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', buf ) );\n\t\t}\n\t\tbyteOffset = arguments[ 1 ];\n\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) );\n\t\t}\n\t\tif ( !isInteger( byteOffset/BYTES_PER_ELEMENT ) ) {\n\t\t\tthrow new RangeError( format( 'invalid argument. Byte offset must be a multiple of %u. Value: `%u`.', BYTES_PER_ELEMENT, byteOffset ) );\n\t\t}\n\t\tif ( nargs === 2 ) {\n\t\t\tlen = buf.byteLength - byteOffset;\n\t\t\tif ( !isInteger( len/BYTES_PER_ELEMENT ) ) {\n\t\t\t\tthrow new RangeError( format( 'invalid arguments. ArrayBuffer view byte length must be a multiple of %u. View byte length: `%u`.', BYTES_PER_ELEMENT, len ) );\n\t\t\t}\n\t\t\tbuf = new Uint16Array( buf, byteOffset );\n\t\t} else {\n\t\t\tlen = arguments[ 2 ];\n\t\t\tif ( !isNonNegativeInteger( len ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', len ) );\n\t\t\t}\n\t\t\tif ( (len*BYTES_PER_ELEMENT) > (buf.byteLength-byteOffset) ) {\n\t\t\t\tthrow new RangeError( format( 'invalid arguments. ArrayBuffer has insufficient capacity. Either decrease the array length or provide a bigger buffer. Minimum capacity: `%u`.', len*BYTES_PER_ELEMENT ) );\n\t\t\t}\n\t\t\tbuf = new Uint16Array( buf, byteOffset, len );\n\t\t}\n\t}\n\tsetReadOnly( this, '_buffer', buf );\n\tsetReadOnly( this, '_length', buf.length );\n\tfor ( i = 0; i < buf.length; i++ ) {\n\t\tsetReadWriteAccessor( this, i, getter( this, i ), setter( this, i ) );\n\t}\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each array element.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Float16Array\n* @readonly\n* @type {PositiveInteger}\n* @default 2\n*\n* @example\n* var nbytes = Float16Array.BYTES_PER_ELEMENT;\n* // returns 2\n*/\nsetReadOnly( Float16Array, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT );\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof Float16Array\n* @readonly\n* @type {string}\n* @default 'Float16Array'\n*\n* @example\n* var str = Float16Array.name;\n* // returns 'Float16Array'\n*/\nsetReadOnly( Float16Array, 'name', 'Float16Array' );\n\n/**\n* Creates a new 16-bit floating-point number array from an array-like object or an iterable.\n*\n* @name from\n* @memberof Float16Array\n* @type {Function}\n* @param {(Collection|Iterable)} src - array-like object or iterable\n* @param {Function} [clbk] - callback to invoke for each source element\n* @param {*} [thisArg] - context\n* @throws {TypeError} `this` context must be a constructor\n* @throws {TypeError} `this` must be a floating-point array\n* @throws {TypeError} first argument must be an array-like object or an iterable\n* @throws {TypeError} second argument must be a function\n* @returns {Float16Array} half-precision floating-point number array\n*\n* @example\n* var arr = Float16Array.from( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* function clbk( v ) {\n* return v * 2.0;\n* }\n*\n* var arr = Float16Array.from( [ 1.0, 2.0 ], clbk );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nsetReadOnly( Float16Array, 'from', function from( src ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar clbk;\n\tvar out;\n\tvar buf;\n\tvar tmp;\n\tvar len;\n\tvar i;\n\tif ( !isFunction( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` context must be a constructor.' );\n\t}\n\tif ( !isFloatingPointArrayConstructor( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point array.' );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs > 1 ) {\n\t\tclbk = arguments[ 1 ];\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t\tif ( nargs > 2 ) {\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( isCollection( src ) ) {\n\t\tif ( clbk ) {\n\t\t\tlen = src.length;\n\t\t\tout = new this( len );\n\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tbuf[ i ] = toWord( f16( clbk.call( thisArg, src[ i ], i ) ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\treturn new this( src );\n\t}\n\tif ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) { // eslint-disable-line max-len\n\t\tbuf = src[ ITERATOR_SYMBOL ]();\n\t\tif ( !isFunction( buf.next ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) );\n\t\t}\n\t\tif ( clbk ) {\n\t\t\ttmp = fromIteratorMap( buf, clbk, thisArg );\n\t\t} else {\n\t\t\ttmp = fromIterator( buf );\n\t\t}\n\t\tif ( tmp instanceof Error ) {\n\t\t\tthrow tmp;\n\t\t}\n\t\tlen = tmp.length;\n\t\tout = new this( len );\n\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tbuf[ i ] = tmp[ i ];\n\t\t}\n\t\treturn out;\n\t}\n\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) );\n});\n\n/**\n* Creates a new 16-bit floating-point number array from a variable number of arguments.\n*\n* @name of\n* @memberof Float16Array\n* @type {Function}\n* @param {...*} element - array elements\n* @throws {TypeError} `this` context must be a constructor\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Float16Array} half-precision floating-point number array\n*\n* @example\n* var arr = Float16Array.of( 1.0, 1.0, 1.0, 1.0 );\n* // returns \n*\n* var x = arr[ 0 ];\n* // returns 1.0\n*\n* var len = arr.length;\n* // returns 4\n*/\nsetReadOnly( Float16Array, 'of', function of() {\n\tvar args;\n\tvar i;\n\tif ( !isFunction( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` context must be a constructor.' );\n\t}\n\tif ( !isFloatingPointArrayConstructor( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\targs = [];\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\targs.push( arguments[ i ] );\n\t}\n\treturn new this( args );\n});\n\n/**\n* Returns an array element with support for both nonnegative and negative integer indices.\n*\n* @name at\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} must provide an integer\n* @returns {(number|void)} array element\n*\n* @example\n* var arr = new Float16Array( [ 10.0, 20.0, 30.0 ] );\n*\n* var v = arr.at( 0 );\n* // returns 10.0\n*\n* v = arr.at( -1 );\n* // returns 30.0\n*\n* v = arr.at( 100 );\n* // returns undefined\n*/\nsetReadOnly( Float16Array.prototype, 'at', function at( idx ) {\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += this._length;\n\t}\n\tif ( idx < 0 || idx >= this._length ) {\n\t\treturn;\n\t}\n\treturn fromWord( this._buffer[ idx ] );\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name buffer\n* @memberof Float16Array.prototype\n* @readonly\n* @type {ArrayBuffer}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var buf = arr.buffer;\n* // returns \n*/\nsetReadOnlyAccessor( Float16Array.prototype, 'buffer', function get() {\n\treturn this._buffer.buffer;\n});\n\n/**\n* Size (in bytes) of the array.\n*\n* @name byteLength\n* @memberof Float16Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var byteLength = arr.byteLength;\n* // returns 20\n*/\nsetReadOnlyAccessor( Float16Array.prototype, 'byteLength', function get() {\n\treturn this._buffer.byteLength;\n});\n\n/**\n* Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`.\n*\n* @name byteOffset\n* @memberof Float16Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var byteOffset = arr.byteOffset;\n* // returns 0\n*/\nsetReadOnlyAccessor( Float16Array.prototype, 'byteOffset', function get() {\n\treturn this._buffer.byteOffset;\n});\n\n/**\n* Size (in bytes) of each array element.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Float16Array.prototype\n* @readonly\n* @type {PositiveInteger}\n* @default 2\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var nbytes = arr.BYTES_PER_ELEMENT;\n* // returns 2\n*/\nsetReadOnly( Float16Array.prototype, 'BYTES_PER_ELEMENT', Float16Array.BYTES_PER_ELEMENT );\n\n/**\n* Copies a sequence of elements within the array to the position starting at `target`.\n*\n* @name copyWithin\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} target - index at which to start copying elements\n* @param {integer} start - source index at which to copy elements from\n* @param {integer} [end] - source index at which to stop copying elements from\n* @throws {TypeError} `this` must be a floating-point array\n* @returns {Float16Array} modified array\n*\n* @example\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0 ] );\n*\n* // Copy the first two elements to the last two elements:\n* arr.copyWithin( 2, 0, 2 );\n*\n* var v = arr[ 2 ];\n* // returns 1.0\n*\n* v = arr[ 3 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'copyWithin', function copyWithin( target, start ) {\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\t// FIXME: prefer a functional `copyWithin` implementation which addresses lack of universal browser support (e.g., IE11 and Safari) or ensure that typed arrays are polyfilled\n\tif ( arguments.length === 2 ) {\n\t\tthis._buffer.copyWithin( target, start );\n\t} else {\n\t\tthis._buffer.copyWithin( target, start, arguments[2] );\n\t}\n\treturn this;\n});\n\n/**\n* Returns an iterator for iterating over array key-value pairs.\n*\n* @name entries\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] );\n*\n* var it = arr.entries();\n*\n* var v = it.next().value;\n* // returns [ 0, 1.0 ]\n*\n* v = it.next().value;\n* // returns [ 1, 2.0 ]\n*\n* v = it.next().value;\n* // returns [ 2, 3.0 ]\n*\n* var bool = it.next().done;\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'entries', function entries() {\n\tvar self;\n\tvar iter;\n\tvar len;\n\tvar buf;\n\tvar FLG;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tself = this;\n\tbuf = this._buffer;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': [ i, fromWord( buf[ i ] ) ],\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.entries();\n\t}\n});\n\n/**\n* Tests whether all elements in an array pass a test implemented by a predicate function.\n*\n* @name every\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {boolean} boolean indicating whether all elements pass a test\n*\n* @example\n* function predicate( v ) {\n* return v === 0.0;\n* }\n*\n* var arr = new Float16Array( 3 );\n*\n* var bool = arr.every( predicate );\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'every', function every( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( !predicate.call( thisArg, fromWord( buf[ i ] ), i, this ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n});\n\n/**\n* Returns a modified typed array filled with a fill value.\n*\n* @name fill\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {number} value - fill value\n* @param {integer} [start=0] - starting index (inclusive)\n* @param {integer} [end] - ending index (exclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a floating-point number\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be an integer\n* @returns {Float16Array} modified array\n*\n* @example\n* var arr = new Float16Array( 3 );\n*\n* arr.fill( 1.0, 1 );\n*\n* var v = arr[ 0 ];\n* // returns 0.0\n*\n* v = arr[ 1 ];\n* // returns 1.0\n*\n* v = arr[ 2 ];\n* // returns 1.0\n*/\nsetReadOnly( Float16Array.prototype, 'fill', function fill( value, start, end ) {\n\tvar buf;\n\tvar len;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNumber( value ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a number. Value: `%s`.', value ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( start ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', start ) );\n\t\t}\n\t\tif ( start < 0 ) {\n\t\t\tstart += len;\n\t\t\tif ( start < 0 ) {\n\t\t\t\tstart = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length > 2 ) {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t} else {\n\t\t\tend = len;\n\t\t}\n\t} else {\n\t\tstart = 0;\n\t\tend = len;\n\t}\n\tv = toWord( value );\n\tfor ( i = start; i < end; i++ ) {\n\t\tbuf[ i ] = v;\n\t}\n\treturn this;\n});\n\n/**\n* Returns a new array containing the elements of an array which pass a test implemented by a predicate function.\n*\n* @name filter\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {Float16Array} floating-point number array\n*\n* @example\n* function predicate( v ) {\n* return ( v === 0.0 );\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] );\n*\n* var out = arr.filter( predicate );\n* // returns \n*\n* var len = out.length;\n* // returns 2\n*\n* var v = out[ 0 ];\n* // returns 0.0\n*\n* v = out[ 1 ];\n* // returns 0.0\n*/\nsetReadOnly( Float16Array.prototype, 'filter', function filter( predicate, thisArg ) {\n\tvar buf;\n\tvar out;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\tout.push( v );\n\t\t}\n\t}\n\treturn new this.constructor( out );\n});\n\n/**\n* Returns the first element in an array for which a predicate function returns a truthy value.\n*\n* @name find\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {(boolean|void)} array element or undefined\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] );\n*\n* var v = arr.find( predicate );\n* // returns 1.0\n*/\nsetReadOnly( Float16Array.prototype, 'find', function find( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn v;\n\t\t}\n\t}\n});\n\n/**\n* Returns the index of the first element in an array for which a predicate function returns a truthy value.\n*\n* @name findIndex\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {integer} index or -1\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var v = arr.findIndex( predicate );\n* // returns 1\n*/\nsetReadOnly( Float16Array.prototype, 'findIndex', function findIndex( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Returns the last element in an array for which a predicate function returns a truthy value.\n*\n* @name findLast\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {(boolean|void)} array element or undefined\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] );\n*\n* var v = arr.findLast( predicate );\n* // returns 1.0\n*/\nsetReadOnly( Float16Array.prototype, 'findLast', function findLast( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = this._length-1; i >= 0; i-- ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn v;\n\t\t}\n\t}\n});\n\n/**\n* Returns the index of the last element in an array for which a predicate function returns a truthy value.\n*\n* @name findLastIndex\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {integer} index or -1\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] );\n*\n* var v = arr.findLastIndex( predicate );\n* // returns 1\n*/\nsetReadOnly( Float16Array.prototype, 'findLastIndex', function findLastIndex( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = this._length-1; i >= 0; i-- ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Invokes a function once for each array element.\n*\n* @name forEach\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} fcn - function to invoke\n* @param {*} [thisArg] - function invocation context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n*\n* @example\n* function log( v, i ) {\n* console.log( '%s: %s', i, v.toString() );\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* arr.forEach( log );\n*/\nsetReadOnly( Float16Array.prototype, 'forEach', function forEach( fcn, thisArg ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( fcn ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tfcn.call( thisArg, fromWord( buf[ i ] ), i, this );\n\t}\n});\n\n/**\n* Returns an array element.\n*\n* @private\n* @name _get\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {NonNegativeInteger} idx - element index\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} must provide a nonnegative integer\n* @returns {(number|void)} array element\n*/\nsetReadOnly( Float16Array.prototype, '_get', function get( idx ) {\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNonNegativeInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a nonnegative integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx >= this._length ) {\n\t\treturn;\n\t}\n\treturn fromWord( this._buffer[ idx ] );\n});\n\n/**\n* Returns a boolean indicating whether an array includes a provided value.\n*\n* @name includes\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {number} searchElement - search element\n* @param {integer} [fromIndex=0] - starting index (inclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a floating-point number\n* @throws {TypeError} second argument must be an integer\n* @returns {boolean} boolean indicating whether an array includes a value\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] );\n*\n* var bool = arr.includes( 1.0 );\n* // returns true\n*\n* bool = arr.includes( 1.0, 2 );\n* // returns false\n*\n* bool = arr.includes( 5.0 );\n* // returns false\n*/\nsetReadOnly( Float16Array.prototype, 'includes', function includes( searchElement, fromIndex ) {\n\tvar buf;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNumber( searchElement ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a number. Value: `%s`.', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\tfromIndex = 0;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfromIndex = 0;\n\t}\n\tbuf = this._buffer;\n\tv = toWord( searchElement );\n\tfor ( i = fromIndex; i < this._length; i++ ) {\n\t\tif ( v === buf[ i ] ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n});\n\n/**\n* Returns the first index at which a given element can be found.\n*\n* @name indexOf\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {float16} searchElement - element to find\n* @param {integer} [fromIndex=0] - starting index (inclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a floating-point number\n* @throws {TypeError} second argument must be an integer\n* @returns {integer} index or -1\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] );\n*\n* var idx = arr.indexOf( 2.0 );\n* // returns 2\n*\n* idx = arr.indexOf( 2.0, 3 );\n* // returns -1\n*\n* idx = arr.indexOf( 3.0, 3 );\n* // returns 3\n*/\nsetReadOnly( Float16Array.prototype, 'indexOf', function indexOf( searchElement, fromIndex ) {\n\tvar buf;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNumber( searchElement ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a number. Value: `%s`.', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\tfromIndex = 0;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfromIndex = 0;\n\t}\n\tbuf = this._buffer;\n\tv = toWord( searchElement );\n\tfor ( i = fromIndex; i < this._length; i++ ) {\n\t\tif ( v === buf[ i ] ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Returns a new string by concatenating all array elements.\n*\n* @name join\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {string} [separator=','] - element separator\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a string\n* @returns {string} string representation\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var str = arr.join();\n* // returns '0,1,2'\n*\n* str = arr.join( '|' );\n* // returns '0|1|2'\n*/\nsetReadOnly( Float16Array.prototype, 'join', function join( separator ) {\n\tvar buf;\n\tvar out;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( arguments.length > 0 ) {\n\t\tif ( !isString( separator ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', separator ) );\n\t\t}\n\t} else {\n\t\tseparator = ',';\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( fromWord( buf[ i ] ) );\n\t}\n\treturn out.join( separator );\n});\n\n/**\n* Returns an iterator for iterating over each index key in a typed array.\n*\n* @name keys\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new Float16Array( [ 1.0, 2.0 ] );\n*\n* var iter = arr.keys();\n*\n* var v = iter.next().value;\n* // returns 0\n*\n* v = iter.next().value;\n* // returns 1\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'keys', function keys() {\n\tvar self;\n\tvar iter;\n\tvar len;\n\tvar FLG;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tself = this;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': i,\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.keys();\n\t}\n});\n\n/**\n* Returns the last index at which a given element can be found.\n*\n* @name lastIndexOf\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {number} searchElement - element to find\n* @param {integer} [fromIndex] - starting index (inclusive)\n* @throws {TypeError} `this` must be a floating-point number\n* @throws {TypeError} first argument must be a numeric value\n* @throws {TypeError} second argument must be an integer\n* @returns {integer} index or -1\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 2.0 ] );\n*\n* var idx = arr.lastIndexOf( 2.0 );\n* // returns 4\n*\n* idx = arr.lastIndexOf( 2.0, 3 );\n* // returns 2\n*\n* idx = arr.lastIndexOf( 4.0, 3 );\n* // returns -1\n*\n* idx = arr.lastIndexOf( 1.0, -3 );\n* // returns 1\n*/\nsetReadOnly( Float16Array.prototype, 'lastIndexOf', function lastIndexOf( searchElement, fromIndex ) {\n\tvar buf;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNumber( searchElement ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a number. Value: `%s`.', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex >= this._length ) {\n\t\t\tfromIndex = this._length - 1;\n\t\t} else if ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t}\n\t} else {\n\t\tfromIndex = this._length - 1;\n\t}\n\tbuf = this._buffer;\n\tv = toWord( searchElement );\n\tfor ( i = fromIndex; i >= 0; i-- ) {\n\t\tif ( v === buf[ i ] ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Number of array elements.\n*\n* @name length\n* @memberof Float16Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var len = arr.length;\n* // returns 10\n*/\nsetReadOnlyAccessor( Float16Array.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Returns a new array with each element being the result of a provided callback function.\n*\n* @name map\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} fcn - callback function\n* @param {*} [thisArg] - callback function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {Float16Array} new floating-point number array\n*\n* @example\n* function scale( v ) {\n* return v * 2.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var out = arr.map( scale );\n* // returns \n*\n* var z = out[ 0 ];\n* // returns 0.0\n*\n* z = out[ 1 ];\n* // returns 2.0\n*\n* z = out[ 2 ];\n* // returns 4.0\n*/\nsetReadOnly( Float16Array.prototype, 'map', function map( fcn, thisArg ) {\n\tvar outbuf;\n\tvar out;\n\tvar buf;\n\tvar i;\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( fcn ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be a function. Value: `%s`.', fcn );\n\t}\n\tbuf = this._buffer;\n\tout = new this.constructor( this._length );\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\toutbuf[ i ] = toWord( fcn.call( thisArg, fromWord( buf[ i ] ), i, this ) ); // eslint-disable-line max-len\n\t}\n\treturn out;\n});\n\n/**\n* Applies a provided callback function to each element of the array, in order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion.\n*\n* @name reduce\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} reducer - callback function\n* @param {*} [initialValue] - initial value\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {Error} if not provided an initial value, the array must have at least one element\n* @returns {*} accumulated result\n*\n* @example\n* function add( acc, v ) {\n* return acc + v;\n* }\n*\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] );\n*\n* var out = arr.reduce( add, 0 );\n* // returns 6.0\n*/\nsetReadOnly( Float16Array.prototype, 'reduce', function reduce( reducer, initialValue ) {\n\tvar buf;\n\tvar len;\n\tvar acc;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( reducer ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', reducer ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tacc = initialValue;\n\t\ti = 0;\n\t} else {\n\t\tif ( len === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' );\n\t\t}\n\t\tacc = fromWord( buf[ 0 ] );\n\t\ti = 1;\n\t}\n\tfor ( ; i < len; i++ ) {\n\t\tacc = reducer( acc, fromWord( buf[ i ] ), i, this );\n\t}\n\treturn acc;\n});\n\n/**\n* Applies a provided callback function to each element of the array, in reverse order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion.\n*\n* @name reduceRight\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} reducer - callback function\n* @param {*} [initialValue] - initial value\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {Error} if not provided an initial value, the array must have at least one element\n* @returns {*} accumulated result\n*\n* @example\n* function add( acc, v ) {\n* return acc + v;\n* }\n*\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] );\n*\n* var out = arr.reduceRight( add, 0 );\n* // returns 6.0\n*/\nsetReadOnly( Float16Array.prototype, 'reduceRight', function reduceRight( reducer, initialValue ) {\n\tvar buf;\n\tvar len;\n\tvar acc;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( reducer ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', reducer ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tacc = initialValue;\n\t\ti = len - 1;\n\t} else {\n\t\tif ( len === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' );\n\t\t}\n\t\tacc = fromWord( buf[ len-1 ] );\n\t\ti = len - 2;\n\t}\n\tfor ( ; i >= 0; i-- ) {\n\t\tacc = reducer( acc, fromWord( buf[ i ] ), i, this );\n\t}\n\treturn acc;\n});\n\n/**\n* Reverses an array in-place.\n*\n* @name reverse\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Float16Array} reversed array\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var out = arr.reverse();\n* // returns \n*\n* var v = out[ 0 ];\n* // returns 2.0\n*\n* v = out[ 1 ];\n* // returns 1.0\n*\n* v = out[ 2 ];\n* // returns 0.0\n*/\nsetReadOnly( Float16Array.prototype, 'reverse', function reverse() {\n\tvar buf;\n\tvar tmp;\n\tvar len;\n\tvar N;\n\tvar i;\n\tvar j;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tN = floor( len / 2 );\n\tfor ( i = 0; i < N; i++ ) {\n\t\tj = len - i - 1;\n\t\ttmp = buf[ i ];\n\t\tbuf[ i ] = buf[ j ];\n\t\tbuf[ j ] = tmp;\n\t}\n\treturn this;\n});\n\n/**\n* Sets one or more array elements.\n*\n* ## Notes\n*\n* - When provided a typed array, we must check whether the source array shares the same buffer as the target array and whether the underlying memory overlaps. In particular, we are concerned with the following scenario:\n*\n* ```text\n* buf: ---------------------\n* src: ---------------------\n* ```\n*\n* In the above, as we copy values from `src`, we will overwrite values in the `src` view, resulting in duplicated values copied into the end of `buf`, which is not intended. Hence, to avoid overwriting source values, we must **copy** source values to a temporary array.\n*\n* In the other overlapping scenario,\n*\n* ```text\n* buf: ---------------------\n* src: ---------------------\n* ```\n*\n* by the time we begin copying into the overlapping region, we are copying from the end of `src`, a non-overlapping region, which means we don't run the risk of copying copied values, rather than the original `src` values, as intended.\n*\n* @name set\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {(Collection|Float16Array)} value - value(s)\n* @param {NonNegativeInteger} [i=0] - element index at which to start writing values\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a collection\n* @throws {TypeError} index argument must be a nonnegative integer\n* @throws {RangeError} index argument is out-of-bounds\n* @throws {RangeError} target array lacks sufficient storage to accommodate source values\n* @returns {void}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var v = arr[ 0 ];\n* // returns 0.0\n*\n* arr.set( [ 1.0, 2.0 ], 0 );\n*\n* v = arr[ 0 ];\n* // returns 1.0\n*/\nsetReadOnly( Float16Array.prototype, 'set', function set( value ) {\n\tvar sbuf;\n\tvar idx;\n\tvar buf;\n\tvar tmp;\n\tvar flg;\n\tvar N;\n\tvar i;\n\tvar j;\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isCollection( value ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', value ) );\n\t}\n\tbuf = this._buffer;\n\tif ( arguments.length > 1 ) {\n\t\tidx = arguments[ 1 ];\n\t\tif ( !isNonNegativeInteger( idx ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Index argument must be a nonnegative integer. Value: `%s`.', idx ) );\n\t\t}\n\t} else {\n\t\tidx = 0;\n\t}\n\tN = value.length;\n\tif ( idx+N > this._length ) {\n\t\tthrow new RangeError( 'invalid arguments. Target array lacks sufficient storage to accommodate source values.' );\n\t}\n\tif ( isFloat16Array( value ) ) {\n\t\tsbuf = value._buffer; // eslint-disable-line no-underscore-dangle\n\t\tflg = true;\n\t} else {\n\t\tsbuf = value;\n\t\tflg = false;\n\t}\n\t// Check for overlapping memory...\n\tj = buf.byteOffset + (idx*BYTES_PER_ELEMENT);\n\tif (\n\t\tsbuf.buffer === buf.buffer &&\n\t\t(\n\t\t\tsbuf.byteOffset < j &&\n\t\t\tsbuf.byteOffset+sbuf.byteLength > j\n\t\t)\n\t) {\n\t\t// We need to copy source values...\n\t\ttmp = new Uint16Array( sbuf.length );\n\t\tfor ( i = 0; i < sbuf.length; i++ ) {\n\t\t\ttmp[ i ] = sbuf[ i ];\n\t\t}\n\t\tsbuf = tmp;\n\t}\n\tif ( flg ) {\n\t\tfor ( i = 0; i < N; idx++, i++ ) {\n\t\t\tbuf[ idx ] = sbuf[ i ];\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < N; idx++, i++ ) {\n\t\t\tbuf[ idx ] = toWord( sbuf[ i ] );\n\t\t}\n\t}\n});\n\n/**\n* Copies a portion of a typed array to a new typed array.\n*\n* @name slice\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} [begin] - start index (inclusive)\n* @param {integer} [end] - end index (exclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be integer\n* @throws {TypeError} second argument must be integer\n* @returns {Float16Array} floating-point number array\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] );\n*\n* var out = arr.slice();\n* // returns \n*\n* var len = out.length;\n* // returns 5\n*\n* var v = out[ 0 ];\n* // returns 0.0\n*\n* v = out[ len-1 ];\n* // returns 4.0\n*\n* out = arr.slice( 1, -2 );\n* // returns \n*\n* len = out.length;\n* // returns 2\n*\n* v = out[ 0 ];\n* // returns 1.0\n*\n* v = out[ len-1 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'slice', function slice( begin, end ) {\n\tvar outlen;\n\tvar outbuf;\n\tvar out;\n\tvar buf;\n\tvar len;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length === 0 ) {\n\t\tbegin = 0;\n\t\tend = len;\n\t} else {\n\t\tif ( !isInteger( begin ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', begin ) );\n\t\t}\n\t\tif ( begin < 0 ) {\n\t\t\tbegin += len;\n\t\t\tif ( begin < 0 ) {\n\t\t\t\tbegin = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\tend = len;\n\t\t} else {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t} else if ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t}\n\t}\n\tif ( begin < end ) {\n\t\toutlen = end - begin;\n\t} else {\n\t\toutlen = 0;\n\t}\n\tout = new this.constructor( outlen );\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < outlen; i++ ) {\n\t\toutbuf[ i ] = buf[ i+begin ];\n\t}\n\treturn out;\n});\n\n/**\n* Tests whether at least one element in an array passes a test implemented by a predicate function.\n*\n* @name some\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {boolean} boolean indicating whether at least one element passes a test\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var bool = arr.some( predicate );\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'some', function some( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( predicate.call( thisArg, fromWord( buf[ i ] ), i, this ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n});\n\n/**\n* Sorts an array in-place.\n*\n* @name sort\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} [compareFcn] - comparison function\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {Float16Array} sorted array\n*\n* @example\n* function compare( a, b ) {\n* if ( a < b ) {\n* return -1;\n* }\n* if ( a > b ) {\n* return 1;\n* }\n* return 0;\n* }\n*\n* var arr = new Float16Array( [ 1.0, 0.0, 2.0 ] );\n*\n* arr.sort( compare );\n*\n* var v = arr[ 0 ];\n* // returns 0.0\n*\n* v = arr[ 1 ];\n* // returns 1.0\n*\n* v = arr[ 2 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'sort', function sort( compareFcn ) {\n\tvar buf;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tif ( arguments.length === 0 ) {\n\t\tbuf.sort( defaultCompare );\n\t\treturn this;\n\t}\n\tif ( !isFunction( compareFcn ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', compareFcn ) );\n\t}\n\tbuf.sort( compare );\n\treturn this;\n\n\t/**\n\t* Default comparison function for float16 values.\n\t*\n\t* @private\n\t* @param {unsigned16} a - unsigned 16-bit integer for comparison\n\t* @param {unsigned16} b - unsigned 16-bit integer for comparison\n\t* @returns {number} comparison result\n\t*/\n\tfunction defaultCompare( a, b ) { // eslint-disable-line stdlib/no-unnecessary-nested-functions\n\t\tvar x = fromWord( a );\n\t\tvar y = fromWord( b );\n\n\t\t// Handle NaN...\n\t\tif ( isnan( x ) && isnan( y ) ) {\n\t\t\treturn 0;\n\t\t}\n\t\tif ( isnan( x ) ) {\n\t\t\treturn 1;\n\t\t}\n\t\tif ( isnan( y ) ) {\n\t\t\treturn -1;\n\t\t}\n\t\t// Normal comparison\n\t\tif ( x < y ) {\n\t\t\treturn -1;\n\t\t}\n\t\tif ( x > y ) {\n\t\t\treturn 1;\n\t\t}\n\t\treturn 0;\n\t}\n\n\t/**\n\t* Comparison function wrapper.\n\t*\n\t* @private\n\t* @param {unsigned16} a - unsigned 16-bit integer for comparison\n\t* @param {unsigned16} b - unsigned 16-bit integer for comparison\n\t* @returns {number} comparison result\n\t*/\n\tfunction compare( a, b ) {\n\t\treturn compareFcn( fromWord( a ), fromWord( b ) );\n\t}\n});\n\n/**\n* Creates a new typed array view over the same underlying `ArrayBuffer` and with the same underlying data type as the host array.\n*\n* @name subarray\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} [begin] - start index (inclusive)\n* @param {integer} [end] - end index (exclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be an integer\n* @throws {TypeError} second argument must be an integer\n* @returns {Float16Array} subarray\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] );\n*\n* var subarr = arr.subarray();\n* // returns \n*\n* var len = subarr.length;\n* // returns 5\n*\n* var bool = subarr[ 0 ];\n* // returns 0.0\n*\n* bool = subarr[ len-1 ];\n* // returns 4.0\n*\n* subarr = arr.subarray( 1, -2 );\n* // returns \n*\n* len = subarr.length;\n* // returns 2\n*\n* bool = subarr[ 0 ];\n* // returns 1.0\n*\n* bool = subarr[ len-1 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'subarray', function subarray( begin, end ) {\n\tvar offset;\n\tvar buf;\n\tvar len;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length === 0 ) {\n\t\tbegin = 0;\n\t\tend = len;\n\t} else {\n\t\tif ( !isInteger( begin ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', begin ) );\n\t\t}\n\t\tif ( begin < 0 ) {\n\t\t\tbegin += len;\n\t\t\tif ( begin < 0 ) {\n\t\t\t\tbegin = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\tend = len;\n\t\t} else {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t} else if ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t}\n\t}\n\tif ( begin >= len ) {\n\t\tlen = 0;\n\t\toffset = buf.byteLength;\n\t} else if ( begin >= end ) {\n\t\tlen = 0;\n\t\toffset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT );\n\t} else {\n\t\tlen = end - begin;\n\t\toffset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT );\n\t}\n\treturn new this.constructor( buf.buffer, offset, ( len < 0 ) ? 0 : len );\n});\n\n/**\n* Serializes an array as a locale-specific string.\n*\n* @name toLocaleString\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {(string|Array)} [locales] - locale identifier(s)\n* @param {Object} [options] - configuration options\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a string or an array of strings\n* @throws {TypeError} options argument must be an object\n* @returns {string} string representation\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var str = arr.toLocaleString();\n* // returns '0,1,2'\n*/\nsetReadOnly( Float16Array.prototype, 'toLocaleString', function toLocaleString( locales, options ) {\n\tvar opts;\n\tvar loc;\n\tvar out;\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( arguments.length === 0 ) {\n\t\tloc = [];\n\t} else if ( isString( locales ) || isStringArray( locales ) ) {\n\t\tloc = locales;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a string or an array of strings. Value: `%s`.', locales ) );\n\t}\n\tif ( arguments.length < 2 ) {\n\t\topts = {};\n\t} else if ( isObject( options ) ) {\n\t\topts = options;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( fromWord( buf[ i ] ) );\n\t}\n\treturn out.toLocaleString( loc, opts );\n});\n\n/**\n* Returns a new typed array containing the elements in reversed order.\n*\n* @name toReversed\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Float16Array} reversed array\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var out = arr.toReversed();\n* // returns \n*\n* var v = out[ 0 ];\n* // returns 2.0\n*\n* v = out[ 1 ];\n* // returns 1.0\n*\n* v = out[ 2 ];\n* // returns 0.0\n*/\nsetReadOnly( Float16Array.prototype, 'toReversed', function toReversed() {\n\tvar outbuf;\n\tvar out;\n\tvar len;\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tlen = this._length;\n\tout = new this.constructor( len );\n\tbuf = this._buffer;\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < len; i++ ) {\n\t\toutbuf[ i ] = buf[ len - i - 1 ];\n\t}\n\treturn out;\n});\n\n/**\n* Returns a new typed array containing the elements in sorted order.\n*\n* @name toSorted\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} [compareFcn] - comparison function\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {Float16Array} sorted array\n*\n* @example\n* function compare( a, b ) {\n* if ( a > b ) {\n* return 1;\n* }\n* if ( a < b ) {\n* return -1;\n* }\n* return 0;\n* }\n*\n* var arr = new Float16Array( [ 2.0, 0.0, 1.0 ] );\n*\n* var out = arr.toSorted( compare );\n* // returns \n*\n* var v = out[ 0 ];\n* // returns 0.0\n*\n* v = out[ 1 ];\n* // returns 1.0\n*\n* v = out[ 2 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'toSorted', function toSorted( compareFcn ) {\n\tvar out;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tout = new this.constructor( this );\n\tif ( arguments.length === 0 ) {\n\t\treturn out.sort();\n\t}\n\treturn out.sort( compareFcn );\n});\n\n/**\n* Serializes an array as a string.\n*\n* @name toString\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {string} string representation\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var str = arr.toString();\n* // returns '0,1,2'\n*/\nsetReadOnly( Float16Array.prototype, 'toString', function toString() {\n\tvar out;\n\tvar buf;\n\tvar i;\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( fromWord( buf[ i ] ) );\n\t}\n\treturn out.join( ',' );\n});\n\n/**\n* Returns an iterator for iterating over each value in a typed array.\n*\n* @name values\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0 ] );\n*\n* var iter = arr.values();\n*\n* var v = iter.next().value;\n* // returns 0.0\n*\n* v = iter.next().value;\n* // returns 1.0\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'values', function values() {\n\tvar iter;\n\tvar self;\n\tvar len;\n\tvar FLG;\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tself = this;\n\tbuf = this._buffer;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': fromWord( buf[ i ] ),\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.values();\n\t}\n});\n\n/**\n* Returns a new typed array with the element at a provided index replaced with a provided value.\n*\n* @name with\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} index - element index\n* @param {number} value - new value\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be an integer\n* @throws {RangeError} index argument is out-of-bounds\n* @throws {TypeError} second argument must be a floating-point number\n* @returns {Float16Array} new typed array\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var out = arr.with( 0, 3.0 );\n* // returns \n*\n* var v = out[ 0 ];\n* // returns 3.0\n*/\nsetReadOnly( Float16Array.prototype, 'with', function copyWith( index, value ) {\n\tvar out;\n\tvar len;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isInteger( index ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', index ) );\n\t}\n\tlen = this._length;\n\tif ( index < 0 ) {\n\t\tindex += len;\n\t}\n\tif ( index < 0 || index >= len ) {\n\t\tthrow new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%s`.', index ) );\n\t}\n\tif ( !isNumber( value ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a floating-point number. Value: `%s`.', value ) );\n\t}\n\tout = new this.constructor( this );\n\tout[ index ] = value;\n\treturn out;\n});\n\n\n// EXPORTS //\n\nmodule.exports = Float16Array;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Float16Array === 'function' ) ? Float16Array : void 0; // eslint-disable-line no-undef, stdlib/require-globals\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* 16-bit floating-point number array constructor.\n*\n* @module @stdlib/array-float16\n*\n* @example\n* var Float16Array = require( '@stdlib/array-float16' );\n*\n* var arr = new Float16Array();\n* // returns \n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var Float16Array = require( '@stdlib/array-float16' );\n*\n* var arr = new Float16Array( 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var Float16Array = require( '@stdlib/array-float16' );\n*\n* var arr = new Float16Array( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var Float16Array = require( '@stdlib/array-float16' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float16Array( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 8\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var Float16Array = require( '@stdlib/array-float16' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float16Array( buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 4\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var Float16Array = require( '@stdlib/array-float16' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Float16Array( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\n\n// MODULES //\n\nvar hasFloat16ArraySupport = require( '@stdlib/assert-has-float16array-support' );\nvar polyfill = require( './polyfill' );\nvar builtin = require( './main.js' );\n\n\n// MAIN //\n\nvar ctor;\nif ( hasFloat16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n"], - "mappings": "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", - "names": ["require_from_array", "__commonJSMin", "exports", "module", "f16", "toWord", "fromArray", "buf", "arr", "len", "require_from_iterator", "__commonJSMin", "exports", "module", "f16", "toWord", "fromIterator", "it", "out", "v", "require_from_iterator_map", "__commonJSMin", "exports", "module", "f16", "toWord", "fromIteratorMap", "it", "clbk", "thisArg", "out", "v", "i", "require_polyfill", "__commonJSMin", "exports", "module", "hasIteratorSymbolSupport", "isNonNegativeInteger", "isStringArray", "isCollection", "isArrayBuffer", "isFunction", "isInteger", "isNumber", "isString", "isObject", "isnan", "ITERATOR_SYMBOL", "setReadOnlyAccessor", "setReadOnly", "setReadWriteAccessor", "floor", "format", "Uint16Array", "f16", "toWord", "fromWord", "gcopy", "fromArray", "fromIterator", "fromIteratorMap", "BYTES_PER_ELEMENT", "HAS_ITERATOR_SYMBOL", "isFloat16Array", "value", "isFloatingPointArrayConstructor", "Float16Array", "getter", "ctx", "idx", "get", "setter", "set", "byteOffset", "nargs", "buf", "len", "arg", "i", "src", "thisArg", "clbk", "out", "tmp", "args", "target", "start", "self", "iter", "FLG", "next", "end", "factory", "predicate", "v", "fcn", "searchElement", "fromIndex", "separator", "outbuf", "reducer", "initialValue", "acc", "N", "j", "sbuf", "flg", "begin", "outlen", "compareFcn", "defaultCompare", "compare", "a", "b", "x", "y", "offset", "locales", "options", "opts", "loc", "index", "require_main", "__commonJSMin", "exports", "module", "ctor", "hasFloat16ArraySupport", "polyfill", "builtin", "ctor"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index e311742..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,1222 +0,0 @@ - -{{alias}}() - A 16-bit half-precision floating-point number array. - - Returns - ------- - out: Float16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Creates a half-precision floating-point number array having a specified - length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: Float16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - - > var len = arr.length - 5 - - -{{alias}}( typedarray ) - Creates a half-precision floating-point number array from a typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate a half-precision floating-point - number array. - - Returns - ------- - out: Float16Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/float64}}( [ 0.5, 0.5, 0.5 ] ) - - > var arr = new {{alias}}( buf ) - - > var len = arr.length - 3 - - -{{alias}}( obj ) - Creates a half-precision floating-point number array from an array-like - object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a half-precision - floating-point number array. - - Returns - ------- - out: Float16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( [ 0.5, 0.5, 0.5 ] ) - - > var len = arr.length - 3 - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a half-precision floating-point number array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - Returns - ------- - out: Float16Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 8 ); - > var arr1 = new {{alias}}( buf ) - - > var len = arr1.length - 4 - > var arr2 = new {{alias}}( buf, 2 ) - - > len = arr2.length - 3 - > var arr3 = new {{alias}}( buf, 2, 2 ) - - > len = arr3.length - 2 - - -{{alias}}.from( src[, clbk[, thisArg]] ) - Creates a new half-precision floating-point number array from an array-like - object or an iterable. - - A callback function is provided two arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - clbk: Function (optional) - Callback to invoke for each source element. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Float16Array - A typed array. - - Examples - -------- - > function clbkFcn( v ) { return v * 2.0 }; - > var arr = {{alias}}.from( [ 1.0, -1.0 ], clbkFcn ) - - > var len = arr.length - 2 - > var v = arr[ 0 ] - 2.0 - > v = arr[ 1 ] - -2.0 - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new half-precision floating-point number array from a variable - number of arguments. - - Parameters - ---------- - element0: number - Array element. - - element1: number (optional) - Array element. - - elementN: ...number (optional) - Array elements. - - Returns - ------- - out: Float16Array - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( 1.0, -1.0 ) - - > var len = arr.length - 2 - > var v = arr[ 0 ] - 1.0 - > v = arr[ 1 ] - -1.0 - - -{{alias}}.BYTES_PER_ELEMENT - The size of each array element in bytes. - - Examples - -------- - > var nbytes = {{alias}}.BYTES_PER_ELEMENT - 2 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > var str = {{alias}}.name - 'Float16Array' - - -{{alias}}.prototype.buffer - Pointer to the underlying data buffer. - - Examples - -------- - > var arr = new {{alias}}( 2 ) - - > var buf = arr.buffer - - - -{{alias}}.prototype.byteLength - Length of the array in bytes. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - - > var nbytes = arr.byteLength - 10 - - -{{alias}}.prototype.byteOffset - Offset (in bytes) of the array from the start of its underlying ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - - > var offset = arr.byteOffset - 0 - > var buf = new {{alias:@stdlib/array/buffer}}( 20 ); - > arr = new {{alias}}( buf, 10 ) - - > offset = arr.byteOffset - 10 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each array element. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - - > arr.BYTES_PER_ELEMENT - 2 - - -{{alias}}.prototype.length - The number of array elements. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - - > var len = arr.length - 5 - - -{{alias}}.prototype.at( i ) - Returns an array element located at integer position (index) `i`, with - support for both nonnegative and negative integer positions. - - If provided an index outside the array index range, the method returns - `undefined`. - - Parameters - ---------- - i: integer - Element index. - - Returns - ------- - out: float|void - An array element. - - Examples - -------- - > var arr = new {{alias}}( [ 10.0, 20.0, 30.0 ] ) - - > var v = arr.at( 0 ) - 10.0 - > v = arr.at( -1 ) - 30.0 - - -{{alias}}.prototype.copyWithin( target, start[, end] ) - Copies a sequence of elements within the array starting at `start` and - ending at `end` (non-inclusive) to the position starting at `target`. - - Parameters - ---------- - target: integer - Target start index position. - - start: integer - Source start index position. - - end: integer (optional) - Source end index position. Default: out.length. - - Returns - ------- - out: Float16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ) - - > arr.copyWithin( 0, 3 ) - - > var v = arr[ 0 ] - 4.0 - > v = arr[ 1 ] - 5.0 - - -{{alias}}.prototype.entries() - Returns an iterator for iterating over array key-value pairs. - - Returns - ------- - iterator: Iterator - Iterator for iterating over array key-value pairs. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var it = arr.entries(); - > var v = it.next().value - [ 0, 1.0 ] - > v = it.next().value - [ 1, 2.0 ] - > v = it.next().value - [ 2, 3.0 ] - > var bool = it.next().done - true - - -{{alias}}.prototype.every( predicate[, thisArg] ) - Returns a boolean indicating whether all elements in the array pass a test. - - A predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether all elements pass the test. - - Examples - -------- - > function predicate( v ) { return ( v > 0.0 ); }; - > var arr = new {{alias}}( [ 1.0, 2.0 ] ) - - > var bool = arr.every( predicate ) - true - - -{{alias}}.prototype.fill( value[, start[, end]] ) - Returns a modified typed array filled with a fill value. - - Parameters - ---------- - value: number - Fill value. - - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Float16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( 3 ) - - > arr.fill( 2.0 ); - > var v = arr[ 0 ] - 2.0 - > v = arr[ 1 ] - 2.0 - > v = arr[ 2 ] - 2.0 - - -{{alias}}.prototype.filter( predicate[, thisArg] ) - Returns a new array containing the elements of an array which pass a test - implemented by a predicate function. - - A predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - The returned array has the same data type as the host array. - - Parameters - ---------- - predicate: Function - Predicate function which filters array elements. If a predicate function - returns a truthy value, an array element is included in the output - array; otherwise, an array element is not included in the output array. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - out: Float16Array - A new typed array. - - Examples - -------- - > function predicate( v ) { return ( v > 1.0 ); }; - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var out = arr.filter( predicate ) - - > var len = out.length - 2 - > var v = out[ 0 ] - 2.0 - > v = out[ 1 ] - 3.0 - - -{{alias}}.prototype.find( predicate[, thisArg] ) - Returns the first element in an array for which a predicate function - returns a truthy value. - - A predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - out: number|void - Array element or `undefined`. - - Examples - -------- - > function predicate( v ) { return ( v > 1.0 ); }; - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var v = arr.find( predicate ) - 2.0 - - -{{alias}}.prototype.findIndex( predicate[, thisArg] ) - Returns the index of the first element in an array for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - out: integer - Array index or `-1`. - - Examples - -------- - > function predicate( v ) { return ( v > 2.0 ); }; - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var idx = arr.findIndex( predicate ) - 2 - - -{{alias}}.prototype.findLast( predicate[, thisArg] ) - Returns the last element in an array for which a predicate function returns - a truthy value. - - A predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - out: number|void - Array element or `undefined`. - - Examples - -------- - > function predicate( v ) { return ( v > 1.0 ); }; - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var v = arr.findLast( predicate ) - 3.0 - - -{{alias}}.prototype.findLastIndex( predicate[, thisArg] ) - Returns the index of the last element in an array for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - out: integer - Array index or `-1`. - - Examples - -------- - > function predicate( v ) { return ( v > 1.0 ); }; - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var idx = arr.findLastIndex( predicate ) - 2 - - -{{alias}}.prototype.forEach( clbk[, thisArg] ) - Invokes a function once for each array element. - - A callback function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - Parameters - ---------- - clbk: Function - Function to invoke for each array element. - - thisArg: Any (optional) - Execution context. - - Examples - -------- - > var str = '%'; - > function clbk( v ) { str += v.toString() + '%'; }; - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > arr.forEach( clbk ); - > str - '%1%2%3%' - - -{{alias}}.prototype.includes( searchElement[, fromIndex] ) - Returns a boolean indicating whether an array includes a provided value. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index at which to start the search. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - bool: boolean - Boolean indicating whether an array includes a search element. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var bool = arr.includes( 3.0 ) - true - > bool = arr.includes( 3.0, 3 ) - false - - -{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) - Returns the first index at which a given element can be found. - - If method does not find a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index at which to start the search. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - out: integer - Array index or `-1`. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var idx = arr.indexOf( 2.0 ) - 1 - > idx = arr.indexOf( 2.0, 2 ) - -1 - - -{{alias}}.prototype.join( [separator] ) - Returns a new string by concatenating all array elements separated by a - separator string. - - Parameters - ---------- - separator: string (optional) - Separator string. Default: ','. - - Returns - ------- - out: string - Array serialized as a string. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var str = arr.join() - '1,2,3' - > str = arr.join( '|' ) - '1|2|3' - - -{{alias}}.prototype.keys() - Returns an iterator for iterating over each index key in a typed array. - - Returns - ------- - iterator: Iterator - Iterator for iterating over array index keys. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0 ] ) - - > var it = arr.keys(); - > var v = it.next().value - 0 - > v = it.next().value - 1 - > v = it.next().done - true - - -{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) - Returns the last index at which a given element can be found. - - If method does not find a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index at which to start the search. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: out.length-1. - - Returns - ------- - out: integer - Array index or `-1`. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0, 1.0 ] ) - - > var idx = arr.lastIndexOf( 1.0 ) - 3 - > idx = arr.lastIndexOf( 1.0, 2 ) - 0 - - -{{alias}}.prototype.map( clbk[, thisArg] ) - Returns a new array with each element being the result of a provided - callback function. - - A callback function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - The returned array has the same data type as the host array. - - Parameters - ---------- - clbk: Function - Function which maps array elements to elements in the new array. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - out: Float16Array - A new typed array. - - Examples - -------- - > function clbk( v ) { return v * 2.0; }; - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var out = arr.map( clbk ) - - > var v = out[ 0 ] - 2.0 - > v = out[ 1 ] - 4.0 - > v = out[ 2 ] - 6.0 - - -{{alias}}.prototype.reduce( reducerFn[, initialValue] ) - Applies a provided function to each element of the array, in order, passing - in the return value from the calculation on the preceding element and - returning the accumulated result upon completion. - - A reducer function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the first array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the first array element as the first argument and the second array - element as the second argument. - - Parameters - ---------- - reducerFn: Function - Function to apply to each array element. - - initialValue: any (optional) - Initial accumulation value. - - Returns - ------- - out: any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > function reducerFn( acc, v ) { return acc + v; }; - > var v = arr.reduce( reducerFn, 0.0 ) - 6.0 - - -{{alias}}.prototype.reduceRight( reducerFn[, initialValue] ) - Applies a provided function to each element of the array, in reverse order, - passing in the return value from the calculation on the preceding element - and returning the accumulated result upon completion. - - A reducer function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the last array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the last array element as the first argument and the second-to-last - array element as the second argument. - - Parameters - ---------- - reducerFn: Function - Function to apply to each array element. - - initialValue: any (optional) - Initial accumulation value. - - Returns - ------- - out: any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > function reducerFn( acc, v ) { return acc + v; }; - > var v = arr.reduceRight( reducerFn, 0.0 ) - 6.0 - - -{{alias}}.prototype.reverse() - Reverses the array *in-place*. - - This method mutates the array on which the method is invoked. - - Returns - ------- - out: Float16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > arr.reverse(); - > var v = arr[ 0 ] - 3.0 - > v = arr[ 1 ] - 2.0 - > v = arr[ 2 ] - 1.0 - - -{{alias}}.prototype.set( arr[, offset] ) - Sets one or more array elements. - - If provided a single argument, the method sets array elements starting at - position (index) `i = 0`. To set elements starting elsewhere in the array, - provide an offset argument. - - Parameters - ---------- - arr: ArrayLike - Source array containing array values to set. - - offset: integer (optional) - Array index at which to start writing values. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > arr.set( [ 4.0, 5.0 ], 1 ); - > var v = arr[ 0 ] - 1.0 - > v = arr[ 1 ] - 4.0 - > v = arr[ 2 ] - 5.0 - - -{{alias}}.prototype.slice( [start[, end]] ) - Copies a portion of a typed array to a new typed array. - - Parameters - ---------- - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Float16Array - New typed array. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var out = arr.slice( 1 ) - - > var len = out.length - 2 - > var v = out[ 0 ] - 2.0 - > v = out[ 1 ] - 3.0 - - -{{alias}}.prototype.some( predicate[, thisArg] ) - Returns a boolean indicating whether at least one element passes a test. - - A predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether at least one element passes the test. - - Examples - -------- - > function predicate( v ) { return ( v > 2.0 ); }; - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var bool = arr.some( predicate ) - true - - -{{alias}}.prototype.sort( [compareFunction] ) - Sorts an array in-place. - - A comparison function determines the order of the array elements. The - function is provided two arguments: - - - a: first element for comparison. - - b: second element for comparison. - - The function should return a value less than zero if `a` comes before `b`, - a value greater than zero if `a` comes after `b`, and zero if `a` and `b` - are equivalent. - - Parameters - ---------- - compareFunction: Function (optional) - Comparison function. - - Returns - ------- - out: Float16Array - Modified array. - - Examples - -------- - > function compare( a, b ) { return a - b; }; - > var arr = new {{alias}}( [ 2.0, 3.0, 1.0 ] ) - - > arr.sort( compare ); - > var v = arr[ 0 ] - 1.0 - > v = arr[ 1 ] - 2.0 - > v = arr[ 2 ] - 3.0 - - -{{alias}}.prototype.subarray( [begin[, end]] ) - Creates a new typed array view over the same underlying `ArrayBuffer` and - with the same underlying data type as the host array. - - Parameters - ---------- - begin: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Float16Array - New typed array view. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ) - - > var out = arr.subarray( 1, 3 ) - - > var len = out.length - 2 - > var v = out[ 0 ] - 2.0 - > v = out[ 1 ] - 3.0 - - -{{alias}}.prototype.toLocaleString( [locales[, options]] ) - Serializes an array as a locale-specific string. - - Parameters - ---------- - locales: string|Array (optional) - Locale identifier(s). - - options: Object (optional) - An object containing serialization options. - - Returns - ------- - str: string - Local-specific string. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var str = arr.toLocaleString() - '1,2,3' - - -{{alias}}.prototype.toReversed() - Returns a new typed array containing the elements in reversed order. - - Returns - ------- - out: Float16Array - New typed array. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var out = arr.toReversed() - - > var v = out[ 0 ] - 3.0 - > v = out[ 1 ] - 2.0 - > v = out[ 2 ] - 1.0 - - -{{alias}}.prototype.toSorted( [compareFcn] ) - Returns a new typed array containing the elements in sorted order. - - A comparison function determines the order of the array elements. The - function is provided two arguments: - - - a: first element for comparison. - - b: second element for comparison. - - The function should return a value less than zero if `a` comes before `b`, - a value greater than zero if `a` comes after `b`, and zero if `a` and `b` - are equivalent. - - Parameters - ---------- - compareFcn: Function (optional) - Comparison function. - - Returns - ------- - out: Float16Array - New typed array. - - Examples - -------- - > function compare( a, b ) { return a - b; }; - > var arr = new {{alias}}( [ 2.0, 3.0, 1.0 ] ) - - > var out = arr.toSorted( compare ); - > var v = out[ 0 ] - 1.0 - > v = out[ 1 ] - 2.0 - > v = out[ 2 ] - 3.0 - - -{{alias}}.prototype.toString() - Serializes an array as a string. - - Returns - ------- - str: string - String serialization of the array. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var str = arr.toString() - '1,2,3' - - -{{alias}}.prototype.values() - Returns an iterator for iterating over each value in a typed array. - - Returns - ------- - iterator: Iterator - Iterator for iterating over array values. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0 ] ) - - > var it = arr.values(); - > var v = it.next().value - 1.0 - > v = it.next().value - 2.0 - > var bool = it.next().done - true - - -{{alias}}.prototype.with( index, value ) - Returns a new typed array with the element at a provided index replaced with - a provided value. - - Parameters - ---------- - index: integer - Element index. - - value: number - Element value. - - Returns - ------- - out: Float16Array - New typed array. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var out = arr.with( 1, 4.0 ) - - > var v = out[ 1 ] - 4.0 - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 033057e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,129 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2026 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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ArrayBuffer = require( '@stdlib/array-buffer' ); -import Float16Array = require( './index' ); - -/** -* Callback function. -* -* @param v - value -* @returns input value -*/ -function clbk( v: number ): number { - return v; -} - - -// TESTS // - -// The function returns a half-precision floating-point number array... -{ - new Float16Array(); // $ExpectType Float16Array - new Float16Array( 2 ); // $ExpectType Float16Array - new Float16Array( [ 1.0, -1.0 ] ); // $ExpectType Float16Array - - const buf = new ArrayBuffer( 16 ); - new Float16Array( buf ); // $ExpectType Float16Array - new Float16Array( buf, 8 ); // $ExpectType Float16Array - new Float16Array( buf, 8, 2 ); // $ExpectType Float16Array -} - -// The compiler throws an error if the function is provided a first argument that is not a number, typed array, array-like object, or array buffer... -{ - new Float16Array( true ); // $ExpectError - new Float16Array( false ); // $ExpectError - new Float16Array( null ); // $ExpectError - new Float16Array( 'abc' ); // $ExpectError - new Float16Array( {} ); // $ExpectError - new Float16Array( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument that is not a number... -{ - const buf = new ArrayBuffer( 16 ); - new Float16Array( buf, true ); // $ExpectError - new Float16Array( buf, false ); // $ExpectError - new Float16Array( buf, null ); // $ExpectError - new Float16Array( buf, 'abc' ); // $ExpectError - new Float16Array( buf, {} ); // $ExpectError - new Float16Array( buf, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument that is not a number... -{ - const buf = new ArrayBuffer( 16 ); - new Float16Array( buf, 8, true ); // $ExpectError - new Float16Array( buf, 8, false ); // $ExpectError - new Float16Array( buf, 8, null ); // $ExpectError - new Float16Array( buf, 8, 'abc' ); // $ExpectError - new Float16Array( buf, 8, {} ); // $ExpectError - new Float16Array( buf, 8, ( x: number ): number => x ); // $ExpectError -} - -// The `from` method returns a half-precision floating-point number array... -{ - Float16Array.from( [ 1.0, 1.0 ] ); // $ExpectType Float16Array - Float16Array.from( [ 1.0, 1.0 ], ( x: number ): number => x * x ); // $ExpectType Float16Array - Float16Array.from( [ 1.0 ], clbk, {} ); // $ExpectType Float16Array -} - -// The compiler throws an error if the `from` method is provided a first argument which is not array-like or iterable... -{ - Float16Array.from( true ); // $ExpectError - Float16Array.from( false ); // $ExpectError - Float16Array.from( 123 ); // $ExpectError - Float16Array.from( null ); // $ExpectError - Float16Array.from( {} ); // $ExpectError - - Float16Array.from( true, clbk ); // $ExpectError - Float16Array.from( false, clbk ); // $ExpectError - Float16Array.from( 123, clbk ); // $ExpectError - Float16Array.from( null, clbk ); // $ExpectError - Float16Array.from( {}, clbk ); // $ExpectError - - Float16Array.from( true, clbk, {} ); // $ExpectError - Float16Array.from( false, clbk, {} ); // $ExpectError - Float16Array.from( 123, clbk, {} ); // $ExpectError - Float16Array.from( null, clbk, {} ); // $ExpectError - Float16Array.from( {}, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the `from` method is provided a second argument which is not a function with a supported signature... -{ - Float16Array.from( [ 1.0, 1.0 ], true ); // $ExpectError - Float16Array.from( [ 1.0, 1.0 ], false ); // $ExpectError - Float16Array.from( [ 1.0, 1.0 ], 123 ); // $ExpectError - Float16Array.from( [ 1.0, 1.0 ], null ); // $ExpectError - Float16Array.from( [ 1.0, 1.0 ], {} ); // $ExpectError -} - -// The `of` method returns a half-precision floating-point number array... -{ - Float16Array.of( 1.0, 1.0, 1.0, 1.0 ); // $ExpectType Float16Array -} - -// The compiler throws an error if the `of` method is provided arguments that are not numbers... -{ - Float16Array.of( 'abc', 'def' ); // $ExpectError - Float16Array.of( true, false ); // $ExpectError - Float16Array.of( {}, [] ); // $ExpectError - Float16Array.of( null, null ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a5c84ca..0000000 --- a/examples/index.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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'; - -var Uint16Array = require( '@stdlib/array-uint16' ); -var logEach = require( '@stdlib/console-log-each' ); -var Float16Array = require( './../lib' ); - -// Create a half-precision floating-point number array by specifying a length: -var out = new Float16Array( 3 ); -logEach( '%s', out ); - -// Create a half-precision floating-point number array from an array of numbers: -var arr = [ 1.05, 2.05, 3.05 ]; -out = new Float16Array( arr ); -logEach( '%s', out ); - -// Create a half-precision floating-point number array from an array buffer: -arr = new Uint16Array( [ 1000, 2000, 3000, 4000 ] ); -out = new Float16Array( arr.buffer ); -logEach( '%s', out ); - -// Create a half-precision floating-point number array from an array buffer view: -arr = new Uint16Array( [ 1000, 2000, 3000, 4000 ] ); -out = new Float16Array( arr.buffer, 2, 2 ); -logEach( '%s', out ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 001159c..ed52b06 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { Iterator as Iter, IterableIterator, TypedIterator } from '@stdlib/types/iter'; import { ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..16ac68e --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-float16array-support@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.3-esm/index.mjs";import{isPrimitive as n}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.3-esm/index.mjs";import{primitives as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string-array@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.3-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.3-esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.3-esm/index.mjs";import{isPrimitive as h}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.3-esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.3-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-assert-is-nan@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.4-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.3-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@v0.2.4-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint16@v0.2.3-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-float16@v0.1.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float16-base-to-word@v0.1.1-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float16-base-from-word@v0.2.1-esm/index.mjs";import T from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-base-gcopy@v0.2.3-esm/index.mjs";function _(t){var r,n;for(r=[];!(n=t.next()).done;)r.push(b(m(n.value)));return r}var j=g.BYTES_PER_ELEMENT,x=r();function L(t){return"object"==typeof t&&null!==t&&"Float16Array"===t.constructor.name&&t.BYTES_PER_ELEMENT===j}function R(t){return t===A}function O(t,r){return function(){return t._get(r)}}function S(t,r){return function(n){t.set([n],r)}}function A(){var t,r,i,h,l,u;if(r=arguments.length,!(this instanceof A))return 0===r?new A:1===r?new A(arguments[0]):2===r?new A(arguments[0],arguments[1]):new A(arguments[0],arguments[1],arguments[2]);if(0===r)i=new g(0);else if(1===r)if(n(l=arguments[0]))i=new g(l);else if(e(l))L(l)?(i=new g(l.length),T.ndarray(l.length,new g(l.buffer,l.byteOffset,l.length),1,0,i,1,0)):i=function(t,r){var n,i;for(n=r.length,i=0;ii.byteLength-t)throw new RangeError(d("null2G",h*j));i=new g(i,t,h)}}for(y(this,"_buffer",i),y(this,"_length",i.length),u=0;u1){if(!s(i=arguments[1]))throw new TypeError(d("null2H",i));n>2&&(r=arguments[2])}if(e(t)){if(i){for(f=(o=new this(l=t.length))._buffer,u=0;u=this._length))return E(this._buffer[t])})),w(A.prototype,"buffer",(function(){return this._buffer.buffer})),w(A.prototype,"byteLength",(function(){return this._buffer.byteLength})),w(A.prototype,"byteOffset",(function(){return this._buffer.byteOffset})),y(A.prototype,"BYTES_PER_ELEMENT",A.BYTES_PER_ELEMENT),y(A.prototype,"copyWithin",(function(t,r){if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");return 2===arguments.length?this._buffer.copyWithin(t,r):this._buffer.copyWithin(t,r,arguments[2]),this})),y(A.prototype,"entries",(function(){var t,r,n,i,e,o;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");return t=this,i=this._buffer,n=this._length,o=-1,y(r={},"next",(function(){if(o+=1,e||o>=n)return{done:!0};return{value:[o,E(i[o])],done:!1}})),y(r,"return",(function(t){if(e=!0,arguments.length)return{value:t,done:!0};return{done:!0}})),p&&y(r,p,(function(){return t.entries()})),r})),y(A.prototype,"every",(function(t,r){var n,i;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!s(t))throw new TypeError(d("null3c",t));for(n=this._buffer,i=0;i1){if(!f(r))throw new TypeError(d("null7f",r));if(r<0&&(r+=e)<0&&(r=0),arguments.length>2){if(!f(n))throw new TypeError(d("null2z",n));n<0&&(n+=e)<0&&(n=0),n>e&&(n=e)}else n=e}else r=0,n=e;for(s=b(t),o=r;o=0;e--)if(i=E(n[e]),t.call(r,i,e,this))return i})),y(A.prototype,"findLastIndex",(function(t,r){var n,i,e;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!s(t))throw new TypeError(d("null3c",t));for(n=this._buffer,e=this._length-1;e>=0;e--)if(i=E(n[e]),t.call(r,i,e,this))return e;return-1})),y(A.prototype,"forEach",(function(t,r){var n,i;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!s(t))throw new TypeError(d("null3c",t));for(n=this._buffer,i=0;i=this._length))return E(this._buffer[t])})),y(A.prototype,"includes",(function(t,r){var n,i,e;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!h(t))throw new TypeError(d("null49",t));if(arguments.length>1){if(!f(r))throw new TypeError(d("null7f",r));r<0&&(r+=this._length)<0&&(r=0)}else r=0;for(n=this._buffer,e=b(t),i=r;i1){if(!f(r))throw new TypeError(d("null7f",r));r<0&&(r+=this._length)<0&&(r=0)}else r=0;for(n=this._buffer,e=b(t),i=r;i0){if(!l(t))throw new TypeError(d("null3F",t))}else t=",";for(r=this._buffer,n=[],i=0;i=n)return{done:!0};return{value:e,done:!1}})),y(r,"return",(function(t){if(i=!0,arguments.length)return{value:t,done:!0};return{done:!0}})),p&&y(r,p,(function(){return t.keys()})),r})),y(A.prototype,"lastIndexOf",(function(t,r){var n,i,e;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!h(t))throw new TypeError(d("null49",t));if(arguments.length>1){if(!f(r))throw new TypeError(d("null7f",r));r>=this._length?r=this._length-1:r<0&&(r+=this._length)}else r=this._length-1;for(n=this._buffer,e=b(t),i=r;i>=0;i--)if(e===n[i])return i;return-1})),w(A.prototype,"length",(function(){return this._length})),y(A.prototype,"map",(function(t,r){var n,i,e,o;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!s(t))throw new TypeError(d("null3c"),t);for(e=this._buffer,n=(i=new this.constructor(this._length))._buffer,o=0;o1)e=r,o=0;else{if(0===i)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");e=E(n[0]),o=1}for(;o1)e=r,o=i-1;else{if(0===i)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");e=E(n[i-1]),o=i-2}for(;o>=0;o--)e=t(e,E(n[o]),o,this);return e})),y(A.prototype,"reverse",(function(){var t,r,n,i,e,o;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");for(t=this._buffer,n=this._length,i=v(n/2),e=0;e1){if(!n(i=arguments[1]))throw new TypeError(d("null2L",i))}else i=0;if(i+(h=t.length)>this._length)throw new RangeError(d("null03"));if(L(t)?(r=t._buffer,f=!0):(r=t,f=!1),a=o.byteOffset+i*j,r.buffer===o.buffer&&r.byteOffseta){for(s=new g(r.length),l=0;ls&&(r=s)}}for(n=ti)return 1;return 0})),this;if(!s(t))throw new TypeError(d("null3c",t));return r.sort((function(r,n){return t(E(r),E(n))})),this})),y(A.prototype,"subarray",(function(t,r){var n,i,e;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(i=this._buffer,e=this._length,0===arguments.length)t=0,r=e;else{if(!f(t))throw new TypeError(d("null7e",t));if(t<0&&(t+=e)<0&&(t=0),1===arguments.length)r=e;else{if(!f(r))throw new TypeError(d("null7f",r));r<0?(r+=e)<0&&(r=0):r>e&&(r=e)}}return t>=e?(e=0,n=i.byteLength):t>=r?(e=0,n=i.byteOffset+t*j):(e=r-t,n=i.byteOffset+t*j),new this.constructor(i.buffer,n,e<0?0:e)})),y(A.prototype,"toLocaleString",(function(t,r){var n,e,o,s,f;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(0===arguments.length)e=[];else{if(!l(t)&&!i(t))throw new TypeError(d("invalid argument. First argument must be a string or an array of strings. Value: `%s`.",t));e=t}if(arguments.length<2)n={};else{if(!a(r))throw new TypeError(d("null2V",r));n=r}for(s=this._buffer,o=[],f=0;f=n)return{done:!0};return{value:E(e[o]),done:!1}})),y(t,"return",(function(t){if(i=!0,arguments.length)return{value:t,done:!0};return{done:!0}})),p&&y(t,p,(function(){return r.values()})),t})),y(A.prototype,"with",(function(t,r){var n,i;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!f(t))throw new TypeError(d("null7e",t));if(i=this._length,t<0&&(t+=i),t<0||t>=i)throw new RangeError(d("nullFP",t));if(!h(r))throw new TypeError(d("invalid argument. Second argument must be a floating-point number. Value: `%s`.",r));return(n=new this.constructor(this))[t]=r,n}));var P="function"==typeof Float16Array?Float16Array:void 0,F=t()?P:A;export{F as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..d0d8a32 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/polyfill/from_iterator.js","../lib/polyfill/index.js","../lib/polyfill/from_array.js","../lib/polyfill/from_iterator_map.js","../lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport f16 from '@stdlib/number-float64-base-to-float16';\nimport toWord from '@stdlib/number-float16-base-to-word';\n\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @returns {Array} output array\n*/\nfunction fromIterator( it ) {\n\tvar out;\n\tvar v;\n\n\tout = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tout.push( toWord( f16( v.value ) ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIterator;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this, stdlib/jsdoc-typedef-typos, max-lines */\n\n'use strict';\n\n// MODULES //\n\nimport hasIteratorSymbolSupport from '@stdlib/assert-has-iterator-symbol-support';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport { primitives as isStringArray } from '@stdlib/assert-is-string-array';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isFunction from '@stdlib/assert-is-function';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isObject from '@stdlib/assert-is-object';\nimport isnan from '@stdlib/math-base-assert-is-nan';\nimport ITERATOR_SYMBOL from '@stdlib/symbol-iterator';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadWriteAccessor from '@stdlib/utils-define-read-write-accessor';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport Uint16Array from '@stdlib/array-uint16';\nimport f16 from '@stdlib/number-float64-base-to-float16';\nimport toWord from '@stdlib/number-float16-base-to-word';\nimport fromWord from '@stdlib/number-float16-base-from-word';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport fromArray from './from_array.js';\nimport fromIterator from './from_iterator.js';\nimport fromIteratorMap from './from_iterator_map.js';\n\n\n// VARIABLES //\n\nvar BYTES_PER_ELEMENT = Uint16Array.BYTES_PER_ELEMENT;\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\n\n\n// FUNCTIONS //\n\n/**\n* Returns a boolean indicating if a value is a `Float16Array`.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `Float16Array`\n*/\nfunction isFloat16Array( value ) {\n\treturn (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\tvalue.constructor.name === 'Float16Array' &&\n\t\tvalue.BYTES_PER_ELEMENT === BYTES_PER_ELEMENT\n\t);\n}\n\n/**\n* Returns a boolean indicating if a value is a floating-point typed array constructor.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a floating-point typed array constructor\n*/\nfunction isFloatingPointArrayConstructor( value ) { // eslint-disable-line id-length\n\treturn ( value === Float16Array );\n}\n\n/**\n* Returns a getter.\n*\n* @private\n* @param {Float16Array} ctx - typed array instance\n* @param {NonNegativeInteger} idx - element index\n* @returns {Function} getter\n*/\nfunction getter( ctx, idx ) {\n\treturn get;\n\n\t/**\n\t* Returns an array element.\n\t*\n\t* @private\n\t* @returns {(number|void)} array element\n\t*/\n\tfunction get() {\n\t\treturn ctx._get( idx ); // eslint-disable-line no-underscore-dangle\n\t}\n}\n\n/**\n* Returns a setter.\n*\n* @private\n* @param {Float16Array} ctx - typed array instance\n* @param {NonNegativeInteger} idx - element index\n* @returns {Function} setter\n*/\nfunction setter( ctx, idx ) {\n\treturn set;\n\n\t/**\n\t* Sets an array element.\n\t*\n\t* @private\n\t* @param {number} value - value to set\n\t*/\n\tfunction set( value ) {\n\t\tctx.set( [ value ], idx );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* 16-bit floating-point number array constructor.\n*\n* @constructor\n* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable\n* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n* @param {NonNegativeInteger} [length] - view length\n* @throws {RangeError} ArrayBuffer byte length must be a multiple of `2`\n* @throws {TypeError} if provided only a single argument, must provide a valid argument\n* @throws {TypeError} byte offset must be a nonnegative integer\n* @throws {RangeError} byte offset must be a multiple of `2`\n* @throws {TypeError} view length must be a positive multiple of `2`\n* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n* @returns {Float16Array} half-precision floating-point number array\n*\n* @example\n* var arr = new Float16Array();\n* // returns \n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var arr = new Float16Array( 5 );\n* // returns \n*\n* var len = arr.length;\n* // returns 5\n*\n* @example\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 5\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float16Array( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 8\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float16Array( buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 4\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Float16Array( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nfunction Float16Array() {\n\tvar byteOffset;\n\tvar nargs;\n\tvar buf;\n\tvar len;\n\tvar arg;\n\tvar i;\n\n\tnargs = arguments.length;\n\tif ( !(this instanceof Float16Array) ) {\n\t\tif ( nargs === 0 ) {\n\t\t\treturn new Float16Array();\n\t\t}\n\t\tif ( nargs === 1 ) {\n\t\t\treturn new Float16Array( arguments[0] );\n\t\t}\n\t\tif ( nargs === 2 ) {\n\t\t\treturn new Float16Array( arguments[0], arguments[1] );\n\t\t}\n\t\treturn new Float16Array( arguments[0], arguments[1], arguments[2] );\n\t}\n\t// Create the underlying data buffer...\n\tif ( nargs === 0 ) {\n\t\tbuf = new Uint16Array( 0 ); // backward-compatibility\n\t} else if ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\t\tif ( isNonNegativeInteger( arg ) ) {\n\t\t\tbuf = new Uint16Array( arg );\n\t\t} else if ( isCollection( arg ) ) {\n\t\t\tif ( isFloat16Array( arg ) ) {\n\t\t\t\tbuf = new Uint16Array( arg.length );\n\t\t\t\tgcopy.ndarray( arg.length, new Uint16Array( arg.buffer, arg.byteOffset, arg.length ), 1, 0, buf, 1, 0 ); // eslint-disable-line max-len\n\t\t\t} else {\n\t\t\t\tbuf = fromArray( new Uint16Array( arg.length ), arg );\n\t\t\t}\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tif ( !isInteger( arg.byteLength/BYTES_PER_ELEMENT ) ) {\n\t\t\t\tthrow new RangeError( format( 'nullE9', BYTES_PER_ELEMENT, arg.byteLength ) );\n\t\t\t}\n\t\t\tbuf = new Uint16Array( arg );\n\t\t} else if ( isObject( arg ) ) {\n\t\t\tif ( HAS_ITERATOR_SYMBOL === false ) {\n\t\t\t\tthrow new TypeError( format( 'null29', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2A', arg ) );\n\t\t\t}\n\t\t\tbuf = arg[ ITERATOR_SYMBOL ]();\n\t\t\tif ( !isFunction( buf.next ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2A', arg ) );\n\t\t\t}\n\t\t\tbuf = new Uint16Array( fromIterator( buf ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( 'null2A', arg ) );\n\t\t}\n\t} else {\n\t\tbuf = arguments[ 0 ];\n\t\tif ( !isArrayBuffer( buf ) ) {\n\t\t\tthrow new TypeError( format( 'null2B', buf ) );\n\t\t}\n\t\tbyteOffset = arguments[ 1 ];\n\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\tthrow new TypeError( format( 'null2C', byteOffset ) );\n\t\t}\n\t\tif ( !isInteger( byteOffset/BYTES_PER_ELEMENT ) ) {\n\t\t\tthrow new RangeError( format( 'nullEA', BYTES_PER_ELEMENT, byteOffset ) );\n\t\t}\n\t\tif ( nargs === 2 ) {\n\t\t\tlen = buf.byteLength - byteOffset;\n\t\t\tif ( !isInteger( len/BYTES_PER_ELEMENT ) ) {\n\t\t\t\tthrow new RangeError( format( 'null2E', BYTES_PER_ELEMENT, len ) );\n\t\t\t}\n\t\t\tbuf = new Uint16Array( buf, byteOffset );\n\t\t} else {\n\t\t\tlen = arguments[ 2 ];\n\t\t\tif ( !isNonNegativeInteger( len ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2F', len ) );\n\t\t\t}\n\t\t\tif ( (len*BYTES_PER_ELEMENT) > (buf.byteLength-byteOffset) ) {\n\t\t\t\tthrow new RangeError( format( 'null2G', len*BYTES_PER_ELEMENT ) );\n\t\t\t}\n\t\t\tbuf = new Uint16Array( buf, byteOffset, len );\n\t\t}\n\t}\n\tsetReadOnly( this, '_buffer', buf );\n\tsetReadOnly( this, '_length', buf.length );\n\tfor ( i = 0; i < buf.length; i++ ) {\n\t\tsetReadWriteAccessor( this, i, getter( this, i ), setter( this, i ) );\n\t}\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each array element.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Float16Array\n* @readonly\n* @type {PositiveInteger}\n* @default 2\n*\n* @example\n* var nbytes = Float16Array.BYTES_PER_ELEMENT;\n* // returns 2\n*/\nsetReadOnly( Float16Array, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT );\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof Float16Array\n* @readonly\n* @type {string}\n* @default 'Float16Array'\n*\n* @example\n* var str = Float16Array.name;\n* // returns 'Float16Array'\n*/\nsetReadOnly( Float16Array, 'name', 'Float16Array' );\n\n/**\n* Creates a new 16-bit floating-point number array from an array-like object or an iterable.\n*\n* @name from\n* @memberof Float16Array\n* @type {Function}\n* @param {(Collection|Iterable)} src - array-like object or iterable\n* @param {Function} [clbk] - callback to invoke for each source element\n* @param {*} [thisArg] - context\n* @throws {TypeError} `this` context must be a constructor\n* @throws {TypeError} `this` must be a floating-point array\n* @throws {TypeError} first argument must be an array-like object or an iterable\n* @throws {TypeError} second argument must be a function\n* @returns {Float16Array} half-precision floating-point number array\n*\n* @example\n* var arr = Float16Array.from( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* function clbk( v ) {\n* return v * 2.0;\n* }\n*\n* var arr = Float16Array.from( [ 1.0, 2.0 ], clbk );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nsetReadOnly( Float16Array, 'from', function from( src ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar clbk;\n\tvar out;\n\tvar buf;\n\tvar tmp;\n\tvar len;\n\tvar i;\n\tif ( !isFunction( this ) ) {\n\t\tthrow new TypeError( format('null01') );\n\t}\n\tif ( !isFloatingPointArrayConstructor( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point array.' );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs > 1 ) {\n\t\tclbk = arguments[ 1 ];\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'null2H', clbk ) );\n\t\t}\n\t\tif ( nargs > 2 ) {\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( isCollection( src ) ) {\n\t\tif ( clbk ) {\n\t\t\tlen = src.length;\n\t\t\tout = new this( len );\n\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tbuf[ i ] = toWord( f16( clbk.call( thisArg, src[ i ], i ) ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\treturn new this( src );\n\t}\n\tif ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) { // eslint-disable-line max-len\n\t\tbuf = src[ ITERATOR_SYMBOL ]();\n\t\tif ( !isFunction( buf.next ) ) {\n\t\t\tthrow new TypeError( format( 'null2J', src ) );\n\t\t}\n\t\tif ( clbk ) {\n\t\t\ttmp = fromIteratorMap( buf, clbk, thisArg );\n\t\t} else {\n\t\t\ttmp = fromIterator( buf );\n\t\t}\n\t\tif ( tmp instanceof Error ) {\n\t\t\tthrow tmp;\n\t\t}\n\t\tlen = tmp.length;\n\t\tout = new this( len );\n\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tbuf[ i ] = tmp[ i ];\n\t\t}\n\t\treturn out;\n\t}\n\tthrow new TypeError( format( 'null2J', src ) );\n});\n\n/**\n* Creates a new 16-bit floating-point number array from a variable number of arguments.\n*\n* @name of\n* @memberof Float16Array\n* @type {Function}\n* @param {...*} element - array elements\n* @throws {TypeError} `this` context must be a constructor\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Float16Array} half-precision floating-point number array\n*\n* @example\n* var arr = Float16Array.of( 1.0, 1.0, 1.0, 1.0 );\n* // returns \n*\n* var x = arr[ 0 ];\n* // returns 1.0\n*\n* var len = arr.length;\n* // returns 4\n*/\nsetReadOnly( Float16Array, 'of', function of() {\n\tvar args;\n\tvar i;\n\tif ( !isFunction( this ) ) {\n\t\tthrow new TypeError( format('null01') );\n\t}\n\tif ( !isFloatingPointArrayConstructor( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\targs = [];\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\targs.push( arguments[ i ] );\n\t}\n\treturn new this( args );\n});\n\n/**\n* Returns an array element with support for both nonnegative and negative integer indices.\n*\n* @name at\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} must provide an integer\n* @returns {(number|void)} array element\n*\n* @example\n* var arr = new Float16Array( [ 10.0, 20.0, 30.0 ] );\n*\n* var v = arr.at( 0 );\n* // returns 10.0\n*\n* v = arr.at( -1 );\n* // returns 30.0\n*\n* v = arr.at( 100 );\n* // returns undefined\n*/\nsetReadOnly( Float16Array.prototype, 'at', function at( idx ) {\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'null8A', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += this._length;\n\t}\n\tif ( idx < 0 || idx >= this._length ) {\n\t\treturn;\n\t}\n\treturn fromWord( this._buffer[ idx ] );\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name buffer\n* @memberof Float16Array.prototype\n* @readonly\n* @type {ArrayBuffer}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var buf = arr.buffer;\n* // returns \n*/\nsetReadOnlyAccessor( Float16Array.prototype, 'buffer', function get() {\n\treturn this._buffer.buffer;\n});\n\n/**\n* Size (in bytes) of the array.\n*\n* @name byteLength\n* @memberof Float16Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var byteLength = arr.byteLength;\n* // returns 20\n*/\nsetReadOnlyAccessor( Float16Array.prototype, 'byteLength', function get() {\n\treturn this._buffer.byteLength;\n});\n\n/**\n* Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`.\n*\n* @name byteOffset\n* @memberof Float16Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var byteOffset = arr.byteOffset;\n* // returns 0\n*/\nsetReadOnlyAccessor( Float16Array.prototype, 'byteOffset', function get() {\n\treturn this._buffer.byteOffset;\n});\n\n/**\n* Size (in bytes) of each array element.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Float16Array.prototype\n* @readonly\n* @type {PositiveInteger}\n* @default 2\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var nbytes = arr.BYTES_PER_ELEMENT;\n* // returns 2\n*/\nsetReadOnly( Float16Array.prototype, 'BYTES_PER_ELEMENT', Float16Array.BYTES_PER_ELEMENT );\n\n/**\n* Copies a sequence of elements within the array to the position starting at `target`.\n*\n* @name copyWithin\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} target - index at which to start copying elements\n* @param {integer} start - source index at which to copy elements from\n* @param {integer} [end] - source index at which to stop copying elements from\n* @throws {TypeError} `this` must be a floating-point array\n* @returns {Float16Array} modified array\n*\n* @example\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0 ] );\n*\n* // Copy the first two elements to the last two elements:\n* arr.copyWithin( 2, 0, 2 );\n*\n* var v = arr[ 2 ];\n* // returns 1.0\n*\n* v = arr[ 3 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'copyWithin', function copyWithin( target, start ) {\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\t// FIXME: prefer a functional `copyWithin` implementation which addresses lack of universal browser support (e.g., IE11 and Safari) or ensure that typed arrays are polyfilled\n\tif ( arguments.length === 2 ) {\n\t\tthis._buffer.copyWithin( target, start );\n\t} else {\n\t\tthis._buffer.copyWithin( target, start, arguments[2] );\n\t}\n\treturn this;\n});\n\n/**\n* Returns an iterator for iterating over array key-value pairs.\n*\n* @name entries\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] );\n*\n* var it = arr.entries();\n*\n* var v = it.next().value;\n* // returns [ 0, 1.0 ]\n*\n* v = it.next().value;\n* // returns [ 1, 2.0 ]\n*\n* v = it.next().value;\n* // returns [ 2, 3.0 ]\n*\n* var bool = it.next().done;\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'entries', function entries() {\n\tvar self;\n\tvar iter;\n\tvar len;\n\tvar buf;\n\tvar FLG;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tself = this;\n\tbuf = this._buffer;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': [ i, fromWord( buf[ i ] ) ],\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.entries();\n\t}\n});\n\n/**\n* Tests whether all elements in an array pass a test implemented by a predicate function.\n*\n* @name every\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {boolean} boolean indicating whether all elements pass a test\n*\n* @example\n* function predicate( v ) {\n* return v === 0.0;\n* }\n*\n* var arr = new Float16Array( 3 );\n*\n* var bool = arr.every( predicate );\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'every', function every( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( !predicate.call( thisArg, fromWord( buf[ i ] ), i, this ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n});\n\n/**\n* Returns a modified typed array filled with a fill value.\n*\n* @name fill\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {number} value - fill value\n* @param {integer} [start=0] - starting index (inclusive)\n* @param {integer} [end] - ending index (exclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a floating-point number\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be an integer\n* @returns {Float16Array} modified array\n*\n* @example\n* var arr = new Float16Array( 3 );\n*\n* arr.fill( 1.0, 1 );\n*\n* var v = arr[ 0 ];\n* // returns 0.0\n*\n* v = arr[ 1 ];\n* // returns 1.0\n*\n* v = arr[ 2 ];\n* // returns 1.0\n*/\nsetReadOnly( Float16Array.prototype, 'fill', function fill( value, start, end ) {\n\tvar buf;\n\tvar len;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNumber( value ) ) {\n\t\tthrow new TypeError( format( 'null49', value ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( start ) ) {\n\t\t\tthrow new TypeError( format( 'null7f', start ) );\n\t\t}\n\t\tif ( start < 0 ) {\n\t\t\tstart += len;\n\t\t\tif ( start < 0 ) {\n\t\t\t\tstart = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length > 2 ) {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2z', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t} else {\n\t\t\tend = len;\n\t\t}\n\t} else {\n\t\tstart = 0;\n\t\tend = len;\n\t}\n\tv = toWord( value );\n\tfor ( i = start; i < end; i++ ) {\n\t\tbuf[ i ] = v;\n\t}\n\treturn this;\n});\n\n/**\n* Returns a new array containing the elements of an array which pass a test implemented by a predicate function.\n*\n* @name filter\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {Float16Array} floating-point number array\n*\n* @example\n* function predicate( v ) {\n* return ( v === 0.0 );\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] );\n*\n* var out = arr.filter( predicate );\n* // returns \n*\n* var len = out.length;\n* // returns 2\n*\n* var v = out[ 0 ];\n* // returns 0.0\n*\n* v = out[ 1 ];\n* // returns 0.0\n*/\nsetReadOnly( Float16Array.prototype, 'filter', function filter( predicate, thisArg ) {\n\tvar buf;\n\tvar out;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\tout.push( v );\n\t\t}\n\t}\n\treturn new this.constructor( out );\n});\n\n/**\n* Returns the first element in an array for which a predicate function returns a truthy value.\n*\n* @name find\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {(boolean|void)} array element or undefined\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] );\n*\n* var v = arr.find( predicate );\n* // returns 1.0\n*/\nsetReadOnly( Float16Array.prototype, 'find', function find( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn v;\n\t\t}\n\t}\n});\n\n/**\n* Returns the index of the first element in an array for which a predicate function returns a truthy value.\n*\n* @name findIndex\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {integer} index or -1\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var v = arr.findIndex( predicate );\n* // returns 1\n*/\nsetReadOnly( Float16Array.prototype, 'findIndex', function findIndex( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Returns the last element in an array for which a predicate function returns a truthy value.\n*\n* @name findLast\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {(boolean|void)} array element or undefined\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] );\n*\n* var v = arr.findLast( predicate );\n* // returns 1.0\n*/\nsetReadOnly( Float16Array.prototype, 'findLast', function findLast( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = this._length-1; i >= 0; i-- ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn v;\n\t\t}\n\t}\n});\n\n/**\n* Returns the index of the last element in an array for which a predicate function returns a truthy value.\n*\n* @name findLastIndex\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {integer} index or -1\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] );\n*\n* var v = arr.findLastIndex( predicate );\n* // returns 1\n*/\nsetReadOnly( Float16Array.prototype, 'findLastIndex', function findLastIndex( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = this._length-1; i >= 0; i-- ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Invokes a function once for each array element.\n*\n* @name forEach\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} fcn - function to invoke\n* @param {*} [thisArg] - function invocation context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n*\n* @example\n* function log( v, i ) {\n* console.log( '%s: %s', i, v.toString() );\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* arr.forEach( log );\n*/\nsetReadOnly( Float16Array.prototype, 'forEach', function forEach( fcn, thisArg ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( fcn ) ) {\n\t\tthrow new TypeError( format( 'null3c', fcn ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tfcn.call( thisArg, fromWord( buf[ i ] ), i, this );\n\t}\n});\n\n/**\n* Returns an array element.\n*\n* @private\n* @name _get\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {NonNegativeInteger} idx - element index\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} must provide a nonnegative integer\n* @returns {(number|void)} array element\n*/\nsetReadOnly( Float16Array.prototype, '_get', function get( idx ) {\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNonNegativeInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'null2K', idx ) );\n\t}\n\tif ( idx >= this._length ) {\n\t\treturn;\n\t}\n\treturn fromWord( this._buffer[ idx ] );\n});\n\n/**\n* Returns a boolean indicating whether an array includes a provided value.\n*\n* @name includes\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {number} searchElement - search element\n* @param {integer} [fromIndex=0] - starting index (inclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a floating-point number\n* @throws {TypeError} second argument must be an integer\n* @returns {boolean} boolean indicating whether an array includes a value\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] );\n*\n* var bool = arr.includes( 1.0 );\n* // returns true\n*\n* bool = arr.includes( 1.0, 2 );\n* // returns false\n*\n* bool = arr.includes( 5.0 );\n* // returns false\n*/\nsetReadOnly( Float16Array.prototype, 'includes', function includes( searchElement, fromIndex ) {\n\tvar buf;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNumber( searchElement ) ) {\n\t\tthrow new TypeError( format( 'null49', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'null7f', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\tfromIndex = 0;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfromIndex = 0;\n\t}\n\tbuf = this._buffer;\n\tv = toWord( searchElement );\n\tfor ( i = fromIndex; i < this._length; i++ ) {\n\t\tif ( v === buf[ i ] ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n});\n\n/**\n* Returns the first index at which a given element can be found.\n*\n* @name indexOf\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {float16} searchElement - element to find\n* @param {integer} [fromIndex=0] - starting index (inclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a floating-point number\n* @throws {TypeError} second argument must be an integer\n* @returns {integer} index or -1\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] );\n*\n* var idx = arr.indexOf( 2.0 );\n* // returns 2\n*\n* idx = arr.indexOf( 2.0, 3 );\n* // returns -1\n*\n* idx = arr.indexOf( 3.0, 3 );\n* // returns 3\n*/\nsetReadOnly( Float16Array.prototype, 'indexOf', function indexOf( searchElement, fromIndex ) {\n\tvar buf;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNumber( searchElement ) ) {\n\t\tthrow new TypeError( format( 'null49', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'null7f', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\tfromIndex = 0;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfromIndex = 0;\n\t}\n\tbuf = this._buffer;\n\tv = toWord( searchElement );\n\tfor ( i = fromIndex; i < this._length; i++ ) {\n\t\tif ( v === buf[ i ] ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Returns a new string by concatenating all array elements.\n*\n* @name join\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {string} [separator=','] - element separator\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a string\n* @returns {string} string representation\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var str = arr.join();\n* // returns '0,1,2'\n*\n* str = arr.join( '|' );\n* // returns '0|1|2'\n*/\nsetReadOnly( Float16Array.prototype, 'join', function join( separator ) {\n\tvar buf;\n\tvar out;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( arguments.length > 0 ) {\n\t\tif ( !isString( separator ) ) {\n\t\t\tthrow new TypeError( format( 'null3F', separator ) );\n\t\t}\n\t} else {\n\t\tseparator = ',';\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( fromWord( buf[ i ] ) );\n\t}\n\treturn out.join( separator );\n});\n\n/**\n* Returns an iterator for iterating over each index key in a typed array.\n*\n* @name keys\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new Float16Array( [ 1.0, 2.0 ] );\n*\n* var iter = arr.keys();\n*\n* var v = iter.next().value;\n* // returns 0\n*\n* v = iter.next().value;\n* // returns 1\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'keys', function keys() {\n\tvar self;\n\tvar iter;\n\tvar len;\n\tvar FLG;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tself = this;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': i,\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.keys();\n\t}\n});\n\n/**\n* Returns the last index at which a given element can be found.\n*\n* @name lastIndexOf\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {number} searchElement - element to find\n* @param {integer} [fromIndex] - starting index (inclusive)\n* @throws {TypeError} `this` must be a floating-point number\n* @throws {TypeError} first argument must be a numeric value\n* @throws {TypeError} second argument must be an integer\n* @returns {integer} index or -1\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 2.0 ] );\n*\n* var idx = arr.lastIndexOf( 2.0 );\n* // returns 4\n*\n* idx = arr.lastIndexOf( 2.0, 3 );\n* // returns 2\n*\n* idx = arr.lastIndexOf( 4.0, 3 );\n* // returns -1\n*\n* idx = arr.lastIndexOf( 1.0, -3 );\n* // returns 1\n*/\nsetReadOnly( Float16Array.prototype, 'lastIndexOf', function lastIndexOf( searchElement, fromIndex ) {\n\tvar buf;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNumber( searchElement ) ) {\n\t\tthrow new TypeError( format( 'null49', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'null7f', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex >= this._length ) {\n\t\t\tfromIndex = this._length - 1;\n\t\t} else if ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t}\n\t} else {\n\t\tfromIndex = this._length - 1;\n\t}\n\tbuf = this._buffer;\n\tv = toWord( searchElement );\n\tfor ( i = fromIndex; i >= 0; i-- ) {\n\t\tif ( v === buf[ i ] ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Number of array elements.\n*\n* @name length\n* @memberof Float16Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var len = arr.length;\n* // returns 10\n*/\nsetReadOnlyAccessor( Float16Array.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Returns a new array with each element being the result of a provided callback function.\n*\n* @name map\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} fcn - callback function\n* @param {*} [thisArg] - callback function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {Float16Array} new floating-point number array\n*\n* @example\n* function scale( v ) {\n* return v * 2.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var out = arr.map( scale );\n* // returns \n*\n* var z = out[ 0 ];\n* // returns 0.0\n*\n* z = out[ 1 ];\n* // returns 2.0\n*\n* z = out[ 2 ];\n* // returns 4.0\n*/\nsetReadOnly( Float16Array.prototype, 'map', function map( fcn, thisArg ) {\n\tvar outbuf;\n\tvar out;\n\tvar buf;\n\tvar i;\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( fcn ) ) {\n\t\tthrow new TypeError( format('null3c'), fcn );\n\t}\n\tbuf = this._buffer;\n\tout = new this.constructor( this._length );\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\toutbuf[ i ] = toWord( fcn.call( thisArg, fromWord( buf[ i ] ), i, this ) ); // eslint-disable-line max-len\n\t}\n\treturn out;\n});\n\n/**\n* Applies a provided callback function to each element of the array, in order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion.\n*\n* @name reduce\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} reducer - callback function\n* @param {*} [initialValue] - initial value\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {Error} if not provided an initial value, the array must have at least one element\n* @returns {*} accumulated result\n*\n* @example\n* function add( acc, v ) {\n* return acc + v;\n* }\n*\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] );\n*\n* var out = arr.reduce( add, 0 );\n* // returns 6.0\n*/\nsetReadOnly( Float16Array.prototype, 'reduce', function reduce( reducer, initialValue ) {\n\tvar buf;\n\tvar len;\n\tvar acc;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( reducer ) ) {\n\t\tthrow new TypeError( format( 'null3c', reducer ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tacc = initialValue;\n\t\ti = 0;\n\t} else {\n\t\tif ( len === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' );\n\t\t}\n\t\tacc = fromWord( buf[ 0 ] );\n\t\ti = 1;\n\t}\n\tfor ( ; i < len; i++ ) {\n\t\tacc = reducer( acc, fromWord( buf[ i ] ), i, this );\n\t}\n\treturn acc;\n});\n\n/**\n* Applies a provided callback function to each element of the array, in reverse order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion.\n*\n* @name reduceRight\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} reducer - callback function\n* @param {*} [initialValue] - initial value\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {Error} if not provided an initial value, the array must have at least one element\n* @returns {*} accumulated result\n*\n* @example\n* function add( acc, v ) {\n* return acc + v;\n* }\n*\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] );\n*\n* var out = arr.reduceRight( add, 0 );\n* // returns 6.0\n*/\nsetReadOnly( Float16Array.prototype, 'reduceRight', function reduceRight( reducer, initialValue ) {\n\tvar buf;\n\tvar len;\n\tvar acc;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( reducer ) ) {\n\t\tthrow new TypeError( format( 'null3c', reducer ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tacc = initialValue;\n\t\ti = len - 1;\n\t} else {\n\t\tif ( len === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' );\n\t\t}\n\t\tacc = fromWord( buf[ len-1 ] );\n\t\ti = len - 2;\n\t}\n\tfor ( ; i >= 0; i-- ) {\n\t\tacc = reducer( acc, fromWord( buf[ i ] ), i, this );\n\t}\n\treturn acc;\n});\n\n/**\n* Reverses an array in-place.\n*\n* @name reverse\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Float16Array} reversed array\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var out = arr.reverse();\n* // returns \n*\n* var v = out[ 0 ];\n* // returns 2.0\n*\n* v = out[ 1 ];\n* // returns 1.0\n*\n* v = out[ 2 ];\n* // returns 0.0\n*/\nsetReadOnly( Float16Array.prototype, 'reverse', function reverse() {\n\tvar buf;\n\tvar tmp;\n\tvar len;\n\tvar N;\n\tvar i;\n\tvar j;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tN = floor( len / 2 );\n\tfor ( i = 0; i < N; i++ ) {\n\t\tj = len - i - 1;\n\t\ttmp = buf[ i ];\n\t\tbuf[ i ] = buf[ j ];\n\t\tbuf[ j ] = tmp;\n\t}\n\treturn this;\n});\n\n/**\n* Sets one or more array elements.\n*\n* ## Notes\n*\n* - When provided a typed array, we must check whether the source array shares the same buffer as the target array and whether the underlying memory overlaps. In particular, we are concerned with the following scenario:\n*\n* ```text\n* buf: ---------------------\n* src: ---------------------\n* ```\n*\n* In the above, as we copy values from `src`, we will overwrite values in the `src` view, resulting in duplicated values copied into the end of `buf`, which is not intended. Hence, to avoid overwriting source values, we must **copy** source values to a temporary array.\n*\n* In the other overlapping scenario,\n*\n* ```text\n* buf: ---------------------\n* src: ---------------------\n* ```\n*\n* by the time we begin copying into the overlapping region, we are copying from the end of `src`, a non-overlapping region, which means we don't run the risk of copying copied values, rather than the original `src` values, as intended.\n*\n* @name set\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {(Collection|Float16Array)} value - value(s)\n* @param {NonNegativeInteger} [i=0] - element index at which to start writing values\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a collection\n* @throws {TypeError} index argument must be a nonnegative integer\n* @throws {RangeError} index argument is out-of-bounds\n* @throws {RangeError} target array lacks sufficient storage to accommodate source values\n* @returns {void}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var v = arr[ 0 ];\n* // returns 0.0\n*\n* arr.set( [ 1.0, 2.0 ], 0 );\n*\n* v = arr[ 0 ];\n* // returns 1.0\n*/\nsetReadOnly( Float16Array.prototype, 'set', function set( value ) {\n\tvar sbuf;\n\tvar idx;\n\tvar buf;\n\tvar tmp;\n\tvar flg;\n\tvar N;\n\tvar i;\n\tvar j;\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isCollection( value ) ) {\n\t\tthrow new TypeError( format( 'null2O', value ) );\n\t}\n\tbuf = this._buffer;\n\tif ( arguments.length > 1 ) {\n\t\tidx = arguments[ 1 ];\n\t\tif ( !isNonNegativeInteger( idx ) ) {\n\t\t\tthrow new TypeError( format( 'null2L', idx ) );\n\t\t}\n\t} else {\n\t\tidx = 0;\n\t}\n\tN = value.length;\n\tif ( idx+N > this._length ) {\n\t\tthrow new RangeError( format('null03') );\n\t}\n\tif ( isFloat16Array( value ) ) {\n\t\tsbuf = value._buffer; // eslint-disable-line no-underscore-dangle\n\t\tflg = true;\n\t} else {\n\t\tsbuf = value;\n\t\tflg = false;\n\t}\n\t// Check for overlapping memory...\n\tj = buf.byteOffset + (idx*BYTES_PER_ELEMENT);\n\tif (\n\t\tsbuf.buffer === buf.buffer &&\n\t\t(\n\t\t\tsbuf.byteOffset < j &&\n\t\t\tsbuf.byteOffset+sbuf.byteLength > j\n\t\t)\n\t) {\n\t\t// We need to copy source values...\n\t\ttmp = new Uint16Array( sbuf.length );\n\t\tfor ( i = 0; i < sbuf.length; i++ ) {\n\t\t\ttmp[ i ] = sbuf[ i ];\n\t\t}\n\t\tsbuf = tmp;\n\t}\n\tif ( flg ) {\n\t\tfor ( i = 0; i < N; idx++, i++ ) {\n\t\t\tbuf[ idx ] = sbuf[ i ];\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < N; idx++, i++ ) {\n\t\t\tbuf[ idx ] = toWord( sbuf[ i ] );\n\t\t}\n\t}\n});\n\n/**\n* Copies a portion of a typed array to a new typed array.\n*\n* @name slice\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} [begin] - start index (inclusive)\n* @param {integer} [end] - end index (exclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be integer\n* @throws {TypeError} second argument must be integer\n* @returns {Float16Array} floating-point number array\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] );\n*\n* var out = arr.slice();\n* // returns \n*\n* var len = out.length;\n* // returns 5\n*\n* var v = out[ 0 ];\n* // returns 0.0\n*\n* v = out[ len-1 ];\n* // returns 4.0\n*\n* out = arr.slice( 1, -2 );\n* // returns \n*\n* len = out.length;\n* // returns 2\n*\n* v = out[ 0 ];\n* // returns 1.0\n*\n* v = out[ len-1 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'slice', function slice( begin, end ) {\n\tvar outlen;\n\tvar outbuf;\n\tvar out;\n\tvar buf;\n\tvar len;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length === 0 ) {\n\t\tbegin = 0;\n\t\tend = len;\n\t} else {\n\t\tif ( !isInteger( begin ) ) {\n\t\t\tthrow new TypeError( format( 'null7e', begin ) );\n\t\t}\n\t\tif ( begin < 0 ) {\n\t\t\tbegin += len;\n\t\t\tif ( begin < 0 ) {\n\t\t\t\tbegin = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\tend = len;\n\t\t} else {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'null7f', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t} else if ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t}\n\t}\n\tif ( begin < end ) {\n\t\toutlen = end - begin;\n\t} else {\n\t\toutlen = 0;\n\t}\n\tout = new this.constructor( outlen );\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < outlen; i++ ) {\n\t\toutbuf[ i ] = buf[ i+begin ];\n\t}\n\treturn out;\n});\n\n/**\n* Tests whether at least one element in an array passes a test implemented by a predicate function.\n*\n* @name some\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {boolean} boolean indicating whether at least one element passes a test\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var bool = arr.some( predicate );\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'some', function some( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( predicate.call( thisArg, fromWord( buf[ i ] ), i, this ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n});\n\n/**\n* Sorts an array in-place.\n*\n* @name sort\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} [compareFcn] - comparison function\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {Float16Array} sorted array\n*\n* @example\n* function compare( a, b ) {\n* if ( a < b ) {\n* return -1;\n* }\n* if ( a > b ) {\n* return 1;\n* }\n* return 0;\n* }\n*\n* var arr = new Float16Array( [ 1.0, 0.0, 2.0 ] );\n*\n* arr.sort( compare );\n*\n* var v = arr[ 0 ];\n* // returns 0.0\n*\n* v = arr[ 1 ];\n* // returns 1.0\n*\n* v = arr[ 2 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'sort', function sort( compareFcn ) {\n\tvar buf;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tif ( arguments.length === 0 ) {\n\t\tbuf.sort( defaultCompare );\n\t\treturn this;\n\t}\n\tif ( !isFunction( compareFcn ) ) {\n\t\tthrow new TypeError( format( 'null3c', compareFcn ) );\n\t}\n\tbuf.sort( compare );\n\treturn this;\n\n\t/**\n\t* Default comparison function for float16 values.\n\t*\n\t* @private\n\t* @param {unsigned16} a - unsigned 16-bit integer for comparison\n\t* @param {unsigned16} b - unsigned 16-bit integer for comparison\n\t* @returns {number} comparison result\n\t*/\n\tfunction defaultCompare( a, b ) { // eslint-disable-line stdlib/no-unnecessary-nested-functions\n\t\tvar x = fromWord( a );\n\t\tvar y = fromWord( b );\n\n\t\t// Handle NaN...\n\t\tif ( isnan( x ) && isnan( y ) ) {\n\t\t\treturn 0;\n\t\t}\n\t\tif ( isnan( x ) ) {\n\t\t\treturn 1;\n\t\t}\n\t\tif ( isnan( y ) ) {\n\t\t\treturn -1;\n\t\t}\n\t\t// Normal comparison\n\t\tif ( x < y ) {\n\t\t\treturn -1;\n\t\t}\n\t\tif ( x > y ) {\n\t\t\treturn 1;\n\t\t}\n\t\treturn 0;\n\t}\n\n\t/**\n\t* Comparison function wrapper.\n\t*\n\t* @private\n\t* @param {unsigned16} a - unsigned 16-bit integer for comparison\n\t* @param {unsigned16} b - unsigned 16-bit integer for comparison\n\t* @returns {number} comparison result\n\t*/\n\tfunction compare( a, b ) {\n\t\treturn compareFcn( fromWord( a ), fromWord( b ) );\n\t}\n});\n\n/**\n* Creates a new typed array view over the same underlying `ArrayBuffer` and with the same underlying data type as the host array.\n*\n* @name subarray\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} [begin] - start index (inclusive)\n* @param {integer} [end] - end index (exclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be an integer\n* @throws {TypeError} second argument must be an integer\n* @returns {Float16Array} subarray\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] );\n*\n* var subarr = arr.subarray();\n* // returns \n*\n* var len = subarr.length;\n* // returns 5\n*\n* var bool = subarr[ 0 ];\n* // returns 0.0\n*\n* bool = subarr[ len-1 ];\n* // returns 4.0\n*\n* subarr = arr.subarray( 1, -2 );\n* // returns \n*\n* len = subarr.length;\n* // returns 2\n*\n* bool = subarr[ 0 ];\n* // returns 1.0\n*\n* bool = subarr[ len-1 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'subarray', function subarray( begin, end ) {\n\tvar offset;\n\tvar buf;\n\tvar len;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length === 0 ) {\n\t\tbegin = 0;\n\t\tend = len;\n\t} else {\n\t\tif ( !isInteger( begin ) ) {\n\t\t\tthrow new TypeError( format( 'null7e', begin ) );\n\t\t}\n\t\tif ( begin < 0 ) {\n\t\t\tbegin += len;\n\t\t\tif ( begin < 0 ) {\n\t\t\t\tbegin = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\tend = len;\n\t\t} else {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'null7f', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t} else if ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t}\n\t}\n\tif ( begin >= len ) {\n\t\tlen = 0;\n\t\toffset = buf.byteLength;\n\t} else if ( begin >= end ) {\n\t\tlen = 0;\n\t\toffset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT );\n\t} else {\n\t\tlen = end - begin;\n\t\toffset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT );\n\t}\n\treturn new this.constructor( buf.buffer, offset, ( len < 0 ) ? 0 : len );\n});\n\n/**\n* Serializes an array as a locale-specific string.\n*\n* @name toLocaleString\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {(string|Array)} [locales] - locale identifier(s)\n* @param {Object} [options] - configuration options\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a string or an array of strings\n* @throws {TypeError} options argument must be an object\n* @returns {string} string representation\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var str = arr.toLocaleString();\n* // returns '0,1,2'\n*/\nsetReadOnly( Float16Array.prototype, 'toLocaleString', function toLocaleString( locales, options ) {\n\tvar opts;\n\tvar loc;\n\tvar out;\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( arguments.length === 0 ) {\n\t\tloc = [];\n\t} else if ( isString( locales ) || isStringArray( locales ) ) {\n\t\tloc = locales;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a string or an array of strings. Value: `%s`.', locales ) );\n\t}\n\tif ( arguments.length < 2 ) {\n\t\topts = {};\n\t} else if ( isObject( options ) ) {\n\t\topts = options;\n\t} else {\n\t\tthrow new TypeError( format( 'null2V', options ) );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( fromWord( buf[ i ] ) );\n\t}\n\treturn out.toLocaleString( loc, opts );\n});\n\n/**\n* Returns a new typed array containing the elements in reversed order.\n*\n* @name toReversed\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Float16Array} reversed array\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var out = arr.toReversed();\n* // returns \n*\n* var v = out[ 0 ];\n* // returns 2.0\n*\n* v = out[ 1 ];\n* // returns 1.0\n*\n* v = out[ 2 ];\n* // returns 0.0\n*/\nsetReadOnly( Float16Array.prototype, 'toReversed', function toReversed() {\n\tvar outbuf;\n\tvar out;\n\tvar len;\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tlen = this._length;\n\tout = new this.constructor( len );\n\tbuf = this._buffer;\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < len; i++ ) {\n\t\toutbuf[ i ] = buf[ len - i - 1 ];\n\t}\n\treturn out;\n});\n\n/**\n* Returns a new typed array containing the elements in sorted order.\n*\n* @name toSorted\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} [compareFcn] - comparison function\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {Float16Array} sorted array\n*\n* @example\n* function compare( a, b ) {\n* if ( a > b ) {\n* return 1;\n* }\n* if ( a < b ) {\n* return -1;\n* }\n* return 0;\n* }\n*\n* var arr = new Float16Array( [ 2.0, 0.0, 1.0 ] );\n*\n* var out = arr.toSorted( compare );\n* // returns \n*\n* var v = out[ 0 ];\n* // returns 0.0\n*\n* v = out[ 1 ];\n* // returns 1.0\n*\n* v = out[ 2 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'toSorted', function toSorted( compareFcn ) {\n\tvar out;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tout = new this.constructor( this );\n\tif ( arguments.length === 0 ) {\n\t\treturn out.sort();\n\t}\n\treturn out.sort( compareFcn );\n});\n\n/**\n* Serializes an array as a string.\n*\n* @name toString\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {string} string representation\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var str = arr.toString();\n* // returns '0,1,2'\n*/\nsetReadOnly( Float16Array.prototype, 'toString', function toString() {\n\tvar out;\n\tvar buf;\n\tvar i;\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( fromWord( buf[ i ] ) );\n\t}\n\treturn out.join( ',' );\n});\n\n/**\n* Returns an iterator for iterating over each value in a typed array.\n*\n* @name values\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0 ] );\n*\n* var iter = arr.values();\n*\n* var v = iter.next().value;\n* // returns 0.0\n*\n* v = iter.next().value;\n* // returns 1.0\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'values', function values() {\n\tvar iter;\n\tvar self;\n\tvar len;\n\tvar FLG;\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tself = this;\n\tbuf = this._buffer;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': fromWord( buf[ i ] ),\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.values();\n\t}\n});\n\n/**\n* Returns a new typed array with the element at a provided index replaced with a provided value.\n*\n* @name with\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} index - element index\n* @param {number} value - new value\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be an integer\n* @throws {RangeError} index argument is out-of-bounds\n* @throws {TypeError} second argument must be a floating-point number\n* @returns {Float16Array} new typed array\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var out = arr.with( 0, 3.0 );\n* // returns \n*\n* var v = out[ 0 ];\n* // returns 3.0\n*/\nsetReadOnly( Float16Array.prototype, 'with', function copyWith( index, value ) {\n\tvar out;\n\tvar len;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isInteger( index ) ) {\n\t\tthrow new TypeError( format( 'null7e', index ) );\n\t}\n\tlen = this._length;\n\tif ( index < 0 ) {\n\t\tindex += len;\n\t}\n\tif ( index < 0 || index >= len ) {\n\t\tthrow new RangeError( format( 'nullFP', index ) );\n\t}\n\tif ( !isNumber( value ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a floating-point number. Value: `%s`.', value ) );\n\t}\n\tout = new this.constructor( this );\n\tout[ index ] = value;\n\treturn out;\n});\n\n\n// EXPORTS //\n\nexport default Float16Array;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport f16 from '@stdlib/number-float64-base-to-float16';\nimport toWord from '@stdlib/number-float16-base-to-word';\n\n\n// MAIN //\n\n/**\n* Fills an output array with unsigned 16-bit integers corresponding to the IEEE 754 binary representation of respective half-precision floating-point numbers.\n*\n* @private\n* @param {Uint16Array} buf - output array\n* @param {Array} arr - input array\n* @returns {Uint16Array} output array\n*/\nfunction fromArray( buf, arr ) {\n\tvar len;\n\tvar i;\n\n\tlen = arr.length;\n\tfor ( i = 0; i < len; i++ ) {\n\t\tbuf[ i ] = toWord( f16( arr[ i ] ) );\n\t}\n\treturn buf;\n}\n\n\n// EXPORTS //\n\nexport default fromArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport f16 from '@stdlib/number-float64-base-to-float16';\nimport toWord from '@stdlib/number-float16-base-to-word';\n\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @param {Function} clbk - callback to invoke for each iterated value\n* @param {*} thisArg - invocation context\n* @returns {Array} output array\n*/\nfunction fromIteratorMap( it, clbk, thisArg ) {\n\tvar out;\n\tvar v;\n\tvar i;\n\n\tout = [];\n\ti = -1;\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\ti += 1;\n\t\tout.push( toWord( f16( clbk.call( thisArg, v.value, i ) ) ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIteratorMap;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Float16Array === 'function' ) ? Float16Array : void 0; // eslint-disable-line no-undef, stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* 16-bit floating-point number array constructor.\n*\n* @module @stdlib/array-float16\n*\n* @example\n* import Float16Array from '@stdlib/array-float16';\n*\n* var arr = new Float16Array();\n* // returns \n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* import Float16Array from '@stdlib/array-float16';\n*\n* var arr = new Float16Array( 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import Float16Array from '@stdlib/array-float16';\n*\n* var arr = new Float16Array( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n* import Float16Array from '@stdlib/array-float16';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float16Array( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 8\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n* import Float16Array from '@stdlib/array-float16';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float16Array( buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 4\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n* import Float16Array from '@stdlib/array-float16';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Float16Array( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\n\n// MODULES //\n\nimport hasFloat16ArraySupport from '@stdlib/assert-has-float16array-support';\nimport polyfill from './polyfill';\nimport builtin from './main.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasFloat16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n"],"names":["fromIterator","it","out","v","next","done","push","toWord","f16","value","BYTES_PER_ELEMENT","Uint16Array","HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","isFloat16Array","constructor","name","isFloatingPointArrayConstructor","Float16Array","getter","ctx","idx","_get","setter","set","byteOffset","nargs","buf","len","arg","i","arguments","length","this","isNonNegativeInteger","isCollection","gcopy","ndarray","buffer","arr","fromArray","isArrayBuffer","isInteger","byteLength","RangeError","format","isObject","TypeError","isFunction","ITERATOR_SYMBOL","setReadOnly","setReadWriteAccessor","src","thisArg","clbk","tmp","_buffer","call","fromIteratorMap","Error","args","prototype","_length","fromWord","setReadOnlyAccessor","target","start","copyWithin","self","iter","FLG","entries","predicate","end","isNumber","fcn","searchElement","fromIndex","separator","isString","join","keys","outbuf","reducer","initialValue","acc","N","j","floor","sbuf","flg","begin","outlen","compareFcn","sort","a","b","x","y","isnan","offset","locales","options","opts","loc","isStringArray","toLocaleString","values","index","ctor","ctor$1","hasFloat16ArraySupport","builtin","polyfill"],"mappings":"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"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 662979c..0000000 --- a/lib/index.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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'; - -/** -* 16-bit floating-point number array constructor. -* -* @module @stdlib/array-float16 -* -* @example -* var Float16Array = require( '@stdlib/array-float16' ); -* -* var arr = new Float16Array(); -* // returns -* -* var len = arr.length; -* // returns 0 -* -* @example -* var Float16Array = require( '@stdlib/array-float16' ); -* -* var arr = new Float16Array( 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var Float16Array = require( '@stdlib/array-float16' ); -* -* var arr = new Float16Array( [ 1.0, 2.0 ] ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var Float16Array = require( '@stdlib/array-float16' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float16Array( buf ); -* // returns -* -* var len = arr.length; -* // returns 8 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var Float16Array = require( '@stdlib/array-float16' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float16Array( buf, 8 ); -* // returns -* -* var len = arr.length; -* // returns 4 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var Float16Array = require( '@stdlib/array-float16' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = new Float16Array( buf, 8, 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -*/ - -// MODULES // - -var hasFloat16ArraySupport = require( '@stdlib/assert-has-float16array-support' ); -var polyfill = require( './polyfill' ); -var builtin = require( './main.js' ); - - -// MAIN // - -var ctor; -if ( hasFloat16ArraySupport() ) { - ctor = builtin; -} else { - ctor = polyfill; -} - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 90c9924..0000000 --- a/lib/main.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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'; - -// MAIN // - -var ctor = ( typeof Float16Array === 'function' ) ? Float16Array : void 0; // eslint-disable-line no-undef, stdlib/require-globals - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/polyfill/from_array.js b/lib/polyfill/from_array.js deleted file mode 100644 index b5894dc..0000000 --- a/lib/polyfill/from_array.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 f16 = require( '@stdlib/number-float64-base-to-float16' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); - - -// MAIN // - -/** -* Fills an output array with unsigned 16-bit integers corresponding to the IEEE 754 binary representation of respective half-precision floating-point numbers. -* -* @private -* @param {Uint16Array} buf - output array -* @param {Array} arr - input array -* @returns {Uint16Array} output array -*/ -function fromArray( buf, arr ) { - var len; - var i; - - len = arr.length; - for ( i = 0; i < len; i++ ) { - buf[ i ] = toWord( f16( arr[ i ] ) ); - } - return buf; -} - - -// EXPORTS // - -module.exports = fromArray; diff --git a/lib/polyfill/from_iterator.js b/lib/polyfill/from_iterator.js deleted file mode 100644 index 37a2c7c..0000000 --- a/lib/polyfill/from_iterator.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 f16 = require( '@stdlib/number-float64-base-to-float16' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); - - -// MAIN // - -/** -* Returns an array of iterated values. -* -* @private -* @param {Object} it - iterator -* @returns {Array} output array -*/ -function fromIterator( it ) { - var out; - var v; - - out = []; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - out.push( toWord( f16( v.value ) ) ); - } - return out; -} - - -// EXPORTS // - -module.exports = fromIterator; diff --git a/lib/polyfill/from_iterator_map.js b/lib/polyfill/from_iterator_map.js deleted file mode 100644 index 265e59d..0000000 --- a/lib/polyfill/from_iterator_map.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 f16 = require( '@stdlib/number-float64-base-to-float16' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); - - -// MAIN // - -/** -* Returns an array of iterated values. -* -* @private -* @param {Object} it - iterator -* @param {Function} clbk - callback to invoke for each iterated value -* @param {*} thisArg - invocation context -* @returns {Array} output array -*/ -function fromIteratorMap( it, clbk, thisArg ) { - var out; - var v; - var i; - - out = []; - i = -1; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - i += 1; - out.push( toWord( f16( clbk.call( thisArg, v.value, i ) ) ) ); - } - return out; -} - - -// EXPORTS // - -module.exports = fromIteratorMap; diff --git a/lib/polyfill/index.js b/lib/polyfill/index.js deleted file mode 100644 index 063db06..0000000 --- a/lib/polyfill/index.js +++ /dev/null @@ -1,2410 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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. -*/ - -/* eslint-disable no-restricted-syntax, no-invalid-this, stdlib/jsdoc-typedef-typos, max-lines */ - -'use strict'; - -// MODULES // - -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isObject = require( '@stdlib/assert-is-object' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var f16 = require( '@stdlib/number-float64-base-to-float16' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var fromWord = require( '@stdlib/number-float16-base-from-word' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var fromArray = require( './from_array.js' ); -var fromIterator = require( './from_iterator.js' ); -var fromIteratorMap = require( './from_iterator_map.js' ); - - -// VARIABLES // - -var BYTES_PER_ELEMENT = Uint16Array.BYTES_PER_ELEMENT; -var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport(); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating if a value is a `Float16Array`. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating if a value is a `Float16Array` -*/ -function isFloat16Array( value ) { - return ( - typeof value === 'object' && - value !== null && - value.constructor.name === 'Float16Array' && - value.BYTES_PER_ELEMENT === BYTES_PER_ELEMENT - ); -} - -/** -* Returns a boolean indicating if a value is a floating-point typed array constructor. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating if a value is a floating-point typed array constructor -*/ -function isFloatingPointArrayConstructor( value ) { // eslint-disable-line id-length - return ( value === Float16Array ); -} - -/** -* Returns a getter. -* -* @private -* @param {Float16Array} ctx - typed array instance -* @param {NonNegativeInteger} idx - element index -* @returns {Function} getter -*/ -function getter( ctx, idx ) { - return get; - - /** - * Returns an array element. - * - * @private - * @returns {(number|void)} array element - */ - function get() { - return ctx._get( idx ); // eslint-disable-line no-underscore-dangle - } -} - -/** -* Returns a setter. -* -* @private -* @param {Float16Array} ctx - typed array instance -* @param {NonNegativeInteger} idx - element index -* @returns {Function} setter -*/ -function setter( ctx, idx ) { - return set; - - /** - * Sets an array element. - * - * @private - * @param {number} value - value to set - */ - function set( value ) { - ctx.set( [ value ], idx ); - } -} - - -// MAIN // - -/** -* 16-bit floating-point number array constructor. -* -* @constructor -* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable -* @param {NonNegativeInteger} [byteOffset=0] - byte offset -* @param {NonNegativeInteger} [length] - view length -* @throws {RangeError} ArrayBuffer byte length must be a multiple of `2` -* @throws {TypeError} if provided only a single argument, must provide a valid argument -* @throws {TypeError} byte offset must be a nonnegative integer -* @throws {RangeError} byte offset must be a multiple of `2` -* @throws {TypeError} view length must be a positive multiple of `2` -* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements -* @returns {Float16Array} half-precision floating-point number array -* -* @example -* var arr = new Float16Array(); -* // returns -* -* var len = arr.length; -* // returns 0 -* -* @example -* var arr = new Float16Array( 5 ); -* // returns -* -* var len = arr.length; -* // returns 5 -* -* @example -* var arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns -* -* var len = arr.length; -* // returns 5 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float16Array( buf ); -* // returns -* -* var len = arr.length; -* // returns 8 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float16Array( buf, 8 ); -* // returns -* -* var len = arr.length; -* // returns 4 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = new Float16Array( buf, 8, 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -*/ -function Float16Array() { - var byteOffset; - var nargs; - var buf; - var len; - var arg; - var i; - - nargs = arguments.length; - if ( !(this instanceof Float16Array) ) { - if ( nargs === 0 ) { - return new Float16Array(); - } - if ( nargs === 1 ) { - return new Float16Array( arguments[0] ); - } - if ( nargs === 2 ) { - return new Float16Array( arguments[0], arguments[1] ); - } - return new Float16Array( arguments[0], arguments[1], arguments[2] ); - } - // Create the underlying data buffer... - if ( nargs === 0 ) { - buf = new Uint16Array( 0 ); // backward-compatibility - } else if ( nargs === 1 ) { - arg = arguments[ 0 ]; - if ( isNonNegativeInteger( arg ) ) { - buf = new Uint16Array( arg ); - } else if ( isCollection( arg ) ) { - if ( isFloat16Array( arg ) ) { - buf = new Uint16Array( arg.length ); - gcopy.ndarray( arg.length, new Uint16Array( arg.buffer, arg.byteOffset, arg.length ), 1, 0, buf, 1, 0 ); // eslint-disable-line max-len - } else { - buf = fromArray( new Uint16Array( arg.length ), arg ); - } - } else if ( isArrayBuffer( arg ) ) { - if ( !isInteger( arg.byteLength/BYTES_PER_ELEMENT ) ) { - throw new RangeError( format( 'nullE9', BYTES_PER_ELEMENT, arg.byteLength ) ); - } - buf = new Uint16Array( arg ); - } else if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'null29', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'null2A', arg ) ); - } - buf = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( buf.next ) ) { - throw new TypeError( format( 'null2A', arg ) ); - } - buf = new Uint16Array( fromIterator( buf ) ); - } else { - throw new TypeError( format( 'null2A', arg ) ); - } - } else { - buf = arguments[ 0 ]; - if ( !isArrayBuffer( buf ) ) { - throw new TypeError( format( 'null2B', buf ) ); - } - byteOffset = arguments[ 1 ]; - if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'null2C', byteOffset ) ); - } - if ( !isInteger( byteOffset/BYTES_PER_ELEMENT ) ) { - throw new RangeError( format( 'nullEA', BYTES_PER_ELEMENT, byteOffset ) ); - } - if ( nargs === 2 ) { - len = buf.byteLength - byteOffset; - if ( !isInteger( len/BYTES_PER_ELEMENT ) ) { - throw new RangeError( format( 'null2E', BYTES_PER_ELEMENT, len ) ); - } - buf = new Uint16Array( buf, byteOffset ); - } else { - len = arguments[ 2 ]; - if ( !isNonNegativeInteger( len ) ) { - throw new TypeError( format( 'null2F', len ) ); - } - if ( (len*BYTES_PER_ELEMENT) > (buf.byteLength-byteOffset) ) { - throw new RangeError( format( 'null2G', len*BYTES_PER_ELEMENT ) ); - } - buf = new Uint16Array( buf, byteOffset, len ); - } - } - setReadOnly( this, '_buffer', buf ); - setReadOnly( this, '_length', buf.length ); - for ( i = 0; i < buf.length; i++ ) { - setReadWriteAccessor( this, i, getter( this, i ), setter( this, i ) ); - } - return this; -} - -/** -* Size (in bytes) of each array element. -* -* @name BYTES_PER_ELEMENT -* @memberof Float16Array -* @readonly -* @type {PositiveInteger} -* @default 2 -* -* @example -* var nbytes = Float16Array.BYTES_PER_ELEMENT; -* // returns 2 -*/ -setReadOnly( Float16Array, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT ); - -/** -* Constructor name. -* -* @name name -* @memberof Float16Array -* @readonly -* @type {string} -* @default 'Float16Array' -* -* @example -* var str = Float16Array.name; -* // returns 'Float16Array' -*/ -setReadOnly( Float16Array, 'name', 'Float16Array' ); - -/** -* Creates a new 16-bit floating-point number array from an array-like object or an iterable. -* -* @name from -* @memberof Float16Array -* @type {Function} -* @param {(Collection|Iterable)} src - array-like object or iterable -* @param {Function} [clbk] - callback to invoke for each source element -* @param {*} [thisArg] - context -* @throws {TypeError} `this` context must be a constructor -* @throws {TypeError} `this` must be a floating-point array -* @throws {TypeError} first argument must be an array-like object or an iterable -* @throws {TypeError} second argument must be a function -* @returns {Float16Array} half-precision floating-point number array -* -* @example -* var arr = Float16Array.from( [ 1.0, 2.0 ] ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* function clbk( v ) { -* return v * 2.0; -* } -* -* var arr = Float16Array.from( [ 1.0, 2.0 ], clbk ); -* // returns -* -* var len = arr.length; -* // returns 2 -*/ -setReadOnly( Float16Array, 'from', function from( src ) { - var thisArg; - var nargs; - var clbk; - var out; - var buf; - var tmp; - var len; - var i; - if ( !isFunction( this ) ) { - throw new TypeError( format('null01') ); - } - if ( !isFloatingPointArrayConstructor( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point array.' ); - } - nargs = arguments.length; - if ( nargs > 1 ) { - clbk = arguments[ 1 ]; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'null2H', clbk ) ); - } - if ( nargs > 2 ) { - thisArg = arguments[ 2 ]; - } - } - if ( isCollection( src ) ) { - if ( clbk ) { - len = src.length; - out = new this( len ); - buf = out._buffer; // eslint-disable-line no-underscore-dangle - for ( i = 0; i < len; i++ ) { - buf[ i ] = toWord( f16( clbk.call( thisArg, src[ i ], i ) ) ); - } - return out; - } - return new this( src ); - } - if ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) { // eslint-disable-line max-len - buf = src[ ITERATOR_SYMBOL ](); - if ( !isFunction( buf.next ) ) { - throw new TypeError( format( 'null2J', src ) ); - } - if ( clbk ) { - tmp = fromIteratorMap( buf, clbk, thisArg ); - } else { - tmp = fromIterator( buf ); - } - if ( tmp instanceof Error ) { - throw tmp; - } - len = tmp.length; - out = new this( len ); - buf = out._buffer; // eslint-disable-line no-underscore-dangle - for ( i = 0; i < len; i++ ) { - buf[ i ] = tmp[ i ]; - } - return out; - } - throw new TypeError( format( 'null2J', src ) ); -}); - -/** -* Creates a new 16-bit floating-point number array from a variable number of arguments. -* -* @name of -* @memberof Float16Array -* @type {Function} -* @param {...*} element - array elements -* @throws {TypeError} `this` context must be a constructor -* @throws {TypeError} `this` must be a floating-point number array -* @returns {Float16Array} half-precision floating-point number array -* -* @example -* var arr = Float16Array.of( 1.0, 1.0, 1.0, 1.0 ); -* // returns -* -* var x = arr[ 0 ]; -* // returns 1.0 -* -* var len = arr.length; -* // returns 4 -*/ -setReadOnly( Float16Array, 'of', function of() { - var args; - var i; - if ( !isFunction( this ) ) { - throw new TypeError( format('null01') ); - } - if ( !isFloatingPointArrayConstructor( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - args = []; - for ( i = 0; i < arguments.length; i++ ) { - args.push( arguments[ i ] ); - } - return new this( args ); -}); - -/** -* Returns an array element with support for both nonnegative and negative integer indices. -* -* @name at -* @memberof Float16Array.prototype -* @type {Function} -* @param {integer} idx - element index -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} must provide an integer -* @returns {(number|void)} array element -* -* @example -* var arr = new Float16Array( [ 10.0, 20.0, 30.0 ] ); -* -* var v = arr.at( 0 ); -* // returns 10.0 -* -* v = arr.at( -1 ); -* // returns 30.0 -* -* v = arr.at( 100 ); -* // returns undefined -*/ -setReadOnly( Float16Array.prototype, 'at', function at( idx ) { - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isInteger( idx ) ) { - throw new TypeError( format( 'null8A', idx ) ); - } - if ( idx < 0 ) { - idx += this._length; - } - if ( idx < 0 || idx >= this._length ) { - return; - } - return fromWord( this._buffer[ idx ] ); -}); - -/** -* Pointer to the underlying data buffer. -* -* @name buffer -* @memberof Float16Array.prototype -* @readonly -* @type {ArrayBuffer} -* -* @example -* var arr = new Float16Array( 10 ); -* -* var buf = arr.buffer; -* // returns -*/ -setReadOnlyAccessor( Float16Array.prototype, 'buffer', function get() { - return this._buffer.buffer; -}); - -/** -* Size (in bytes) of the array. -* -* @name byteLength -* @memberof Float16Array.prototype -* @readonly -* @type {NonNegativeInteger} -* -* @example -* var arr = new Float16Array( 10 ); -* -* var byteLength = arr.byteLength; -* // returns 20 -*/ -setReadOnlyAccessor( Float16Array.prototype, 'byteLength', function get() { - return this._buffer.byteLength; -}); - -/** -* Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`. -* -* @name byteOffset -* @memberof Float16Array.prototype -* @readonly -* @type {NonNegativeInteger} -* -* @example -* var arr = new Float16Array( 10 ); -* -* var byteOffset = arr.byteOffset; -* // returns 0 -*/ -setReadOnlyAccessor( Float16Array.prototype, 'byteOffset', function get() { - return this._buffer.byteOffset; -}); - -/** -* Size (in bytes) of each array element. -* -* @name BYTES_PER_ELEMENT -* @memberof Float16Array.prototype -* @readonly -* @type {PositiveInteger} -* @default 2 -* -* @example -* var arr = new Float16Array( 10 ); -* -* var nbytes = arr.BYTES_PER_ELEMENT; -* // returns 2 -*/ -setReadOnly( Float16Array.prototype, 'BYTES_PER_ELEMENT', Float16Array.BYTES_PER_ELEMENT ); - -/** -* Copies a sequence of elements within the array to the position starting at `target`. -* -* @name copyWithin -* @memberof Float16Array.prototype -* @type {Function} -* @param {integer} target - index at which to start copying elements -* @param {integer} start - source index at which to copy elements from -* @param {integer} [end] - source index at which to stop copying elements from -* @throws {TypeError} `this` must be a floating-point array -* @returns {Float16Array} modified array -* -* @example -* var arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0 ] ); -* -* // Copy the first two elements to the last two elements: -* arr.copyWithin( 2, 0, 2 ); -* -* var v = arr[ 2 ]; -* // returns 1.0 -* -* v = arr[ 3 ]; -* // returns 2.0 -*/ -setReadOnly( Float16Array.prototype, 'copyWithin', function copyWithin( target, start ) { - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - // FIXME: prefer a functional `copyWithin` implementation which addresses lack of universal browser support (e.g., IE11 and Safari) or ensure that typed arrays are polyfilled - if ( arguments.length === 2 ) { - this._buffer.copyWithin( target, start ); - } else { - this._buffer.copyWithin( target, start, arguments[2] ); - } - return this; -}); - -/** -* Returns an iterator for iterating over array key-value pairs. -* -* @name entries -* @memberof Float16Array.prototype -* @type {Function} -* @throws {TypeError} `this` must be a floating-point number array -* @returns {Iterator} iterator -* -* @example -* var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); -* -* var it = arr.entries(); -* -* var v = it.next().value; -* // returns [ 0, 1.0 ] -* -* v = it.next().value; -* // returns [ 1, 2.0 ] -* -* v = it.next().value; -* // returns [ 2, 3.0 ] -* -* var bool = it.next().done; -* // returns true -*/ -setReadOnly( Float16Array.prototype, 'entries', function entries() { - var self; - var iter; - var len; - var buf; - var FLG; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - self = this; - buf = this._buffer; - len = this._length; - - // Initialize an iteration index: - i = -1; - - // Create an iterator protocol-compliant object: - iter = {}; - setReadOnly( iter, 'next', next ); - setReadOnly( iter, 'return', end ); - - if ( ITERATOR_SYMBOL ) { - setReadOnly( iter, ITERATOR_SYMBOL, factory ); - } - return iter; - - /** - * Returns an iterator protocol-compliant object containing the next iterated value. - * - * @private - * @returns {Object} iterator protocol-compliant object - */ - function next() { - i += 1; - if ( FLG || i >= len ) { - return { - 'done': true - }; - } - return { - 'value': [ i, fromWord( buf[ i ] ) ], - 'done': false - }; - } - - /** - * Finishes an iterator. - * - * @private - * @param {*} [value] - value to return - * @returns {Object} iterator protocol-compliant object - */ - function end( value ) { - FLG = true; - if ( arguments.length ) { - return { - 'value': value, - 'done': true - }; - } - return { - 'done': true - }; - } - - /** - * Returns a new iterator. - * - * @private - * @returns {Iterator} iterator - */ - function factory() { - return self.entries(); - } -}); - -/** -* Tests whether all elements in an array pass a test implemented by a predicate function. -* -* @name every -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - predicate function execution context -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a function -* @returns {boolean} boolean indicating whether all elements pass a test -* -* @example -* function predicate( v ) { -* return v === 0.0; -* } -* -* var arr = new Float16Array( 3 ); -* -* var bool = arr.every( predicate ); -* // returns true -*/ -setReadOnly( Float16Array.prototype, 'every', function every( predicate, thisArg ) { - var buf; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'null3c', predicate ) ); - } - buf = this._buffer; - for ( i = 0; i < this._length; i++ ) { - if ( !predicate.call( thisArg, fromWord( buf[ i ] ), i, this ) ) { - return false; - } - } - return true; -}); - -/** -* Returns a modified typed array filled with a fill value. -* -* @name fill -* @memberof Float16Array.prototype -* @type {Function} -* @param {number} value - fill value -* @param {integer} [start=0] - starting index (inclusive) -* @param {integer} [end] - ending index (exclusive) -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a floating-point number -* @throws {TypeError} second argument must be an integer -* @throws {TypeError} third argument must be an integer -* @returns {Float16Array} modified array -* -* @example -* var arr = new Float16Array( 3 ); -* -* arr.fill( 1.0, 1 ); -* -* var v = arr[ 0 ]; -* // returns 0.0 -* -* v = arr[ 1 ]; -* // returns 1.0 -* -* v = arr[ 2 ]; -* // returns 1.0 -*/ -setReadOnly( Float16Array.prototype, 'fill', function fill( value, start, end ) { - var buf; - var len; - var i; - var v; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isNumber( value ) ) { - throw new TypeError( format( 'null49', value ) ); - } - buf = this._buffer; - len = this._length; - if ( arguments.length > 1 ) { - if ( !isInteger( start ) ) { - throw new TypeError( format( 'null7f', start ) ); - } - if ( start < 0 ) { - start += len; - if ( start < 0 ) { - start = 0; - } - } - if ( arguments.length > 2 ) { - if ( !isInteger( end ) ) { - throw new TypeError( format( 'null2z', end ) ); - } - if ( end < 0 ) { - end += len; - if ( end < 0 ) { - end = 0; - } - } - if ( end > len ) { - end = len; - } - } else { - end = len; - } - } else { - start = 0; - end = len; - } - v = toWord( value ); - for ( i = start; i < end; i++ ) { - buf[ i ] = v; - } - return this; -}); - -/** -* Returns a new array containing the elements of an array which pass a test implemented by a predicate function. -* -* @name filter -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} predicate - test function -* @param {*} [thisArg] - predicate function execution context -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a function -* @returns {Float16Array} floating-point number array -* -* @example -* function predicate( v ) { -* return ( v === 0.0 ); -* } -* -* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] ); -* -* var out = arr.filter( predicate ); -* // returns -* -* var len = out.length; -* // returns 2 -* -* var v = out[ 0 ]; -* // returns 0.0 -* -* v = out[ 1 ]; -* // returns 0.0 -*/ -setReadOnly( Float16Array.prototype, 'filter', function filter( predicate, thisArg ) { - var buf; - var out; - var i; - var v; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'null3c', predicate ) ); - } - buf = this._buffer; - out = []; - for ( i = 0; i < this._length; i++ ) { - v = fromWord( buf[ i ] ); - if ( predicate.call( thisArg, v, i, this ) ) { - out.push( v ); - } - } - return new this.constructor( out ); -}); - -/** -* Returns the first element in an array for which a predicate function returns a truthy value. -* -* @name find -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - predicate function execution context -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a function -* @returns {(boolean|void)} array element or undefined -* -* @example -* function predicate( v ) { -* return v > 0.0; -* } -* -* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] ); -* -* var v = arr.find( predicate ); -* // returns 1.0 -*/ -setReadOnly( Float16Array.prototype, 'find', function find( predicate, thisArg ) { - var buf; - var v; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'null3c', predicate ) ); - } - buf = this._buffer; - for ( i = 0; i < this._length; i++ ) { - v = fromWord( buf[ i ] ); - if ( predicate.call( thisArg, v, i, this ) ) { - return v; - } - } -}); - -/** -* Returns the index of the first element in an array for which a predicate function returns a truthy value. -* -* @name findIndex -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - predicate function execution context -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a function -* @returns {integer} index or -1 -* -* @example -* function predicate( v ) { -* return v > 0.0; -* } -* -* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] ); -* -* var v = arr.findIndex( predicate ); -* // returns 1 -*/ -setReadOnly( Float16Array.prototype, 'findIndex', function findIndex( predicate, thisArg ) { - var buf; - var v; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'null3c', predicate ) ); - } - buf = this._buffer; - for ( i = 0; i < this._length; i++ ) { - v = fromWord( buf[ i ] ); - if ( predicate.call( thisArg, v, i, this ) ) { - return i; - } - } - return -1; -}); - -/** -* Returns the last element in an array for which a predicate function returns a truthy value. -* -* @name findLast -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - predicate function execution context -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a function -* @returns {(boolean|void)} array element or undefined -* -* @example -* function predicate( v ) { -* return v > 0.0; -* } -* -* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] ); -* -* var v = arr.findLast( predicate ); -* // returns 1.0 -*/ -setReadOnly( Float16Array.prototype, 'findLast', function findLast( predicate, thisArg ) { - var buf; - var v; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'null3c', predicate ) ); - } - buf = this._buffer; - for ( i = this._length-1; i >= 0; i-- ) { - v = fromWord( buf[ i ] ); - if ( predicate.call( thisArg, v, i, this ) ) { - return v; - } - } -}); - -/** -* Returns the index of the last element in an array for which a predicate function returns a truthy value. -* -* @name findLastIndex -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - predicate function execution context -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a function -* @returns {integer} index or -1 -* -* @example -* function predicate( v ) { -* return v > 0.0; -* } -* -* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] ); -* -* var v = arr.findLastIndex( predicate ); -* // returns 1 -*/ -setReadOnly( Float16Array.prototype, 'findLastIndex', function findLastIndex( predicate, thisArg ) { - var buf; - var v; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'null3c', predicate ) ); - } - buf = this._buffer; - for ( i = this._length-1; i >= 0; i-- ) { - v = fromWord( buf[ i ] ); - if ( predicate.call( thisArg, v, i, this ) ) { - return i; - } - } - return -1; -}); - -/** -* Invokes a function once for each array element. -* -* @name forEach -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} fcn - function to invoke -* @param {*} [thisArg] - function invocation context -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a function -* -* @example -* function log( v, i ) { -* console.log( '%s: %s', i, v.toString() ); -* } -* -* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] ); -* -* arr.forEach( log ); -*/ -setReadOnly( Float16Array.prototype, 'forEach', function forEach( fcn, thisArg ) { - var buf; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'null3c', fcn ) ); - } - buf = this._buffer; - for ( i = 0; i < this._length; i++ ) { - fcn.call( thisArg, fromWord( buf[ i ] ), i, this ); - } -}); - -/** -* Returns an array element. -* -* @private -* @name _get -* @memberof Float16Array.prototype -* @type {Function} -* @param {NonNegativeInteger} idx - element index -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} must provide a nonnegative integer -* @returns {(number|void)} array element -*/ -setReadOnly( Float16Array.prototype, '_get', function get( idx ) { - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isNonNegativeInteger( idx ) ) { - throw new TypeError( format( 'null2K', idx ) ); - } - if ( idx >= this._length ) { - return; - } - return fromWord( this._buffer[ idx ] ); -}); - -/** -* Returns a boolean indicating whether an array includes a provided value. -* -* @name includes -* @memberof Float16Array.prototype -* @type {Function} -* @param {number} searchElement - search element -* @param {integer} [fromIndex=0] - starting index (inclusive) -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a floating-point number -* @throws {TypeError} second argument must be an integer -* @returns {boolean} boolean indicating whether an array includes a value -* -* @example -* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] ); -* -* var bool = arr.includes( 1.0 ); -* // returns true -* -* bool = arr.includes( 1.0, 2 ); -* // returns false -* -* bool = arr.includes( 5.0 ); -* // returns false -*/ -setReadOnly( Float16Array.prototype, 'includes', function includes( searchElement, fromIndex ) { - var buf; - var i; - var v; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isNumber( searchElement ) ) { - throw new TypeError( format( 'null49', searchElement ) ); - } - if ( arguments.length > 1 ) { - if ( !isInteger( fromIndex ) ) { - throw new TypeError( format( 'null7f', fromIndex ) ); - } - if ( fromIndex < 0 ) { - fromIndex += this._length; - if ( fromIndex < 0 ) { - fromIndex = 0; - } - } - } else { - fromIndex = 0; - } - buf = this._buffer; - v = toWord( searchElement ); - for ( i = fromIndex; i < this._length; i++ ) { - if ( v === buf[ i ] ) { - return true; - } - } - return false; -}); - -/** -* Returns the first index at which a given element can be found. -* -* @name indexOf -* @memberof Float16Array.prototype -* @type {Function} -* @param {float16} searchElement - element to find -* @param {integer} [fromIndex=0] - starting index (inclusive) -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a floating-point number -* @throws {TypeError} second argument must be an integer -* @returns {integer} index or -1 -* -* @example -* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] ); -* -* var idx = arr.indexOf( 2.0 ); -* // returns 2 -* -* idx = arr.indexOf( 2.0, 3 ); -* // returns -1 -* -* idx = arr.indexOf( 3.0, 3 ); -* // returns 3 -*/ -setReadOnly( Float16Array.prototype, 'indexOf', function indexOf( searchElement, fromIndex ) { - var buf; - var i; - var v; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isNumber( searchElement ) ) { - throw new TypeError( format( 'null49', searchElement ) ); - } - if ( arguments.length > 1 ) { - if ( !isInteger( fromIndex ) ) { - throw new TypeError( format( 'null7f', fromIndex ) ); - } - if ( fromIndex < 0 ) { - fromIndex += this._length; - if ( fromIndex < 0 ) { - fromIndex = 0; - } - } - } else { - fromIndex = 0; - } - buf = this._buffer; - v = toWord( searchElement ); - for ( i = fromIndex; i < this._length; i++ ) { - if ( v === buf[ i ] ) { - return i; - } - } - return -1; -}); - -/** -* Returns a new string by concatenating all array elements. -* -* @name join -* @memberof Float16Array.prototype -* @type {Function} -* @param {string} [separator=','] - element separator -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a string -* @returns {string} string representation -* -* @example -* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] ); -* -* var str = arr.join(); -* // returns '0,1,2' -* -* str = arr.join( '|' ); -* // returns '0|1|2' -*/ -setReadOnly( Float16Array.prototype, 'join', function join( separator ) { - var buf; - var out; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( arguments.length > 0 ) { - if ( !isString( separator ) ) { - throw new TypeError( format( 'null3F', separator ) ); - } - } else { - separator = ','; - } - buf = this._buffer; - out = []; - for ( i = 0; i < this._length; i++ ) { - out.push( fromWord( buf[ i ] ) ); - } - return out.join( separator ); -}); - -/** -* Returns an iterator for iterating over each index key in a typed array. -* -* @name keys -* @memberof Float16Array.prototype -* @type {Function} -* @throws {TypeError} `this` must be a floating-point number array -* @returns {Iterator} iterator -* -* @example -* var arr = new Float16Array( [ 1.0, 2.0 ] ); -* -* var iter = arr.keys(); -* -* var v = iter.next().value; -* // returns 0 -* -* v = iter.next().value; -* // returns 1 -* -* var bool = iter.next().done; -* // returns true -*/ -setReadOnly( Float16Array.prototype, 'keys', function keys() { - var self; - var iter; - var len; - var FLG; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - self = this; - len = this._length; - - // Initialize an iteration index: - i = -1; - - // Create an iterator protocol-compliant object: - iter = {}; - setReadOnly( iter, 'next', next ); - setReadOnly( iter, 'return', end ); - - if ( ITERATOR_SYMBOL ) { - setReadOnly( iter, ITERATOR_SYMBOL, factory ); - } - return iter; - - /** - * Returns an iterator protocol-compliant object containing the next iterated value. - * - * @private - * @returns {Object} iterator protocol-compliant object - */ - function next() { - i += 1; - if ( FLG || i >= len ) { - return { - 'done': true - }; - } - return { - 'value': i, - 'done': false - }; - } - - /** - * Finishes an iterator. - * - * @private - * @param {*} [value] - value to return - * @returns {Object} iterator protocol-compliant object - */ - function end( value ) { - FLG = true; - if ( arguments.length ) { - return { - 'value': value, - 'done': true - }; - } - return { - 'done': true - }; - } - - /** - * Returns a new iterator. - * - * @private - * @returns {Iterator} iterator - */ - function factory() { - return self.keys(); - } -}); - -/** -* Returns the last index at which a given element can be found. -* -* @name lastIndexOf -* @memberof Float16Array.prototype -* @type {Function} -* @param {number} searchElement - element to find -* @param {integer} [fromIndex] - starting index (inclusive) -* @throws {TypeError} `this` must be a floating-point number -* @throws {TypeError} first argument must be a numeric value -* @throws {TypeError} second argument must be an integer -* @returns {integer} index or -1 -* -* @example -* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 2.0 ] ); -* -* var idx = arr.lastIndexOf( 2.0 ); -* // returns 4 -* -* idx = arr.lastIndexOf( 2.0, 3 ); -* // returns 2 -* -* idx = arr.lastIndexOf( 4.0, 3 ); -* // returns -1 -* -* idx = arr.lastIndexOf( 1.0, -3 ); -* // returns 1 -*/ -setReadOnly( Float16Array.prototype, 'lastIndexOf', function lastIndexOf( searchElement, fromIndex ) { - var buf; - var i; - var v; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isNumber( searchElement ) ) { - throw new TypeError( format( 'null49', searchElement ) ); - } - if ( arguments.length > 1 ) { - if ( !isInteger( fromIndex ) ) { - throw new TypeError( format( 'null7f', fromIndex ) ); - } - if ( fromIndex >= this._length ) { - fromIndex = this._length - 1; - } else if ( fromIndex < 0 ) { - fromIndex += this._length; - } - } else { - fromIndex = this._length - 1; - } - buf = this._buffer; - v = toWord( searchElement ); - for ( i = fromIndex; i >= 0; i-- ) { - if ( v === buf[ i ] ) { - return i; - } - } - return -1; -}); - -/** -* Number of array elements. -* -* @name length -* @memberof Float16Array.prototype -* @readonly -* @type {NonNegativeInteger} -* -* @example -* var arr = new Float16Array( 10 ); -* -* var len = arr.length; -* // returns 10 -*/ -setReadOnlyAccessor( Float16Array.prototype, 'length', function get() { - return this._length; -}); - -/** -* Returns a new array with each element being the result of a provided callback function. -* -* @name map -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} fcn - callback function -* @param {*} [thisArg] - callback function execution context -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a function -* @returns {Float16Array} new floating-point number array -* -* @example -* function scale( v ) { -* return v * 2.0; -* } -* -* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] ); -* -* var out = arr.map( scale ); -* // returns -* -* var z = out[ 0 ]; -* // returns 0.0 -* -* z = out[ 1 ]; -* // returns 2.0 -* -* z = out[ 2 ]; -* // returns 4.0 -*/ -setReadOnly( Float16Array.prototype, 'map', function map( fcn, thisArg ) { - var outbuf; - var out; - var buf; - var i; - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( format('null3c'), fcn ); - } - buf = this._buffer; - out = new this.constructor( this._length ); - outbuf = out._buffer; // eslint-disable-line no-underscore-dangle - for ( i = 0; i < this._length; i++ ) { - outbuf[ i ] = toWord( fcn.call( thisArg, fromWord( buf[ i ] ), i, this ) ); // eslint-disable-line max-len - } - return out; -}); - -/** -* Applies a provided callback function to each element of the array, in order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion. -* -* @name reduce -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} reducer - callback function -* @param {*} [initialValue] - initial value -* @throws {TypeError} `this` must be a floating-point number array -* @throws {Error} if not provided an initial value, the array must have at least one element -* @returns {*} accumulated result -* -* @example -* function add( acc, v ) { -* return acc + v; -* } -* -* var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); -* -* var out = arr.reduce( add, 0 ); -* // returns 6.0 -*/ -setReadOnly( Float16Array.prototype, 'reduce', function reduce( reducer, initialValue ) { - var buf; - var len; - var acc; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isFunction( reducer ) ) { - throw new TypeError( format( 'null3c', reducer ) ); - } - buf = this._buffer; - len = this._length; - if ( arguments.length > 1 ) { - acc = initialValue; - i = 0; - } else { - if ( len === 0 ) { - throw new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' ); - } - acc = fromWord( buf[ 0 ] ); - i = 1; - } - for ( ; i < len; i++ ) { - acc = reducer( acc, fromWord( buf[ i ] ), i, this ); - } - return acc; -}); - -/** -* Applies a provided callback function to each element of the array, in reverse order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion. -* -* @name reduceRight -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} reducer - callback function -* @param {*} [initialValue] - initial value -* @throws {TypeError} `this` must be a floating-point number array -* @throws {Error} if not provided an initial value, the array must have at least one element -* @returns {*} accumulated result -* -* @example -* function add( acc, v ) { -* return acc + v; -* } -* -* var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); -* -* var out = arr.reduceRight( add, 0 ); -* // returns 6.0 -*/ -setReadOnly( Float16Array.prototype, 'reduceRight', function reduceRight( reducer, initialValue ) { - var buf; - var len; - var acc; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isFunction( reducer ) ) { - throw new TypeError( format( 'null3c', reducer ) ); - } - buf = this._buffer; - len = this._length; - if ( arguments.length > 1 ) { - acc = initialValue; - i = len - 1; - } else { - if ( len === 0 ) { - throw new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' ); - } - acc = fromWord( buf[ len-1 ] ); - i = len - 2; - } - for ( ; i >= 0; i-- ) { - acc = reducer( acc, fromWord( buf[ i ] ), i, this ); - } - return acc; -}); - -/** -* Reverses an array in-place. -* -* @name reverse -* @memberof Float16Array.prototype -* @type {Function} -* @throws {TypeError} `this` must be a floating-point number array -* @returns {Float16Array} reversed array -* -* @example -* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] ); -* -* var out = arr.reverse(); -* // returns -* -* var v = out[ 0 ]; -* // returns 2.0 -* -* v = out[ 1 ]; -* // returns 1.0 -* -* v = out[ 2 ]; -* // returns 0.0 -*/ -setReadOnly( Float16Array.prototype, 'reverse', function reverse() { - var buf; - var tmp; - var len; - var N; - var i; - var j; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number 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 one or more array elements. -* -* ## Notes -* -* - When provided a typed array, we must check whether the source array shares the same buffer as the target array and whether the underlying memory overlaps. In particular, we are concerned with the following scenario: -* -* ```text -* buf: --------------------- -* src: --------------------- -* ``` -* -* In the above, as we copy values from `src`, we will overwrite values in the `src` view, resulting in duplicated values copied into the end of `buf`, which is not intended. Hence, to avoid overwriting source values, we must **copy** source values to a temporary array. -* -* In the other overlapping scenario, -* -* ```text -* buf: --------------------- -* src: --------------------- -* ``` -* -* by the time we begin copying into the overlapping region, we are copying from the end of `src`, a non-overlapping region, which means we don't run the risk of copying copied values, rather than the original `src` values, as intended. -* -* @name set -* @memberof Float16Array.prototype -* @type {Function} -* @param {(Collection|Float16Array)} value - value(s) -* @param {NonNegativeInteger} [i=0] - element index at which to start writing values -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a collection -* @throws {TypeError} index argument must be a nonnegative integer -* @throws {RangeError} index argument is out-of-bounds -* @throws {RangeError} target array lacks sufficient storage to accommodate source values -* @returns {void} -* -* @example -* var arr = new Float16Array( 10 ); -* -* var v = arr[ 0 ]; -* // returns 0.0 -* -* arr.set( [ 1.0, 2.0 ], 0 ); -* -* v = arr[ 0 ]; -* // returns 1.0 -*/ -setReadOnly( Float16Array.prototype, 'set', function set( value ) { - var sbuf; - var idx; - var buf; - var tmp; - var flg; - var N; - var i; - var j; - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isCollection( value ) ) { - throw new TypeError( format( 'null2O', value ) ); - } - buf = this._buffer; - if ( arguments.length > 1 ) { - idx = arguments[ 1 ]; - if ( !isNonNegativeInteger( idx ) ) { - throw new TypeError( format( 'null2L', idx ) ); - } - } else { - idx = 0; - } - N = value.length; - if ( idx+N > this._length ) { - throw new RangeError( format('null03') ); - } - if ( isFloat16Array( value ) ) { - sbuf = value._buffer; // eslint-disable-line no-underscore-dangle - flg = true; - } else { - sbuf = value; - flg = false; - } - // Check for overlapping memory... - j = buf.byteOffset + (idx*BYTES_PER_ELEMENT); - if ( - sbuf.buffer === buf.buffer && - ( - sbuf.byteOffset < j && - sbuf.byteOffset+sbuf.byteLength > j - ) - ) { - // We need to copy source values... - tmp = new Uint16Array( sbuf.length ); - for ( i = 0; i < sbuf.length; i++ ) { - tmp[ i ] = sbuf[ i ]; - } - sbuf = tmp; - } - if ( flg ) { - for ( i = 0; i < N; idx++, i++ ) { - buf[ idx ] = sbuf[ i ]; - } - } else { - for ( i = 0; i < N; idx++, i++ ) { - buf[ idx ] = toWord( sbuf[ i ] ); - } - } -}); - -/** -* Copies a portion of a typed array to a new typed array. -* -* @name slice -* @memberof Float16Array.prototype -* @type {Function} -* @param {integer} [begin] - start index (inclusive) -* @param {integer} [end] - end index (exclusive) -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be integer -* @throws {TypeError} second argument must be integer -* @returns {Float16Array} floating-point number array -* -* @example -* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] ); -* -* var out = arr.slice(); -* // returns -* -* var len = out.length; -* // returns 5 -* -* var v = out[ 0 ]; -* // returns 0.0 -* -* v = out[ len-1 ]; -* // returns 4.0 -* -* out = arr.slice( 1, -2 ); -* // returns -* -* len = out.length; -* // returns 2 -* -* v = out[ 0 ]; -* // returns 1.0 -* -* v = out[ len-1 ]; -* // returns 2.0 -*/ -setReadOnly( Float16Array.prototype, 'slice', function slice( begin, end ) { - var outlen; - var outbuf; - var out; - var buf; - var len; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - buf = this._buffer; - len = this._length; - if ( arguments.length === 0 ) { - begin = 0; - end = len; - } else { - if ( !isInteger( begin ) ) { - throw new TypeError( format( 'null7e', begin ) ); - } - if ( begin < 0 ) { - begin += len; - if ( begin < 0 ) { - begin = 0; - } - } - if ( arguments.length === 1 ) { - end = len; - } else { - if ( !isInteger( end ) ) { - throw new TypeError( format( 'null7f', end ) ); - } - if ( end < 0 ) { - end += len; - if ( end < 0 ) { - end = 0; - } - } else if ( end > len ) { - end = len; - } - } - } - if ( begin < end ) { - outlen = end - begin; - } else { - outlen = 0; - } - out = new this.constructor( outlen ); - outbuf = out._buffer; // eslint-disable-line no-underscore-dangle - for ( i = 0; i < outlen; i++ ) { - outbuf[ i ] = buf[ i+begin ]; - } - return out; -}); - -/** -* Tests whether at least one element in an array passes a test implemented by a predicate function. -* -* @name some -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - predicate function execution context -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a function -* @returns {boolean} boolean indicating whether at least one element passes a test -* -* @example -* function predicate( v ) { -* return v > 0.0; -* } -* -* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] ); -* -* var bool = arr.some( predicate ); -* // returns true -*/ -setReadOnly( Float16Array.prototype, 'some', function some( predicate, thisArg ) { - var buf; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'null3c', predicate ) ); - } - buf = this._buffer; - for ( i = 0; i < this._length; i++ ) { - if ( predicate.call( thisArg, fromWord( buf[ i ] ), i, this ) ) { - return true; - } - } - return false; -}); - -/** -* Sorts an array in-place. -* -* @name sort -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} [compareFcn] - comparison function -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a function -* @returns {Float16Array} sorted array -* -* @example -* function compare( a, b ) { -* if ( a < b ) { -* return -1; -* } -* if ( a > b ) { -* return 1; -* } -* return 0; -* } -* -* var arr = new Float16Array( [ 1.0, 0.0, 2.0 ] ); -* -* arr.sort( compare ); -* -* var v = arr[ 0 ]; -* // returns 0.0 -* -* v = arr[ 1 ]; -* // returns 1.0 -* -* v = arr[ 2 ]; -* // returns 2.0 -*/ -setReadOnly( Float16Array.prototype, 'sort', function sort( compareFcn ) { - var buf; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - buf = this._buffer; - if ( arguments.length === 0 ) { - buf.sort( defaultCompare ); - return this; - } - if ( !isFunction( compareFcn ) ) { - throw new TypeError( format( 'null3c', compareFcn ) ); - } - buf.sort( compare ); - return this; - - /** - * Default comparison function for float16 values. - * - * @private - * @param {unsigned16} a - unsigned 16-bit integer for comparison - * @param {unsigned16} b - unsigned 16-bit integer for comparison - * @returns {number} comparison result - */ - function defaultCompare( a, b ) { // eslint-disable-line stdlib/no-unnecessary-nested-functions - var x = fromWord( a ); - var y = fromWord( b ); - - // Handle NaN... - if ( isnan( x ) && isnan( y ) ) { - return 0; - } - if ( isnan( x ) ) { - return 1; - } - if ( isnan( y ) ) { - return -1; - } - // Normal comparison - if ( x < y ) { - return -1; - } - if ( x > y ) { - return 1; - } - return 0; - } - - /** - * Comparison function wrapper. - * - * @private - * @param {unsigned16} a - unsigned 16-bit integer for comparison - * @param {unsigned16} b - unsigned 16-bit integer for comparison - * @returns {number} comparison result - */ - function compare( a, b ) { - return compareFcn( fromWord( a ), fromWord( b ) ); - } -}); - -/** -* Creates a new typed array view over the same underlying `ArrayBuffer` and with the same underlying data type as the host array. -* -* @name subarray -* @memberof Float16Array.prototype -* @type {Function} -* @param {integer} [begin] - start index (inclusive) -* @param {integer} [end] - end index (exclusive) -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be an integer -* @throws {TypeError} second argument must be an integer -* @returns {Float16Array} subarray -* -* @example -* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] ); -* -* var subarr = arr.subarray(); -* // returns -* -* var len = subarr.length; -* // returns 5 -* -* var bool = subarr[ 0 ]; -* // returns 0.0 -* -* bool = subarr[ len-1 ]; -* // returns 4.0 -* -* subarr = arr.subarray( 1, -2 ); -* // returns -* -* len = subarr.length; -* // returns 2 -* -* bool = subarr[ 0 ]; -* // returns 1.0 -* -* bool = subarr[ len-1 ]; -* // returns 2.0 -*/ -setReadOnly( Float16Array.prototype, 'subarray', function subarray( begin, end ) { - var offset; - var buf; - var len; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - buf = this._buffer; - len = this._length; - if ( arguments.length === 0 ) { - begin = 0; - end = len; - } else { - if ( !isInteger( begin ) ) { - throw new TypeError( format( 'null7e', begin ) ); - } - if ( begin < 0 ) { - begin += len; - if ( begin < 0 ) { - begin = 0; - } - } - if ( arguments.length === 1 ) { - end = len; - } else { - if ( !isInteger( end ) ) { - throw new TypeError( format( 'null7f', end ) ); - } - if ( end < 0 ) { - end += len; - if ( end < 0 ) { - end = 0; - } - } else if ( end > len ) { - end = len; - } - } - } - if ( begin >= len ) { - len = 0; - offset = buf.byteLength; - } else if ( begin >= end ) { - len = 0; - offset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT ); - } else { - len = end - begin; - offset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT ); - } - return new this.constructor( buf.buffer, offset, ( len < 0 ) ? 0 : len ); -}); - -/** -* Serializes an array as a locale-specific string. -* -* @name toLocaleString -* @memberof Float16Array.prototype -* @type {Function} -* @param {(string|Array)} [locales] - locale identifier(s) -* @param {Object} [options] - configuration options -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a string or an array of strings -* @throws {TypeError} options argument must be an object -* @returns {string} string representation -* -* @example -* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] ); -* -* var str = arr.toLocaleString(); -* // returns '0,1,2' -*/ -setReadOnly( Float16Array.prototype, 'toLocaleString', function toLocaleString( locales, options ) { - var opts; - var loc; - var out; - var buf; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( arguments.length === 0 ) { - loc = []; - } else if ( isString( locales ) || isStringArray( locales ) ) { - loc = locales; - } else { - throw new TypeError( format( 'invalid argument. First argument must be a string or an array of strings. Value: `%s`.', locales ) ); - } - if ( arguments.length < 2 ) { - opts = {}; - } else if ( isObject( options ) ) { - opts = options; - } else { - throw new TypeError( format( 'null2V', options ) ); - } - buf = this._buffer; - out = []; - for ( i = 0; i < this._length; i++ ) { - out.push( fromWord( buf[ i ] ) ); - } - return out.toLocaleString( loc, opts ); -}); - -/** -* Returns a new typed array containing the elements in reversed order. -* -* @name toReversed -* @memberof Float16Array.prototype -* @type {Function} -* @throws {TypeError} `this` must be a floating-point number array -* @returns {Float16Array} reversed array -* -* @example -* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] ); -* -* var out = arr.toReversed(); -* // returns -* -* var v = out[ 0 ]; -* // returns 2.0 -* -* v = out[ 1 ]; -* // returns 1.0 -* -* v = out[ 2 ]; -* // returns 0.0 -*/ -setReadOnly( Float16Array.prototype, 'toReversed', function toReversed() { - var outbuf; - var out; - var len; - var buf; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number 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; -}); - -/** -* Returns a new typed array containing the elements in sorted order. -* -* @name toSorted -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} [compareFcn] - comparison function -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a function -* @returns {Float16Array} sorted array -* -* @example -* function compare( a, b ) { -* if ( a > b ) { -* return 1; -* } -* if ( a < b ) { -* return -1; -* } -* return 0; -* } -* -* var arr = new Float16Array( [ 2.0, 0.0, 1.0 ] ); -* -* var out = arr.toSorted( compare ); -* // returns -* -* var v = out[ 0 ]; -* // returns 0.0 -* -* v = out[ 1 ]; -* // returns 1.0 -* -* v = out[ 2 ]; -* // returns 2.0 -*/ -setReadOnly( Float16Array.prototype, 'toSorted', function toSorted( compareFcn ) { - var out; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - out = new this.constructor( this ); - if ( arguments.length === 0 ) { - return out.sort(); - } - return out.sort( compareFcn ); -}); - -/** -* Serializes an array as a string. -* -* @name toString -* @memberof Float16Array.prototype -* @type {Function} -* @throws {TypeError} `this` must be a floating-point number array -* @returns {string} string representation -* -* @example -* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] ); -* -* var str = arr.toString(); -* // returns '0,1,2' -*/ -setReadOnly( Float16Array.prototype, 'toString', function toString() { - var out; - var buf; - var i; - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - buf = this._buffer; - out = []; - for ( i = 0; i < this._length; i++ ) { - out.push( fromWord( buf[ i ] ) ); - } - return out.join( ',' ); -}); - -/** -* Returns an iterator for iterating over each value in a typed array. -* -* @name values -* @memberof Float16Array.prototype -* @type {Function} -* @throws {TypeError} `this` must be a floating-point number array -* @returns {Iterator} iterator -* -* @example -* var arr = new Float16Array( [ 0.0, 1.0 ] ); -* -* var iter = arr.values(); -* -* var v = iter.next().value; -* // returns 0.0 -* -* v = iter.next().value; -* // returns 1.0 -* -* var bool = iter.next().done; -* // returns true -*/ -setReadOnly( Float16Array.prototype, 'values', function values() { - var iter; - var self; - var len; - var FLG; - var buf; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - self = this; - buf = this._buffer; - len = this._length; - - // Initialize an iteration index: - i = -1; - - // Create an iterator protocol-compliant object: - iter = {}; - setReadOnly( iter, 'next', next ); - setReadOnly( iter, 'return', end ); - - if ( ITERATOR_SYMBOL ) { - setReadOnly( iter, ITERATOR_SYMBOL, factory ); - } - return iter; - - /** - * Returns an iterator protocol-compliant object containing the next iterated value. - * - * @private - * @returns {Object} iterator protocol-compliant object - */ - function next() { - i += 1; - if ( FLG || i >= len ) { - return { - 'done': true - }; - } - return { - 'value': fromWord( buf[ i ] ), - 'done': false - }; - } - - /** - * Finishes an iterator. - * - * @private - * @param {*} [value] - value to return - * @returns {Object} iterator protocol-compliant object - */ - function end( value ) { - FLG = true; - if ( arguments.length ) { - return { - 'value': value, - 'done': true - }; - } - return { - 'done': true - }; - } - - /** - * Returns a new iterator. - * - * @private - * @returns {Iterator} iterator - */ - function factory() { - return self.values(); - } -}); - -/** -* Returns a new typed array with the element at a provided index replaced with a provided value. -* -* @name with -* @memberof Float16Array.prototype -* @type {Function} -* @param {integer} index - element index -* @param {number} value - new value -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be an integer -* @throws {RangeError} index argument is out-of-bounds -* @throws {TypeError} second argument must be a floating-point number -* @returns {Float16Array} new typed array -* -* @example -* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] ); -* -* var out = arr.with( 0, 3.0 ); -* // returns -* -* var v = out[ 0 ]; -* // returns 3.0 -*/ -setReadOnly( Float16Array.prototype, 'with', function copyWith( index, value ) { - var out; - var len; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isInteger( index ) ) { - throw new TypeError( format( 'null7e', index ) ); - } - len = this._length; - if ( index < 0 ) { - index += len; - } - if ( index < 0 || index >= len ) { - throw new RangeError( format( 'nullFP', index ) ); - } - if ( !isNumber( value ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a floating-point number. Value: `%s`.', value ) ); - } - out = new this.constructor( this ); - out[ index ] = value; - return out; -}); - - -// EXPORTS // - -module.exports = Float16Array; diff --git a/package.json b/package.json index 0ed7acd..953c789 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.0", "description": "Float16Array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,65 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-uint16": "^0.2.3", - "@stdlib/assert-has-float16array-support": "^0.1.1", - "@stdlib/assert-has-iterator-symbol-support": "^0.2.3", - "@stdlib/assert-is-arraybuffer": "^0.2.3", - "@stdlib/assert-is-collection": "^0.2.3", - "@stdlib/assert-is-function": "^0.2.3", - "@stdlib/assert-is-integer": "^0.2.3", - "@stdlib/assert-is-nonnegative-integer": "^0.2.3", - "@stdlib/assert-is-number": "^0.2.3", - "@stdlib/assert-is-object": "^0.2.3", - "@stdlib/assert-is-string": "^0.2.3", - "@stdlib/assert-is-string-array": "^0.2.3", - "@stdlib/blas-base-gcopy": "^0.2.3", - "@stdlib/math-base-assert-is-nan": "^0.2.3", - "@stdlib/math-base-special-floor": "^0.2.4", - "@stdlib/number-float16-base-from-word": "^0.2.1", - "@stdlib/number-float16-base-to-word": "^0.1.1", - "@stdlib/number-float64-base-to-float16": "^0.1.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/symbol-iterator": "^0.2.3", - "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.4", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", - "@stdlib/utils-define-read-write-accessor": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.2.3", - "@stdlib/assert-has-own-property": "^0.2.3", - "@stdlib/assert-instance-of": "^0.3.1", - "@stdlib/assert-is-array": "^0.2.3", - "@stdlib/assert-is-boolean": "^0.2.3", - "@stdlib/assert-is-iterator-like": "^0.2.3", - "@stdlib/console-log-each": "^0.2.4", - "@stdlib/math-base-special-pow": "^0.3.1", - "@stdlib/random-array-uniform": "^0.2.2", - "@stdlib/utils-identity-function": "^0.2.3", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..41ab3bb --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 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 main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/polyfill/test.at.js b/test/polyfill/test.at.js deleted file mode 100644 index 2cd65c2..0000000 --- a/test/polyfill/test.at.js +++ /dev/null @@ -1,144 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `at` method for returning an array element', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'at' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.at ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.at.call( value, 0 ); - }; - } -}); - -tape( 'the method throws an error if provided an index argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - 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.at( value ); - }; - } -}); - -tape( 'the method returns `undefined` if provided an index which exceeds array dimensions', function test( t ) { - var arr; - var v; - var i; - - arr = new Float16Array( 10 ); - for ( i = -arr.length; i < arr.length; i++ ) { - if ( i < 0 ) { - v = arr.at( i-arr.length ); - t.strictEqual( v, void 0, 'returns expected value for index '+(i-arr.length) ); - } else { - v = arr.at( arr.length+i ); - t.strictEqual( v, void 0, 'returns expected value for index '+(arr.length+i) ); - } - } - t.end(); -}); - -tape( 'the method returns an array element', function test( t ) { - var arr; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( i+0.05 ); - } - - arr = new Float16Array( arr ); - - for ( i = -arr.length; i < arr.length; i++ ) { - v = arr.at( i ); - if ( i < 0 ) { - t.strictEqual( v, float64ToFloat16( arr.length + i + 0.05 ), 'returns expected value for index '+i ); - } else { - t.strictEqual( v, float64ToFloat16( i + 0.05 ), 'returns expected value for index '+i ); - } - } - t.end(); -}); diff --git a/test/polyfill/test.copy_within.js b/test/polyfill/test.copy_within.js deleted file mode 100644 index 0a8eb57..0000000 --- a/test/polyfill/test.copy_within.js +++ /dev/null @@ -1,281 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 Uint16Array = require( '@stdlib/array-uint16' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `copyWithin` method for copying a sequence of array elements within a floating-point number array', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'copyWithin' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within an array', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( 0, 3 ); - buf = new Uint16Array( arr.buffer ); - - // Overwritten: - t.strictEqual( buf[ 0 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 4.05 ), 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 2 ], toWord( 2.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (negative target)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( -arr.length, 3 ); - buf = new Uint16Array( arr.buffer ); - - // Overwritten: - t.strictEqual( buf[ 0 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 4.05 ), 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 2 ], toWord( 2.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (negative start)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( 0, -2 ); - buf = new Uint16Array( arr.buffer ); - - // Overwritten: - t.strictEqual( buf[ 0 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 4.05 ), 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 2 ], toWord( 2.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (end=length)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( 0, 3, arr.length ); - buf = new Uint16Array( arr.buffer ); - - // Overwritten: - t.strictEqual( buf[ 0 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 4.05 ), 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 2 ], toWord( 2.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (non-inclusive end)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( 2, 0, 2 ); - buf = new Uint16Array( arr.buffer ); - - // Remain the same: - t.strictEqual( buf[ 0 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - - // Overwritten: - t.strictEqual( buf[ 2 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 1.05 ), 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (negative end)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( 2, 0, -3 ); - buf = new Uint16Array( arr.buffer ); - - // Remain the same: - t.strictEqual( buf[ 0 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - - // Overwritten: - t.strictEqual( buf[ 2 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 1.05 ), 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (target >= length)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( arr.length, 3 ); - buf = new Uint16Array( arr.buffer ); - - // Remain the same: - t.strictEqual( buf[ 0 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 2 ], toWord( 2.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (target > start)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( 2, 0 ); - buf = new Uint16Array( arr.buffer ); - - // Remain the same: - t.strictEqual( buf[ 0 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - - // Overwritten: - t.strictEqual( buf[ 2 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 4 ], toWord( 2.05 ), 'returns expected value' ); - - t.end(); -}); diff --git a/test/polyfill/test.entries.js b/test/polyfill/test.entries.js deleted file mode 100644 index 4cea4d1..0000000 --- a/test/polyfill/test.entries.js +++ /dev/null @@ -1,238 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 proxyquire = require( 'proxyquire' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isNumber = require( '@stdlib/assert-is-number' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `entries` method for returning an iterator for iterating over array key-value pairs', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'entries' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.entries ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.entries.call( value ); - }; - } -}); - -tape( 'the method returns an iterator protocol-compliant object', function test( t ) { - var buf; - var arr; - var it; - var v; - var i; - - buf = [ 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( buf ); - - it = arr.entries(); - t.strictEqual( it.next.length, 0, 'has zero arity' ); - - for ( i = 0; i < arr.length; i++ ) { - v = it.next(); - t.strictEqual( isArray( v.value ), true, 'returns expected value' ); - t.strictEqual( v.value[ 0 ], i, 'returns expected value' ); - t.strictEqual( isNumber( v.value[ 1 ] ), true, 'returns expected value' ); - t.strictEqual( v.value[ 1 ], float64ToFloat16( buf[ i ] ), 'returns expected value' ); - t.strictEqual( typeof v.done, 'boolean', 'returns expected value' ); - } - t.end(); -}); - -tape( 'the method returns an iterator which has a `return` method for closing an iterator (no argument)', function test( t ) { - var buf; - var arr; - var it; - var v; - - buf = [ 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( buf ); - - it = arr.entries(); - - v = it.next(); - t.strictEqual( v.value[ 1 ], float64ToFloat16( buf[ 0 ] ), 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value[ 1 ], float64ToFloat16( buf[ 1 ] ), 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.return(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method returns an iterator which has a `return` method for closing an iterator (argument)', function test( t ) { - var buf; - var arr; - var it; - var v; - - buf = [ 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( buf ); - - it = arr.entries(); - - v = it.next(); - t.strictEqual( v.value[ 1 ], float64ToFloat16( buf[ 0 ] ), 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value[ 1 ], float64ToFloat16( buf[ 1 ] ), 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.return( 'finished' ); - t.strictEqual( v.value, 'finished', 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'if an environment supports `Symbol.iterator`, the method returns an iterable', function test( t ) { - var Float16Array; - var arr; - var buf; - var it1; - var it2; - var v1; - var v2; - var i; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - buf = [ 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( buf ); - - it1 = arr.entries(); - t.strictEqual( typeof it1[ '__ITERATOR_SYMBOL__' ], 'function', 'has method' ); - t.strictEqual( it1[ '__ITERATOR_SYMBOL__' ].length, 0, 'has zero arity' ); - - it2 = it1[ '__ITERATOR_SYMBOL__' ](); - t.strictEqual( typeof it2, 'object', 'returns expected value' ); - t.strictEqual( typeof it2.next, 'function', 'has `next` method' ); - t.strictEqual( typeof it2.return, 'function', 'has `return` method' ); - - for ( i = 0; i < arr.length; i++ ) { - v1 = it1.next().value; - v2 = it2.next().value; - t.strictEqual( v1[ 0 ], v2[ 0 ], 'returns expected value' ); - t.strictEqual( v1[ 1 ], v2[ 1 ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'if an environment does not support `Symbol.iterator`, the method does not return an "iterable"', function test( t ) { - var Float16Array; - var arr; - var buf; - var it; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/symbol-iterator': false - }); - - buf = [ 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( buf ); - - it = arr.entries(); - t.strictEqual( it[ ITERATOR_SYMBOL ], void 0, 'does not have property' ); - - t.end(); -}); diff --git a/test/polyfill/test.every.js b/test/polyfill/test.every.js deleted file mode 100644 index 384adc4..0000000 --- a/test/polyfill/test.every.js +++ /dev/null @@ -1,174 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `every` method for returning boolean indicating whether all elements pass a test', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'every' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.every ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.every.call( value, predicate ); - }; - } - - function predicate( v ) { - return v === 0.0; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.every( value ); - }; - } -}); - -tape( 'the method returns `true` if operating on an empty floating-point number array', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( 0 ); - bool = arr.every( predicate ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns `true` if all elements pass a test', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 1.05, 1.05, 1.05 ] ); - bool = arr.every( predicate ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v === float64ToFloat16( 1.05 ); - } -}); - -tape( 'the method returns `false` if one or more elements fail a test', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 1.05, 0.05, 1.05 ] ); - bool = arr.every( predicate ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v === float64ToFloat16( 1.05 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var bool; - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ 1.05, 1.05, 1.05, 1.05 ] ); - bool = arr.every( predicate, ctx ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v === float64ToFloat16( 1.05 ); - } -}); diff --git a/test/polyfill/test.fill.js b/test/polyfill/test.fill.js deleted file mode 100644 index 197e33f..0000000 --- a/test/polyfill/test.fill.js +++ /dev/null @@ -1,305 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 Uint16Array = require( '@stdlib/array-uint16' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `fill` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'fill' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.fill ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.fill.call( value, 1.0 ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a floating-point number', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 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.fill( value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - 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.fill( 1.0, value ); - }; - } -}); - -tape( 'the method throws an error if provided a third argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - 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.fill( 1.0, 0, value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.fill( 1.05 ); - - t.strictEqual( out instanceof Float16Array, true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 10 ); - out = arr.fill( 1.05 ); - - t.strictEqual( out, arr, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'if called with one argument, the method sets each array element to the provided value', function test( t ) { - var arr; - var buf; - var i; - - arr = new Float16Array( 3 ); - arr.fill( 1.05 ); - - buf = new Uint16Array( arr.buffer ); - - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( buf[ i ], toWord( 1.05 ), 'returns expected value' ); - } - - t.end(); -}); - -tape( 'if called with two arguments, the method sets each array element to the provided value starting from a start index (inclusive)', function test( t ) { - var arr; - var buf; - - arr = new Float16Array( 3 ); - buf = new Uint16Array( arr.buffer ); - - arr.fill( 1.05, 1 ); - - t.strictEqual( buf[ 0 ], toWord( 0.0 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 2 ], toWord( 1.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'if called with three arguments, the method sets each array element to the provided value starting from a start index (inclusive) until a specified end index (exclusive)', function test( t ) { - var arr; - var buf; - - arr = new Float16Array( 3 ); - buf = new Uint16Array( arr.buffer ); - - arr.fill( 1.05, 0, 2 ); - - t.strictEqual( buf[ 0 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 2 ], toWord( 0.0 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method supports negative indices', function test( t ) { - var arr; - var buf; - - arr = new Float16Array( 3 ); - buf = new Uint16Array( arr.buffer ); - - arr.fill( 1.05, -3, -1 ); - - t.strictEqual( buf[ 0 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 2 ], toWord( 0.0 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'if a provided start index resolves to a negative index, the method fills an array starting from the first element', function test( t ) { - var arr; - var buf; - var i; - - arr = new Float16Array( 3 ); - buf = new Uint16Array( arr.buffer ); - - arr.fill( 1.05, -10 ); - - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( buf[ i ], toWord( 1.05 ), 'returns expected value' ); - } - - t.end(); -}); - -tape( 'if a provided end index resolves to an index exceeding the last array element index, the method fills an array until the last element (inclusive)', function test( t ) { - var arr; - var buf; - var i; - - arr = new Float16Array( 3 ); - buf = new Uint16Array( arr.buffer ); - - arr.fill( 1.05, 1, 10 ); - - t.strictEqual( buf[ 0 ], toWord( 0.0 ), 'returns expected value' ); - for ( i = 1; i < arr.length; i++ ) { - t.strictEqual( buf[ i ], toWord( 1.05 ), 'returns expected value' ); - } - - t.end(); -}); - -tape( 'if a provided start index resolves to an index which is greater than or equal to a resolved end index, the method does not fill an array', function test( t ) { - var arr; - var buf; - - arr = new Float16Array( 3 ); - buf = new Uint16Array( arr.buffer ); - - arr.fill( 1.0, 2, 1 ); - - t.strictEqual( buf[ 0 ], toWord( 0.0 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 0.0 ), 'returns expected value' ); - t.strictEqual( buf[ 2 ], toWord( 0.0 ), 'returns expected value' ); - - t.end(); -}); diff --git a/test/polyfill/test.filter.js b/test/polyfill/test.filter.js deleted file mode 100644 index c5be66b..0000000 --- a/test/polyfill/test.filter.js +++ /dev/null @@ -1,226 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 instanceOf = require( '@stdlib/assert-instance-of' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `filter` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'filter' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.filter ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.filter.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( v === 1.0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.filter( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.filter( predicate ); - - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v === 1.0 ); - } -}); - -tape( 'the method returns a new floating-point number array containing only those elements which satisfy a test condition', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 1.05, 2.05 ] ); - expected = new Uint16Array( [ toWord( 1.05 ), toWord( 1.05 ) ] ); - actual = arr.filter( predicate ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v === float64ToFloat16( 1.05 ) ); - } -}); - -tape( 'the method copies all elements to a new array if all elements satisfy a test condition', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ) - ]); - actual = arr.filter( predicate ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.notEqual( actual, arr, 'returns a new instance' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v > 1.0 ); - } -}); - -tape( 'the method returns an empty array if no elements satisfy a test condition', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array( [] ); - actual = arr.filter( predicate ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.notEqual( actual, arr, 'returns a new instance' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 1.0 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var expected; - var actual; - var arr; - var buf; - var ctx; - - arr = new Float16Array( [ 1.05, 2.05, 1.05, 1.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 1.05 ), - toWord( 1.05 ) - ]); - ctx = { - 'count': 0 - }; - actual = arr.filter( predicate, ctx ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v === float64ToFloat16( 1.05 ) ); - } -}); diff --git a/test/polyfill/test.find.js b/test/polyfill/test.find.js deleted file mode 100644 index 64dffd0..0000000 --- a/test/polyfill/test.find.js +++ /dev/null @@ -1,174 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `find` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'find' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.find ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.find.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( v === 1.0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.find( value ); - }; - } -}); - -tape( 'the method returns `undefined` if operating on an empty floating-point number array', function test( t ) { - var arr; - var v; - - arr = new Float16Array( 0 ); - v = arr.find( predicate ); - - t.strictEqual( v, void 0, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns the first element which passes a test', function test( t ) { - var arr; - var v; - - arr = new Float16Array( [ 1.05, -2.05, 3.05, -4.05 ] ); - v = arr.find( predicate ); - - t.strictEqual( v, float64ToFloat16( -2.05 ), 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method returns `undefined` if all elements fail a test', function test( t ) { - var arr; - var v; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - v = arr.find( predicate ); - - t.strictEqual( v, void 0, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - var v; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ -1.05, -2.05, 3.05, 4.05, 5.05 ] ); - v = arr.find( predicate, ctx ); - - t.strictEqual( v, float64ToFloat16( 3.05 ), 'returns expected value' ); - t.strictEqual( ctx.count, 3, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v > 0.0 ); - } -}); diff --git a/test/polyfill/test.find_index.js b/test/polyfill/test.find_index.js deleted file mode 100644 index e1516da..0000000 --- a/test/polyfill/test.find_index.js +++ /dev/null @@ -1,173 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `findIndex` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'findIndex' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.findIndex ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.findIndex.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( v === 1.0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.findIndex( value ); - }; - } -}); - -tape( 'the method returns `-1` if operating on an empty floating-point number array', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( 0 ); - idx = arr.findIndex( predicate ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns the index of the first element which passes a test', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( [ 1.05, -2.05, 3.05, -4.05 ] ); - idx = arr.findIndex( predicate ); - - t.strictEqual( idx, 1, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0); - } -}); - -tape( 'the method returns `-1` if all elements fail a test', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - idx = arr.findIndex( predicate ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - var idx; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ -1.05, -2.05, 3.05, 4.05, 5.05 ] ); - idx = arr.findIndex( predicate, ctx ); - - t.strictEqual( idx, 2, 'returns expected value' ); - t.strictEqual( ctx.count, 3, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v > 0.0 ); - } -}); diff --git a/test/polyfill/test.find_last.js b/test/polyfill/test.find_last.js deleted file mode 100644 index 091e5a7..0000000 --- a/test/polyfill/test.find_last.js +++ /dev/null @@ -1,174 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `findLast` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'findLast' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.findLast ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.findLast.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( v === 0.0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.findLast( value ); - }; - } -}); - -tape( 'the method returns `undefined` if operating on an empty floating-point number array', function test( t ) { - var arr; - var v; - - arr = new Float16Array( 0 ); - v = arr.findLast( predicate ); - - t.strictEqual( v, void 0, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns the last element which passes a test', function test( t ) { - var arr; - var v; - - arr = new Float16Array( [ 1.05, -2.05, 3.05, -4.05 ] ); - v = arr.findLast( predicate ); - - t.strictEqual( v, float64ToFloat16( -4.05 ), 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method returns `undefined` if all elements fail a test', function test( t ) { - var arr; - var v; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - v = arr.findLast( predicate ); - - t.strictEqual( v, void 0, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - var v; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ -1.05, -2.05, 3.05, 4.05, 5.05 ] ); - v = arr.findLast( predicate, ctx ); - - t.strictEqual( v, float64ToFloat16( 5.05 ), 'returns expected value' ); - t.strictEqual( ctx.count, 1, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v > 0.0 ); - } -}); diff --git a/test/polyfill/test.find_last_index.js b/test/polyfill/test.find_last_index.js deleted file mode 100644 index 1b7b8df..0000000 --- a/test/polyfill/test.find_last_index.js +++ /dev/null @@ -1,173 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `findLastIndex` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'findLastIndex' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.findLastIndex ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.findLastIndex.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( v === 1.0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.findLastIndex( value ); - }; - } -}); - -tape( 'the method returns `-1` if operating on an empty floating-point number array', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( 0 ); - idx = arr.findLastIndex( predicate ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns the index of the last element which passes a test', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( [ 1.05, -2.05, 3.05, -4.05 ] ); - idx = arr.findLastIndex( predicate ); - - t.strictEqual( idx, 3, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method returns `-1` if all elements fail a test', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - idx = arr.findLastIndex( predicate ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - var idx; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ -1.05, -2.05, 3.05, 4.05, 5.05 ] ); - idx = arr.findLastIndex( predicate, ctx ); - - t.strictEqual( idx, 4, 'returns expected value' ); - t.strictEqual( ctx.count, 1, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v > 0.0 ); - } -}); diff --git a/test/polyfill/test.for_each.js b/test/polyfill/test.for_each.js deleted file mode 100644 index 98e75c2..0000000 --- a/test/polyfill/test.for_each.js +++ /dev/null @@ -1,196 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `forEach` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'forEach' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.forEach ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.forEach.call( value, fcn ); - }; - } - - function fcn( v ) { - if ( !isNumber( v ) ) { - t.fail( 'should be a number' ); - } - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.forEach( value ); - }; - } -}); - -tape( 'the method should not invoke a provided callback function if operating on an empty floating-point array', function test( t ) { - var arr; - - arr = new Float16Array( 0 ); - arr.forEach( fcn ); - - t.end(); - - function fcn() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns `undefined`', function test( t ) { - var arr; - var out; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - out = arr.forEach( fcn ); - - t.strictEqual( out, void 0, 'returns expected value' ); - t.end(); - - function fcn( v ) { - if ( !isNumber( v ) ) { - t.fail( 'should be a number' ); - } - } -}); - -tape( 'the method invokes a provided function for each element in an array', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var arr; - - indices = []; - values = []; - arrays = []; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - arr.forEach( fcn ); - - expected = [ - float64ToFloat16( 1.05 ), - float64ToFloat16( 2.05 ), - float64ToFloat16( 3.05 ), - float64ToFloat16( 4.05 ) - ]; - - t.deepEqual( values, expected, 'returns expected value' ); - t.deepEqual( indices, [ 0, 1, 2, 3 ], 'returns expected value' ); - t.strictEqual( arrays[ 0 ], arr, 'returns expected value' ); - t.strictEqual( arrays[ 1 ], arr, 'returns expected value' ); - t.strictEqual( arrays[ 2 ], arr, 'returns expected value' ); - t.strictEqual( arrays[ 3 ], arr, 'returns expected value' ); - - t.end(); - - function fcn( v, i, arr ) { - values.push( v ); - indices.push( i ); - arrays.push( arr ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - arr.forEach( fcn, ctx ); - - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function fcn() { - this.count += 1; // eslint-disable-line no-invalid-this - } -}); diff --git a/test/polyfill/test.from.js b/test/polyfill/test.from.js deleted file mode 100644 index d9cfc1a..0000000 --- a/test/polyfill/test.from.js +++ /dev/null @@ -1,654 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 proxyquire = require( 'proxyquire' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is a `from` method for creating a 16-bit floating-point number array from an array-like object or an iterable', function test( t ) { - var arr; - - t.strictEqual( hasOwnProp( Float16Array, 'from' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.from ), true, 'has method' ); - - arr = Float16Array.from( [] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a constructor', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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 Float16Array.from.call( value, [] ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array constructor', function test( t ) { - var values; - var i; - - values = [ - {}, - null, - 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 Float16Array.from.call( value, [] ); - }; - } -}); - -tape( 'the method throws an error if not provided an iterable or array-like object', function test( t ) { - var values; - var i; - - 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 Float16Array.from( value ); - }; - } -}); - -tape( 'the method throws an error if not provided an iterable or array-like object (callback)', function test( t ) { - var values; - var i; - - 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 Float16Array.from( value, clbk ); - }; - } - - function clbk() { - return 1.0; - } -}); - -tape( 'the method throws an error if not provided an iterable or array-like object (callback, thisArg)', function test( t ) { - var values; - var i; - - 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 Float16Array.from( value, clbk, {} ); - }; - } - - function clbk() { - return 1.0; - } -}); - -tape( 'the method throws an error if provided a second argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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 Float16Array.from( [], value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not a function (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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 Float16Array.from( [], value, {} ); - }; - } -}); - -tape( 'the method returns a floating-point number array', function test( t ) { - var arr; - var v; - - // Generic array: - arr = Float16Array.from( [] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Float16Array.from( [ 1.0, 2.0, 3.0, 4.0 ] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - // Generic array containing non-numeric values: - arr = Float16Array.from( [ 'beep' ] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - arr = Float16Array.from( [ null, 4 ] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - arr = Float16Array.from( [ true, {}, '' ] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 3, 'returns expected value' ); - - // Typed array: - arr = Float16Array.from( new Uint16Array( 0 ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Float16Array.from( new Uint16Array( [ 1, 1 ] ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // Floating-point number typed array: - arr = Float16Array.from( new Float16Array( 0 ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Float16Array.from( new Float16Array( [ 1.0, 2.0 ] ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method returns a floating-point number array (iterable)', function test( t ) { - var Float16Array; - var iter; - var arr; - var v; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - iter = { - 'next': next, - 'i': 0, - 'N': 4 - }; - arr = Float16Array.from( createIterable( iter ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, iter.N, 'returns expected value' ); - - t.end(); - - function hasSupport() { - return true; - } - - function createIterable( iterator ) { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return iterator; - } - } - - function next() { - iter.i += 1; - if ( iter.i <= iter.N ) { - return { - 'value': 1.0 - }; - } - return { - 'done': true - }; - } -}); - -tape( 'the method supports providing a "map" function which is invoked for each source element', function test( t ) { - var arr; - var v; - - // Generic array: - arr = Float16Array.from( [], clbk1 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Float16Array.from( [ 1.0, 2.0, 3.0, 4.0 ], clbk1 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - // Generic array containing non-numeric values: - arr = Float16Array.from( [ 'beep' ], clbk2 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - arr = Float16Array.from( [ null ], clbk2 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - arr = Float16Array.from( [ [], {} ], clbk1 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - arr = Float16Array.from( [ 4, 5 ], clbk1 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // Typed array: - arr = Float16Array.from( new Uint16Array( 0 ), clbk1 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Float16Array.from( new Uint16Array( [ 1, 1 ] ), clbk1 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // Floating-point number typed array: - arr = Float16Array.from( new Float16Array( 0 ), clbk2 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Float16Array.from( new Float16Array( [ true, true ] ), clbk2 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - t.end(); - - function clbk1( v ) { - return v; - } - - function clbk2() { - return true; - } -}); - -tape( 'the method supports providing a "map" function which is invoked for each iterated value', function test( t ) { - var Float16Array; - var iter; - var arr; - var v; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - iter = { - 'next': next, - 'i': 0, - 'N': 4 - }; - arr = Float16Array.from( createIterable( iter ), clbk ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, iter.N, 'returns expected value' ); - - t.end(); - - function hasSupport() { - return true; - } - - function createIterable( iterator ) { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return iterator; - } - } - - function next() { - iter.i += 1; - if ( iter.i <= iter.N ) { - return { - 'value': 1.0 - }; - } - return { - 'done': true - }; - } - - function clbk( v ) { - return !v; - } -}); - -tape( 'the method supports providing a `this` context for a provided map function', function test( t ) { - var arr; - var ctx; - - ctx = { - 'count': 0 - }; - arr = Float16Array.from( [ 1.0, 2.0, 3.0, 4.0 ], clbk1, ctx ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function clbk1( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v; - } -}); - -tape( 'the method supports providing a `this` context for a provided map function (iterable)', function test( t ) { - var Float16Array; - var iter; - var ctx; - var arr; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - iter = { - 'next': next, - 'i': 0, - 'N': 4 - }; - ctx = { - 'count': 0 - }; - - arr = Float16Array.from( createIterable( iter ), clbk, ctx ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function hasSupport() { - return true; - } - - function createIterable( iterator ) { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return iterator; - } - } - - function next() { - iter.i += 1; - if ( iter.i <= iter.N ) { - return { - 'value': 1.0 - }; - } - return { - 'done': true - }; - } - - function clbk( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v; - } -}); - -tape( 'the method throws an error if provided a non-iterable object (non-ES2015+)', function test( t ) { - var Float16Array; - var values; - var i; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - {}, - { - '0': 1, - '1': 2, - '2': 3 - } - ]; - 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 Float16Array.from( value ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the method throws an error if provided a non-iterable object (ES2015+)', function test( t ) { - var Float16Array; - var values; - var i; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - values = [ - {}, - { - '0': 1, - '1': 2, - '2': 3 - }, - { - '__SYMBOL_ITERATOR__': null - }, - { - '__SYMBOL_ITERATOR__': 'beep' - }, - { - '__SYMBOL_ITERATOR__': nonIterable1 - }, - { - '__SYMBOL_ITERATOR__': nonIterable2 - } - ]; - 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 Float16Array.from( value ); - }; - } - - function hasSupport() { - return true; - } - - function nonIterable1() { - return null; - } - - function nonIterable2() { - return {}; - } -}); diff --git a/test/polyfill/test.includes.js b/test/polyfill/test.includes.js deleted file mode 100644 index 8bb9850..0000000 --- a/test/polyfill/test.includes.js +++ /dev/null @@ -1,222 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `includes` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'includes' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.includes ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.includes.call( value, true ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a numeric value', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 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.includes( value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - 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.includes( true, value ); - }; - } -}); - -tape( 'the method returns `false` if operating on an empty floating-point number array', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( 0 ); - bool = arr.includes( 1.0 ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `false` if a floating-point number is not found', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( 10 ); - bool = arr.includes( 1.0 ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `true` if an array contains a specified floating-point number', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05] ); - bool = arr.includes( float64ToFloat16( 1.05 ) ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `false` if provided a second argument which exceeds the input array length', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( 10 ); - bool = arr.includes( 0.0, 20 ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 1.05, 1.05, 1.05 ] ); - - bool = arr.includes( float64ToFloat16( 1.05 ), 0 ); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = arr.includes( float64ToFloat16( 2.05 ), 1 ); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = arr.includes( float64ToFloat16( 2.05 ), 3 ); - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index (negative)', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 1.05, 1.05, 1.05 ] ); - - bool = arr.includes( float64ToFloat16( 1.05 ), -5 ); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = arr.includes( float64ToFloat16( 2.05 ), -2 ); - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'when provided a starting index which resolves to an index which is less than zero, the method searches from the first array element', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 1.05, 1.05, 1.05 ] ); - - bool = arr.includes( float64ToFloat16( 1.05 ), -10 ); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = arr.includes( float64ToFloat16( 2.05 ), -10 ); - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); -}); diff --git a/test/polyfill/test.index_of.js b/test/polyfill/test.index_of.js deleted file mode 100644 index b432c6d..0000000 --- a/test/polyfill/test.index_of.js +++ /dev/null @@ -1,222 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `indexOf` method for returning the index of an array element', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'indexOf' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.indexOf ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.indexOf.call( value, 1.0 ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a numeric value', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 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.indexOf( value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - 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.indexOf( 1.0, value ); - }; - } -}); - -tape( 'the method returns `-1` if operating on an empty floating-point number array', function test( t ) { - var arr; - var idx; - - arr = new Float16Array(); - idx = arr.indexOf( 1.0 ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `-1` if a numeric value is not found', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( 10 ); - idx = arr.indexOf( 1.0 ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns the index of the first match if a numeric value is found', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - idx = arr.indexOf( float64ToFloat16( 2.05 ) ); - - t.strictEqual( idx, 1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `-1` if provided a second argument which exceeds the input array length', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( 10 ); - idx = arr.indexOf( 1.0, 20 ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 2.05, 5.05 ] ); - - idx = arr.indexOf( float64ToFloat16( 2.05 ), 0 ); - t.strictEqual( idx, 1, 'returns expected value' ); - - idx = arr.indexOf( float64ToFloat16( 2.05 ), 2 ); - t.strictEqual( idx, 3, 'returns expected value' ); - - idx = arr.indexOf( float64ToFloat16( 2.05 ), 4 ); - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index (negative)', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 2.05, 5.05 ] ); - - idx = arr.indexOf( float64ToFloat16( 2.05 ), -5 ); - t.strictEqual( idx, 1, 'returns expected value' ); - - idx = arr.indexOf( float64ToFloat16( 2.05 ), -1 ); - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'when provided a starting index which resolves to an index which is less than zero, the method searches from the first array element', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 2.05, 5.05 ] ); - - idx = arr.indexOf( float64ToFloat16( 2.05 ), -10 ); - t.strictEqual( idx, 1, 'returns expected value' ); - - idx = arr.indexOf( float64ToFloat16( 1.05 ), -10 ); - t.strictEqual( idx, 0, 'returns expected value' ); - t.end(); -}); diff --git a/test/polyfill/test.join.js b/test/polyfill/test.join.js deleted file mode 100644 index 007f1cb..0000000 --- a/test/polyfill/test.join.js +++ /dev/null @@ -1,173 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `join` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'join' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.join ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.join.call( value ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `separator` argument which is not a string', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - 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.join( value ); - }; - } -}); - -tape( 'the method returns an empty string if invoked on an empty array', function test( t ) { - var str; - var arr; - - arr = new Float16Array( 0 ); - str = arr.join(); - - t.strictEqual( str, '', 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a string representation of a floating-point number array with elements separated by a separator', function test( t ) { - var expected; - var str; - var arr; - var i; - - arr = new Float16Array( [ 0.05, 1.05, 2.05, 3.05, 4.05 ] ); - - expected = float64ToFloat16( 0.05 ); - for ( i = 1; i < arr.length; i++ ) { - expected += '@' + float64ToFloat16( i + 0.05 ); - } - - str = arr.join( '@' ); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a string representation of a floating-point number array with elements separated by a separator (single element)', function test( t ) { - var expected; - var str; - var arr; - - arr = new Float16Array( [ 1.05 ] ); - expected = '' + float64ToFloat16( 1.05 ); - - str = arr.join(); - - t.strictEqual( str, expected, 'returns expected value' ); - - arr = new Float16Array( [ 1.05 ] ); - expected = '' + float64ToFloat16( 1.05 ); - - str = arr.join( '@' ); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if the method is invoked without a separator argument, the method returns a string representation of a floating-point number array with elements separated by a comma', function test( t ) { - var expected; - var str; - var arr; - var i; - - arr = new Float16Array( [ 0.05, 1.05, 2.05, 3.05, 4.05 ] ); - - expected = float64ToFloat16( 0.05 ); - for ( i = 1; i < arr.length; i++ ) { - expected += ',' + float64ToFloat16( i + 0.05 ); - } - - str = arr.join(); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); diff --git a/test/polyfill/test.js b/test/polyfill/test.js deleted file mode 100644 index 6e254ad..0000000 --- a/test/polyfill/test.js +++ /dev/null @@ -1,740 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 proxyquire = require( 'proxyquire' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var arr = new Float16Array( 0 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var ctor; - var arr; - - ctor = Float16Array; - - arr = ctor( 0 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (no argument)', function test( t ) { - var arr = new Float16Array(); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (no argument, no new)', function test( t ) { - var ctor; - var arr; - - ctor = Float16Array; - - arr = ctor(); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (length)', function test( t ) { - var arr = new Float16Array( 10 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (length, no new)', function test( t ) { - var ctor; - var arr; - - ctor = Float16Array; - - arr = ctor( 10 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (array)', function test( t ) { - var arr = new Float16Array( [] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (array, no new)', function test( t ) { - var ctor; - var arr; - - ctor = Float16Array; - - arr = ctor( [] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (typed array)', function test( t ) { - var arr = new Float16Array( new Uint16Array( 0 ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (typed array, no new)', function test( t ) { - var ctor; - var arr; - - ctor = Float16Array; - - arr = ctor( new Uint16Array( 0 ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (iterable)', function test( t ) { - var Float16Array; - var arr; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - arr = new Float16Array( createIterable() ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); - - function hasSupport() { - return true; - } - - function createIterable() { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return { - 'next': next - }; - } - - function next() { - return { - 'done': true - }; - } - } -}); - -tape( 'the constructor returns a 16-bit floating-point number array (iterable, no new)', function test( t ) { - var ctor; - var arr; - - ctor = proxyquire( './../../lib/polyfill', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - arr = ctor( createIterable() ); - t.strictEqual( arr instanceof ctor, true, 'returns expected value' ); - - t.end(); - - function hasSupport() { - return true; - } - - function createIterable() { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return { - 'next': next - }; - } - - function next() { - return { - 'done': true - }; - } - } -}); - -tape( 'the constructor returns a 16-bit floating-point number array (ArrayBuffer)', function test( t ) { - var arr = new Float16Array( new ArrayBuffer( 0 ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (ArrayBuffer, no new)', function test( t ) { - var ctor; - var arr; - - ctor = Float16Array; - - arr = ctor( new ArrayBuffer( 0 ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (ArrayBuffer, byte offset)', function test( t ) { - var arr = new Float16Array( new ArrayBuffer( 8 ), 8 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (ArrayBuffer, byte offset, no new)', function test( t ) { - var ctor; - var arr; - - ctor = Float16Array; - - arr = ctor( new ArrayBuffer( 8 ), 8 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (ArrayBuffer, byte offset, length)', function test( t ) { - var arr = new Float16Array( new ArrayBuffer( 8 ), 8, 0 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (ArrayBuffer, byte offset, length, no new)', function test( t ) { - var ctor; - var arr; - - ctor = Float16Array; - - arr = ctor( new ArrayBuffer( 8 ), 8, 0 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'attached to the constructor is a property returning the number of bytes per array element', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Float16Array.BYTES_PER_ELEMENT, 2, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the constructor is a property returning the constructor name', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array, 'name' ), true, 'has property' ); - t.strictEqual( Float16Array.name, 'Float16Array', 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance having a `BYTES_PER_ELEMENT` property returning the number of bytes per array element', function test( t ) { - var arr; - - t.strictEqual( hasOwnProp( Float16Array.prototype, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Float16Array.prototype.BYTES_PER_ELEMENT, 2, 'returns expected value' ); - - arr = new Float16Array( 0 ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance having a `buffer` property for returning the underlying memory (i.e., ArrayBuffer)', function test( t ) { - var arr; - var buf; - - arr = new Float16Array( 0 ); - buf = arr.buffer; - t.strictEqual( isArrayBuffer( buf ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance having a `byteLength` property for returning the number of bytes belonging to the array view', function test( t ) { - var arr; - var v; - - arr = new Float16Array( 0 ); - v = arr.byteLength; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( new ArrayBuffer( 64 ), 8 ); - v = arr.byteLength; - t.strictEqual( v, 56, 'returns expected value' ); - - arr = new Float16Array( new ArrayBuffer( 64 ), 64 ); - v = arr.byteLength; - t.strictEqual( v, 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance having a `byteOffset` property for returning the byte offset pointing to the first array element in the underlying memory', function test( t ) { - var arr; - var v; - - arr = new Float16Array( 0 ); - v = arr.byteOffset; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( new ArrayBuffer( 64 ), 32 ); - v = arr.byteOffset; - t.strictEqual( v, 32, 'returns expected value' ); - - arr = new Float16Array( new ArrayBuffer( 64 ), 64 ); - v = arr.byteOffset; - t.strictEqual( v, 64, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance having a `length` property for returning the number of array elements', function test( t ) { - var arr; - var v; - - // No arguments: - arr = new Float16Array(); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - // Explicit array length: - arr = new Float16Array( 0 ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( 10 ); - v = arr.length; - t.strictEqual( v, 10, 'returns expected value' ); - - // Generic array: - arr = new Float16Array( [] ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - // Typed array: - arr = new Float16Array( new Uint16Array( 0 ) ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( new Uint16Array( [ 1.0, 1.0 ] ) ); - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // Float16 typed array: - arr = new Float16Array( new Float16Array( 0 ) ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( new Float16Array( [ 1.0, 2.0 ] ) ); - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // ArrayBuffer: - arr = new Float16Array( new ArrayBuffer( 64 ), 32 ); - v = arr.length; - t.strictEqual( v, 16, 'returns expected value' ); - - arr = new Float16Array( new ArrayBuffer( 64 ), 64 ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( new ArrayBuffer( 64 ), 32, 2 ); - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance having a `length` property for returning the number of array elements (iterable)', function test( t ) { - var Float16Array; - var iter; - var arr; - var v; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - iter = { - 'next': next, - 'i': 0, - 'N': 4 - }; - arr = new Float16Array( createIterable( iter ) ); - v = arr.length; - t.strictEqual( v, iter.N, 'returns expected value' ); - - t.end(); - - function hasSupport() { - return true; - } - - function createIterable( iterator ) { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return iterator; - } - } - - function next() { - iter.i += 1; - if ( iter.i <= iter.N ) { - return { - 'value': 1.0 - }; - } - return { - 'done': true - }; - } -}); - -tape( 'the constructor throws an error if provided an ArrayBuffer which is not a multiple of 2', function test( t ) { - var values; - var i; - - values = [ - 1, - 3, - 5, - 7, - 9, - 11, - 101, - 1001 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided an ArrayBuffer having a byte length equal to '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Float16Array( new ArrayBuffer( value ) ); - }; - } -}); - -tape( 'the constructor throws an error if provided a non-iterable object (non-ES2015+)', function test( t ) { - var Float16Array; - var values; - var i; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - {}, - { - '0': 1, - '1': 2, - '2': 3 - } - ]; - 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 new Float16Array( value ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the constructor throws an error if provided a non-iterable object (ES2015+)', function test( t ) { - var Float16Array; - var values; - var i; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - values = [ - {}, - { - '0': 1, - '1': 2, - '2': 3 - }, - { - '__SYMBOL_ITERATOR__': null - }, - { - '__SYMBOL_ITERATOR__': 'beep' - }, - { - '__SYMBOL_ITERATOR__': nonIterable1 - }, - { - '__SYMBOL_ITERATOR__': nonIterable2 - } - ]; - 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 new Float16Array( value ); - }; - } - - function hasSupport() { - return true; - } - - function nonIterable1() { - return null; - } - - function nonIterable2() { - return {}; - } -}); - -tape( 'the constructor throws an error if not provided a length, iterable, array-like object, or ArrayBuffer', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - 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 new Float16Array( value ); - }; - } -}); - -tape( 'the constructor throws an error if provided more than one argument and the first argument is not an ArrayBuffer', function test( t ) { - var values; - var i; - - 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 new Float16Array( value, 0 ); - }; - } -}); - -tape( 'the constructor throws an error if provided a byte offset argument which is not a nonnegative integer', function test( t ) { - var values; - var i; - - values = [ - '5', - -1, - 3.14, - 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 new Float16Array( new ArrayBuffer( 64 ), value ); - }; - } -}); - -tape( 'the constructor throws an error if provided a byte offset argument which is not a multiple of 2', function test( t ) { - var values; - var i; - - values = [ - 1, - 3, - 5, - 7, - 9, - 11, - 101, - 1001 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Float16Array( new ArrayBuffer( 1e3 ), value ); - }; - } -}); - -tape( 'the constructor throws an error if provided a byte offset argument such that the view byte length is not a multiple of 8', function test( t ) { - var values; - var i; - - values = [ - 2, - 4, - 6, - 8, - 10, - 12, - 14, - 16, - 18, - 20 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Float16Array( new ArrayBuffer( 101 ), value ); - }; - } -}); - -tape( 'the constructor throws an error if provided a length argument which is not a nonnegative integer (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - -1, - 3.14, - 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 new Float16Array( new ArrayBuffer( 64 ), 0, value ); - }; - } -}); - -tape( 'the constructor throws an error if provided insufficient memory to accommodate byte offset and length arguments', function test( t ) { - var values; - var i; - - values = [ - 8, - 16, - 24, - 32 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Float16Array( new ArrayBuffer( 100 ), value, 1e3 ); - }; - } -}); diff --git a/test/polyfill/test.keys.js b/test/polyfill/test.keys.js deleted file mode 100644 index 59c6210..0000000 --- a/test/polyfill/test.keys.js +++ /dev/null @@ -1,261 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 proxyquire = require( 'proxyquire' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `keys` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'keys' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.keys ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.keys.call( value ); - }; - } -}); - -tape( 'the method returns an iterator protocol-compliant object', function test( t ) { - var expected; - var arr; - var it; - var i; - var r; - var e; - - arr = new Float16Array( [ 1.05, 2.05 ] ); - expected = [ - { - 'value': 0, - 'done': false - }, - { - 'value': 1, - 'done': false - }, - { - 'done': true - } - ]; - it = arr.keys(); - - t.strictEqual( typeof it, 'object', 'returns expected value' ); - t.strictEqual( typeof it.next, 'function', 'has next method' ); - - for ( i = 0; i < expected.length; i++ ) { - r = it.next(); - e = expected[ i ]; - if ( e.value === void 0 ) { - t.deepEqual( r, e, 'returns expected value' ); - } else { - t.strictEqual( r.value, e.value, 'returns expected value' ); - t.strictEqual( r.done, e.done, 'returns expected value' ); - } - } - - t.end(); -}); - -tape( 'the method returns an iterator which does not iterate over empty arrays', function test( t ) { - var expected; - var arr; - var it; - var i; - var v; - - arr = new Float16Array( [] ); - expected = [ - { - 'done': true - }, - { - 'done': true - }, - { - 'done': true - } - ]; - it = arr.keys(); - - t.strictEqual( typeof it, 'object', 'returns expected value' ); - t.strictEqual( typeof it.next, 'function', 'has next method' ); - - for ( i = 0; i < expected.length; i++ ) { - v = it.next(); - t.deepEqual( v, expected[ i ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (no argument)', function test( t ) { - var arr; - var it; - var v; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - it = arr.keys(); - - v = it.next(); - t.strictEqual( v.value, 0, 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, 1, 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.return(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (argument)', function test( t ) { - var arr; - var it; - var v; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - it = arr.keys(); - - v = it.next(); - t.strictEqual( v.value, 0, 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, 1, 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.return( 'beep' ); - t.strictEqual( v.value, 'beep', 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'if an environment supports `Symbol.iterator`, the method returns an iterable', function test( t ) { - var Float16Array; - var arr; - var buf; - var it1; - var it2; - var v1; - var v2; - var i; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - buf = [ 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( buf ); - - it1 = arr.keys(); - t.strictEqual( typeof it1[ '__ITERATOR_SYMBOL__' ], 'function', 'has method' ); - t.strictEqual( it1[ '__ITERATOR_SYMBOL__' ].length, 0, 'has zero arity' ); - - it2 = it1[ '__ITERATOR_SYMBOL__' ](); - t.strictEqual( typeof it2, 'object', 'returns expected value' ); - t.strictEqual( typeof it2.next, 'function', 'has `next` method' ); - t.strictEqual( typeof it2.return, 'function', 'has `return` method' ); - - for ( i = 0; i < arr.length; i++ ) { - v1 = it1.next().value; - v2 = it2.next().value; - t.strictEqual( v1, v2, 'returns expected value' ); - } - t.end(); -}); - -tape( 'if an environment does not support `Symbol.iterator`, the method does not return an "iterable"', function test( t ) { - var Float16Array; - var arr; - var buf; - var it; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/symbol-iterator': false - }); - - buf = [ 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( buf ); - - it = arr.keys(); - t.strictEqual( it[ ITERATOR_SYMBOL ], void 0, 'does not have property' ); - - t.end(); -}); diff --git a/test/polyfill/test.last_index_of.js b/test/polyfill/test.last_index_of.js deleted file mode 100644 index 6a2fe99..0000000 --- a/test/polyfill/test.last_index_of.js +++ /dev/null @@ -1,211 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `lastIndexOf` method for returning the index of an array element', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'lastIndexOf' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.lastIndexOf ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.lastIndexOf.call( value, true ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a numeric value', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 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.lastIndexOf( value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - 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.lastIndexOf( true, value ); - }; - } -}); - -tape( 'the method returns `-1` if operating on an empty floating-point number array', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( 0 ); - idx = arr.lastIndexOf( 0.0 ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `-1` if a numeric value is not found', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( 10 ); - idx = arr.lastIndexOf( 1.0 ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns the index of the first match when searching from the end of the array if a search element is found', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 1.05, 2.05 ] ); - idx = arr.lastIndexOf( float64ToFloat16( 1.05 ) ); - - t.strictEqual( idx, 2, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 2.05, 1.05, 1.05 ] ); - - idx = arr.lastIndexOf( float64ToFloat16( 1.05 ), 4 ); - t.strictEqual( idx, 4, 'returns expected value' ); - - idx = arr.lastIndexOf( float64ToFloat16( 2.05 ), 2 ); - t.strictEqual( idx, 2, 'returns expected value' ); - - idx = arr.lastIndexOf( float64ToFloat16( 2.05 ), 0 ); - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index (negative)', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 2.05, 1.05, 1.05 ] ); - - idx = arr.lastIndexOf( float64ToFloat16( 1.05 ), -3 ); - t.strictEqual( idx, 0, 'returns expected value' ); - - idx = arr.lastIndexOf( float64ToFloat16( 2.05 ), -1 ); - t.strictEqual( idx, 2, 'returns expected value' ); - t.end(); -}); - -tape( 'when the method is provided a starting index which resolves to an index which exceeds the maximum array index, the method searches from the last array element', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 2.05, 1.05, 1.05 ] ); - - idx = arr.lastIndexOf( float64ToFloat16( 1.05 ), 10 ); - t.strictEqual( idx, 4, 'returns expected value' ); - - idx = arr.lastIndexOf( float64ToFloat16( 2.05 ), 10 ); - t.strictEqual( idx, 2, 'returns expected value' ); - t.end(); -}); diff --git a/test/polyfill/test.map.js b/test/polyfill/test.map.js deleted file mode 100644 index 233d1d8..0000000 --- a/test/polyfill/test.map.js +++ /dev/null @@ -1,178 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 identity = require( '@stdlib/utils-identity-function' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `map` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'map' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.map ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.map.call( value, identity ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.map( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.map( identity ); - - t.strictEqual( instanceOf( out, Float16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - t.notEqual( out, arr, 'returns a new instance' ); - t.end(); -}); - -tape( 'the method returns a new floating-point number array containing elements which are the result of a provided callback function', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( -1.05 ), - toWord( -2.05 ), - toWord( -3.05 ), - toWord( -4.05 ) - ]); - actual = arr.map( invert ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.notEqual( actual, arr, 'returns a new instance' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); - - function invert( v ) { - return -v; - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var expected; - var actual; - var arr; - var buf; - var ctx; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( -1.05 ), - toWord( -2.05 ), - toWord( -3.05 ), - toWord( -4.05 ) - ]); - ctx = { - 'count': 0 - }; - actual = arr.map( invert, ctx ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.strictEqual( ctx.count, 6, 'returns expected value' ); - t.end(); - - function invert( v, i ) { - this.count += i; // eslint-disable-line no-invalid-this - return -v; - } -}); diff --git a/test/polyfill/test.of.js b/test/polyfill/test.of.js deleted file mode 100644 index 5031bb5..0000000 --- a/test/polyfill/test.of.js +++ /dev/null @@ -1,130 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `of` method for creating a 16-bit floating-point number array from a variable number of arguments', function test( t ) { - var arr; - - t.strictEqual( hasOwnProp( Float16Array, 'of' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.of ), true, 'has method' ); - - arr = Float16Array.of(); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a constructor', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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 Float16Array.of.call( value, true, true ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point array constructor', function test( t ) { - var values; - var i; - - values = [ - {}, - null, - 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 Float16Array.of.call( value, true, true ); - }; - } -}); - -tape( 'the method returns a floating-point number array', function test( t ) { - var arr; - var v; - - // No arguments: - arr = Float16Array.of(); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - // Numeric arguments: - arr = Float16Array.of( 1.0, 2.0, 3.0, 4.0 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - // Non-numeric arguments: - arr = Float16Array.of( 1, {}, 0, null, 'beep' ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 5, 'returns expected value' ); - - // Mixed arguments: - arr = Float16Array.of( true, 1, false, 0 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - t.end(); -}); diff --git a/test/polyfill/test.reduce.js b/test/polyfill/test.reduce.js deleted file mode 100644 index 7d9cbc0..0000000 --- a/test/polyfill/test.reduce.js +++ /dev/null @@ -1,189 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `reduce` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'reduce' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.reduce ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.reduce.call( value, reducer ); - }; - } - - function reducer( acc, value ) { - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.reduce( value ); - }; - } -}); - -tape( 'the method throws an error if not provided an initial value when operating on an empty floating-point number array', function test( t ) { - var arr; - - arr = new Float16Array( 0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - arr.reduce( reducer ); - } - - function reducer( acc, value ) { - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method uses the first element of the array as the initial value when an initial value is not provided', function test( t ) { - var valueArray; - var accArray; - var expected; - var actual; - var arr; - var ind; - - arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - accArray = [ 1.0, 3.0 ]; - valueArray = [ 2.0, 3.0 ]; - expected = float64ToFloat16( 6.0 ); - actual = arr.reduce( reducer ); - - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); - - function reducer( acc, value, index ) { - ind = index-1; - t.strictEqual( acc, float64ToFloat16( accArray[ ind ] ), 'returns expected value' ); - t.strictEqual( value, float64ToFloat16( valueArray[ ind ] ), 'returns expected value' ); - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method supports providing an initial value as the second argument', function test( t ) { - var valueArray; - var accArray; - var expected; - var actual; - var arr; - - arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - accArray = [ 2.0, 3.0, 5.0 ]; - valueArray = [ 1.0, 2.0, 3.0 ]; - expected = 8.0; - actual = arr.reduce( reducer, 2.0 ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value, index ) { - t.strictEqual( acc, float64ToFloat16( accArray[ index ] ), 'returns expected value' ); - t.strictEqual( value, float64ToFloat16( valueArray[ index ] ), 'returns expected value' ); - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method returns the accumulated result', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = float64ToFloat16( 10.20 ); - actual = arr.reduce( reducer ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value ) { - return float64ToFloat16( acc + value ); - } -}); diff --git a/test/polyfill/test.reduce_right.js b/test/polyfill/test.reduce_right.js deleted file mode 100644 index 0d27e43..0000000 --- a/test/polyfill/test.reduce_right.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `reduceRight` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'reduceRight' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.reduceRight ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.reduceRight.call( value, reducer ); - }; - } - - function reducer( acc, value ) { - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.reduceRight( value ); - }; - } -}); - -tape( 'the method throws an error if not provided an initial value when operating on an empty floating-point number array', function test( t ) { - var arr; - - arr = new Float16Array( 0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - arr.reduceRight( reducer ); - } - - function reducer( acc, value ) { - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method uses the last element of the array as the initial value when an initial value is not provided', function test( t ) { - var valueArray; - var accArray; - var expected; - var actual; - var arr; - var len; - - arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - len = arr.length; - accArray = [ 3.0, 5.0 ]; - valueArray = [ 2.0, 1.0 ]; - expected = float64ToFloat16( 6.0 ); - actual = arr.reduceRight( reducer ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value, index ) { - var ind = (len-index-2); - t.strictEqual( acc, float64ToFloat16( accArray[ ind ] ), 'returns expected value' ); - t.strictEqual( value, float64ToFloat16( valueArray[ ind ] ), 'returns expected value' ); - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method supports providing an initial value as the second argument', function test( t ) { - var valueArray; - var accArray; - var expected; - var actual; - var arr; - var len; - - arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - len = arr.length; - accArray = [ 2.0, 5.0, 7.0 ]; - valueArray = [ 3.0, 2.0, 1.0 ]; - expected = 8.0; - actual = arr.reduceRight( reducer, 2.0 ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value, index ) { - var ind = (len-index-1); - t.strictEqual( acc, float64ToFloat16( accArray[ ind ] ), 'returns expected value' ); - t.strictEqual( value, float64ToFloat16( valueArray[ ind ] ), 'returns expected value' ); - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method returns the accumulated result', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = float64ToFloat16( 10.20 ); - actual = arr.reduceRight( reducer ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value ) { - return float64ToFloat16( acc + value ); - } -}); diff --git a/test/polyfill/test.reverse.js b/test/polyfill/test.reverse.js deleted file mode 100644 index 080a4c3..0000000 --- a/test/polyfill/test.reverse.js +++ /dev/null @@ -1,122 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 instanceOf = require( '@stdlib/assert-instance-of' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, '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( Float16Array.prototype, 'reverse' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.reverse ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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 floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - 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 floating-point number array in-place', function test( t ) { - var expected; - var arr; - var buf; - var out; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05, 5.05 ] ); - expected = new Uint16Array([ - toWord( 5.05 ), - toWord( 4.05 ), - toWord( 3.05 ), - toWord( 2.05 ), - toWord( 1.05 ) - ]); - out = arr.reverse(); - buf = new Uint16Array( arr.buffer ); - - t.strictEqual( instanceOf( arr, Float16Array ), true, 'returns expected value' ); - t.strictEqual( out, arr, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 10 ); - out = arr.reverse(); - - t.strictEqual( out.length, 10, 'returns expected value' ); - t.end(); -}); diff --git a/test/polyfill/test.set.js b/test/polyfill/test.set.js deleted file mode 100644 index d5e0ebb..0000000 --- a/test/polyfill/test.set.js +++ /dev/null @@ -1,259 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `set` method for setting one or more array elements', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.set ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.set.call( value, 0 ); - }; - } -}); - -tape( 'the method throws an error if provided an index argument which is not a nonnegative integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - -5, - 3.14, - 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.set( [ 1.0 ], value ); - }; - } -}); - -tape( 'the method throws an error if provided an index argument which is out-of-bounds', function test( t ) { - var values; - var arr1; - var arr2; - var i; - - arr1 = new Float16Array( 10 ); - arr2 = []; - for ( i = 0; i < arr1.length; i++ ) { - arr2.push( 1.0 ); - } - - values = [ - 1, - 2, - 3, - 4, - 5 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr1.set( arr2, value ); - }; - } -}); - -tape( 'the method sets one or more array elements', function test( t ) { - var arr; - var v; - var i; - - arr = new Float16Array( 10 ); - - v = arr[ 0 ]; - t.strictEqual( v, 0.0, 'returns expected value' ); - - // No index argument: - arr.set( [ 1.0 ] ); - - v = arr[ 0 ]; - t.strictEqual( v, 1.0, 'returns expected value' ); - - arr.set( [ 0.0 ] ); - - // Index argument: - for ( i = 0; i < arr.length; i++ ) { - v = arr[ i ]; - t.strictEqual( v, 0.0, 'returns expected value' ); - - arr.set( [ 1.05 ], i ); - - v = arr[ i ]; - t.strictEqual( v, float64ToFloat16( 1.05 ), 'returns expected value' ); - } - - // Multiple values, no index argument: - arr.set( [ 1.05, 2.05 ] ); - - v = arr[ 0 ]; - t.strictEqual( v, float64ToFloat16( 1.05 ), 'returns expected value' ); - - v = arr[ 1 ]; - t.strictEqual( v, float64ToFloat16( 2.05 ), 'returns expected value' ); - - // Multiple values, index argument: - arr.set( [ 1.05, 2.05 ], 2 ); - - v = arr[ 2 ]; - t.strictEqual( v, float64ToFloat16( 1.05 ), 'returns expected value' ); - - v = arr[ 3 ]; - t.strictEqual( v, float64ToFloat16( 2.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method sets an array element (floating-point number array; shared buffer)', function test( t ) { - var byteOffset; - var arr; - var src; - var buf; - var ab; - var v; - var i; - - byteOffset = 112; - - ab = new ArrayBuffer( 240 ); - arr = new Float16Array( ab, byteOffset, 10 ); - - // Overlapping (requires copy), multiple values, no index argument: - buf = [ 1.05, 2.05 ]; - src = new Float16Array( ab, byteOffset-(1*arr.BYTES_PER_ELEMENT), 2 ); - for ( i = 0; i < buf.length; i++ ) { - src[ i ] = buf[ i ]; - } - arr.set( src ); - - v = arr[ 0 ]; - t.strictEqual( v, float64ToFloat16( buf[ 0 ] ), 'returns expected value' ); - - v = arr[ 1 ]; - t.strictEqual( v, float64ToFloat16( buf[ 1 ] ), 'returns expected value' ); - - // Overlapping (requires copy), multiple values, index argument: - buf = [ -1.05, -2.05 ]; - src = new Float16Array( ab, byteOffset+(1*arr.BYTES_PER_ELEMENT), 2 ); - for ( i = 0; i < buf.length; i++ ) { - src[ i ] = buf[ i ]; - } - arr.set( src, 2 ); - - v = arr[ 2 ]; - t.strictEqual( v, float64ToFloat16( buf[ 0 ] ), 'returns expected value' ); - - v = arr[ 3 ]; - t.strictEqual( v, float64ToFloat16( buf[ 1 ] ), 'returns expected value' ); - - // Overlapping (no copy), multiple values, no index argument: - buf = [ 3.05, 4.05 ]; - src = new Float16Array( ab, byteOffset+(1*arr.BYTES_PER_ELEMENT), 2 ); - for ( i = 0; i < buf.length; i++ ) { - src[ i ] = buf[ i ]; - } - arr.set( src ); - - v = arr[ 0 ]; - t.strictEqual( v, float64ToFloat16( buf[ 0 ] ), 'returns expected value' ); - - v = arr[ 1 ]; - t.strictEqual( v, float64ToFloat16( buf[ 1 ] ), 'returns expected value' ); - - // Overlapping (no copy), multiple values, index argument: - buf = [ -3.05, -4.05 ]; - src = new Float16Array( ab, byteOffset+(3*arr.BYTES_PER_ELEMENT), 2 ); - for ( i = 0; i < buf.length; i++ ) { - src[ i ] = buf[ i ]; - } - arr.set( src, 2 ); - - v = arr[ 2 ]; - t.strictEqual( v, float64ToFloat16( buf[ 0 ] ), 'returns expected value' ); - - v = arr[ 3 ]; - t.strictEqual( v, float64ToFloat16( buf[ 1 ] ), 'returns expected value' ); - - t.end(); -}); diff --git a/test/polyfill/test.slice.js b/test/polyfill/test.slice.js deleted file mode 100644 index f6743cb..0000000 --- a/test/polyfill/test.slice.js +++ /dev/null @@ -1,311 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 instanceOf = require( '@stdlib/assert-instance-of' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `slice` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'slice' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.slice ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.slice.call( value ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.slice( value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.slice( 0, value ); - }; - } -}); - -tape( 'the method returns an empty typed array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.slice(); - - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'if called without arguments, the method returns a typed array containing the same elements as the original array', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ) - ]); - actual = arr.slice(); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.notEqual( actual, arr, 'returns a new instance' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if called with one argument, the method returns a typed array containing elements starting from a specified beginning index (inclusive)', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ) - ]); - actual = arr.slice( 1 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if provided two arguments, the method returns a typed array containing elements starting from a specified beginning index (inclusive) and ending at a specified stop index (exclusive)', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ) - ]); - actual = arr.slice( 1, 3 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ) - ]); - actual = arr.slice( 1, 30 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method resolves negative indices relative to the last element', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ) - ]); - actual = arr.slice( -3, -1 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ) - ]); - actual = arr.slice( -30, -2 ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty typed array if a resolved beginning index exceeds a resolved ending index', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array( [] ); - actual = arr.slice( 2, 0 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty typed array if a resolved beginning index exceeds the maximum array index', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array( [] ); - actual = arr.slice( 5 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty typed array if a resolved ending index is less than or equal to zero', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); - expected = new Uint16Array( [] ); - actual = arr.slice( 2, -8 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - - actual = arr.slice( 1, 0 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); diff --git a/test/polyfill/test.some.js b/test/polyfill/test.some.js deleted file mode 100644 index dfa9cda..0000000 --- a/test/polyfill/test.some.js +++ /dev/null @@ -1,196 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `some` method for returning boolean indicating whether at least one element passes a test', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'some' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.some ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.some.call( value, predicate ); - }; - } - - function predicate( v ) { - return v === 1.0; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.some( value ); - }; - } -}); - -tape( 'the method returns `false` if operating on an empty floating-point number array', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( 0 ); - bool = arr.some( predicate ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns `true` if at least one element passes a test', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - bool = arr.some( predicate ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v === float64ToFloat16( 1.05 ); - } -}); - -tape( 'the method returns `false` if all elements fail a test', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - bool = arr.some( predicate ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v === float64ToFloat16( 5.05 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var bool; - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - bool = arr.some( predicate, ctx ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v === float64ToFloat16( 4.05 ); - } -}); - -tape( 'the method stops executing upon encountering the first element which passes a test', function test( t ) { - var bool; - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - bool = arr.some( predicate, ctx ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.strictEqual( ctx.count, 1, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v === float64ToFloat16( 1.05 ); - } -}); diff --git a/test/polyfill/test.sort.js b/test/polyfill/test.sort.js deleted file mode 100644 index 1ebbfd6..0000000 --- a/test/polyfill/test.sort.js +++ /dev/null @@ -1,189 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 instanceOf = require( '@stdlib/assert-instance-of' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Comparison function. -* -* @private -* @param {boolean} a - first value for comparison -* @param {boolean} b - second value for comparison -* @returns {number} comparison result -*/ -function compareFcn( a, b ) { - if ( a < b ) { - return -1; - } - if ( a > b ) { - return 1; - } - return 0; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `sort` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'sort' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.sort ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.sort.call( value, compareFcn ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.sort( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.sort( compareFcn ); - - t.strictEqual( out.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the method sorts elements of a floating-point number array in-place', function test( t ) { - var expected; - var arr; - var out; - var buf; - - arr = new Float16Array( [ 4.05, 3.05, 1.05, 5.05, 2.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ), - toWord( 5.05 ) - ]); - out = arr.sort( compareFcn ); - buf = new Uint16Array( out.buffer ); - - t.strictEqual( instanceOf( arr, Float16Array ), true, 'returns expected value' ); - t.strictEqual( out, arr, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - - arr = new Float16Array( [ 2.05, 1.05, -1.05, 0.05, -2.05 ] ); - expected = new Uint16Array([ - toWord( -2.05 ), - toWord( -1.05 ), - toWord( 0.05 ), - toWord( 1.05 ), - toWord( 2.05 ) - ]); - out = arr.sort( compareFcn ); - buf = new Uint16Array( out.buffer ); - - t.strictEqual( instanceOf( arr, Float16Array ), true, 'returns expected value' ); - t.strictEqual( out, arr, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Float16Array( [ 4.05, 3.05, 1.05, 5.05, 2.05 ] ); - out = arr.sort( compareFcn ); - - t.strictEqual( out.length, arr.length, 'returns expected value' ); - t.end(); -}); diff --git a/test/polyfill/test.subarray.js b/test/polyfill/test.subarray.js deleted file mode 100644 index c6d42d1..0000000 --- a/test/polyfill/test.subarray.js +++ /dev/null @@ -1,308 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 instanceOf = require( '@stdlib/assert-instance-of' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `subarray` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'subarray' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.subarray ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.subarray.call( value ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.subarray( value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.subarray( 0, value ); - }; - } -}); - -tape( 'the method returns empty array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.subarray(); - - t.strictEqual( out.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'if called without arguments, the method returns a view containing the same elements as the original array', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ) - ]); - actual = arr.subarray(); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if called with one argument, the method returns a view containing elements starting from a specified beginning index (inclusive)', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ) - ]); - actual = arr.subarray( 1 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if provided two arguments, the method returns a view containing elements starting from a specified beginning index (inclusive) and ending at a specified stop index (exclusive)', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ) - ]); - actual = arr.subarray( 1, 3 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method resolves negative indices relative to the last element', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ) - ]); - actual = arr.subarray( -3, -1 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 2.05 ) - ]); - actual = arr.subarray( -30, -2 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty view if a resolved beginning index exceeds a resolved ending index', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array( [] ); - actual = arr.subarray( 2, 0 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty view if a resolved beginning index exceeds the maximum array index', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array( [] ); - actual = arr.subarray( 5 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty view if a resolved ending index is less than or equal to zero', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array( [] ); - actual = arr.subarray( 2, -8 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - - actual = arr.subarray( 1, 0 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); diff --git a/test/polyfill/test.to_locale_string.js b/test/polyfill/test.to_locale_string.js deleted file mode 100644 index 96fb9b0..0000000 --- a/test/polyfill/test.to_locale_string.js +++ /dev/null @@ -1,187 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `toLocaleString` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'toLocaleString' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.toLocaleString ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.toLocaleString.call( value ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a string or an array of strings', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 0 ); - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - {}, - [ 1, 2, 3 ], - 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.toLocaleString( value ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a string or an array of strings (options)', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 0 ); - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - {}, - [ 1, 2, 3 ], - 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.toLocaleString( value, {} ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an object', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array(); - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - 'beep', - [], - 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.toLocaleString( 'en-GB', value ); - }; - } -}); - -tape( 'the method returns an empty string if invoked on an empty array', function test( t ) { - var str; - var arr; - - arr = new Float16Array( 0 ); - str = arr.toLocaleString(); - - t.strictEqual( str, '', 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a string representation of a floating-point number array', function test( t ) { - var expected; - var str; - var arr; - - arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - expected = '1,2,3'; - - str = arr.toLocaleString(); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); diff --git a/test/polyfill/test.to_reversed.js b/test/polyfill/test.to_reversed.js deleted file mode 100644 index a3f8da5..0000000 --- a/test/polyfill/test.to_reversed.js +++ /dev/null @@ -1,121 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 instanceOf = require( '@stdlib/assert-instance-of' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, '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( Float16Array.prototype, 'toReversed' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.toReversed ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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 floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - 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 buf; - var out; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05, 5.05 ] ); - expected = new Uint16Array([ - toWord( 5.05 ), - toWord( 4.05 ), - toWord( 3.05 ), - toWord( 2.05 ), - toWord( 1.05 ) - ]); - out = arr.toReversed(); - buf = new Uint16Array( out.buffer ); - - t.strictEqual( instanceOf( out, Float16Array ), true, 'returns expected value' ); - t.notEqual( out, arr, 'returns a new instance' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 10 ); - out = arr.toReversed(); - - t.strictEqual( out.length, 10, 'returns expected value' ); - t.end(); -}); diff --git a/test/polyfill/test.to_sorted.js b/test/polyfill/test.to_sorted.js deleted file mode 100644 index e011bef..0000000 --- a/test/polyfill/test.to_sorted.js +++ /dev/null @@ -1,172 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 instanceOf = require( '@stdlib/assert-instance-of' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Comparison function. -* -* @private -* @param {boolean} a - first value for comparison -* @param {boolean} b - second value for comparison -* @returns {number} comparison result -*/ -function compareFcn( a, b ) { - if ( a < b ) { - return -1; - } - if ( a > b ) { - return 1; - } - return 0; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `toSorted` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'toSorted' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.toSorted ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.toSorted.call( value, compareFcn ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.toSorted( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.toSorted( compareFcn ); - - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a new typed array containing elements in sorted order', function test( t ) { - var expected; - var arr; - var out; - var buf; - - arr = new Float16Array( [ 4.05, 3.05, 1.05, 5.05, 2.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ), - toWord( 5.05 ) - ]); - out = arr.toSorted( compareFcn ); - buf = new Uint16Array( out.buffer ); - - t.strictEqual( instanceOf( out, Float16Array ), true, 'returns expected value' ); - t.notEqual( out, arr, 'returns a new instance' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Float16Array( [ 4.05, 3.05, 1.05, 5.05, 2.05 ] ); - out = arr.toSorted( compareFcn ); - - t.strictEqual( out.length, arr.length, 'returns expected value' ); - t.end(); -}); diff --git a/test/polyfill/test.to_string.js b/test/polyfill/test.to_string.js deleted file mode 100644 index b0c098b..0000000 --- a/test/polyfill/test.to_string.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `toString` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.toString ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.toString.call( value ); - }; - } -}); - -tape( 'the method returns an empty string if invoked on an empty array', function test( t ) { - var str; - var arr; - - arr = new Float16Array( 0 ); - str = arr.toString(); - - t.strictEqual( str, '', 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a string representation of a floating-point number array', function test( t ) { - var expected; - var str; - var arr; - - arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - expected = '1,2,3,4'; - - str = arr.toString(); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); diff --git a/test/polyfill/test.values.js b/test/polyfill/test.values.js deleted file mode 100644 index ce5fc09..0000000 --- a/test/polyfill/test.values.js +++ /dev/null @@ -1,264 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 proxyquire = require( 'proxyquire' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var isNumber = require( '@stdlib/assert-is-number' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `values` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'values' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.values ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.values.call( value ); - }; - } -}); - -tape( 'the method returns an iterator protocol-compliant object', function test( t ) { - var expected; - var arr; - var it; - var i; - var r; - var e; - - arr = new Float16Array( [ 1.05, 2.05 ] ); - expected = [ - { - 'value': float64ToFloat16( 1.05 ), - 'done': false - }, - { - 'value': float64ToFloat16( 2.05 ), - 'done': false - }, - { - 'done': true - } - ]; - it = arr.values(); - - t.strictEqual( typeof it, 'object', 'returns expected value' ); - t.strictEqual( typeof it.next, 'function', 'has next method' ); - - for ( i = 0; i < expected.length; i++ ) { - r = it.next(); - e = expected[ i ]; - if ( e.value === void 0 ) { - t.deepEqual( r, e, 'returns expected value' ); - } else { - t.strictEqual( isNumber( r.value ), true, 'returns expected value' ); - t.strictEqual( r.value, e.value, 'returns expected value' ); - t.strictEqual( r.done, e.done, 'returns expected value' ); - } - } - - t.end(); -}); - -tape( 'the method returns an iterator which does not iterate over empty arrays', function test( t ) { - var expected; - var arr; - var it; - var i; - var v; - - arr = new Float16Array( [] ); - expected = [ - { - 'done': true - }, - { - 'done': true - }, - { - 'done': true - } - ]; - it = arr.values(); - - t.strictEqual( typeof it, 'object', 'returns expected value' ); - t.strictEqual( typeof it.next, 'function', 'has next method' ); - - for ( i = 0; i < expected.length; i++ ) { - v = it.next(); - t.deepEqual( v, expected[ i ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (no argument)', function test( t ) { - var arr; - var it; - var v; - - arr = new Float16Array( [ 1.05, 2.05, 3.05 ] ); - it = arr.values(); - - v = it.next(); - t.strictEqual( v.value, float64ToFloat16( 1.05 ), 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, float64ToFloat16( 2.05 ), 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.return(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (argument)', function test( t ) { - var arr; - var it; - var v; - - arr = new Float16Array( [ 1.05, 2.05, 3.05 ] ); - it = arr.values(); - - v = it.next(); - t.strictEqual( v.value, float64ToFloat16( 1.05 ), 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, float64ToFloat16( 2.05 ), 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.return( 'beep' ); - t.strictEqual( v.value, 'beep', 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'if an environment supports `Symbol.iterator`, the method returns an iterable', function test( t ) { - var Float16Array; - var arr; - var buf; - var it1; - var it2; - var v1; - var v2; - var i; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - buf = [ 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( buf ); - - it1 = arr.values(); - t.strictEqual( typeof it1[ '__ITERATOR_SYMBOL__' ], 'function', 'has method' ); - t.strictEqual( it1[ '__ITERATOR_SYMBOL__' ].length, 0, 'has zero arity' ); - - it2 = it1[ '__ITERATOR_SYMBOL__' ](); - t.strictEqual( typeof it2, 'object', 'returns expected value' ); - t.strictEqual( typeof it2.next, 'function', 'has `next` method' ); - t.strictEqual( typeof it2.return, 'function', 'has `return` method' ); - - for ( i = 0; i < arr.length; i++ ) { - v1 = it1.next().value; - v2 = it2.next().value; - t.strictEqual( v1, v2, 'returns expected value' ); - } - t.end(); -}); - -tape( 'if an environment does not support `Symbol.iterator`, the method does not return an "iterable"', function test( t ) { - var Float16Array; - var arr; - var buf; - var it; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/symbol-iterator': false - }); - - buf = [ 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( buf ); - - it = arr.values(); - t.strictEqual( it[ ITERATOR_SYMBOL ], void 0, 'does not have property' ); - - t.end(); -}); diff --git a/test/polyfill/test.with.js b/test/polyfill/test.with.js deleted file mode 100644 index 0b6eda1..0000000 --- a/test/polyfill/test.with.js +++ /dev/null @@ -1,213 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `with` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'with' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.with ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.with.call( value, 0, true ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 3.14, - 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.with( value, true ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not in bounds', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - -11, - -12, - 11, - 12 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.with( value, 1.0 ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not a numeric value', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 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.with( 0, value ); - }; - } -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 10 ); - out = arr.with( 5, 1.0 ); - - t.strictEqual( out.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a new floating-point number array with the element at a provided index replaced with a provided value', function test( t ) { - var expected; - var arr; - var buf; - var out; - - arr = new Float16Array( [ 1.05, 1.05, 1.05, 1.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 1.05 ), - toWord( 1.05 ), - toWord( 2.05 ) - ]); - out = arr.with( 3, 2.05 ); - buf = new Uint16Array( out.buffer ); - - t.strictEqual( out instanceof Float16Array, true, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.notEqual( out, arr, 'returns new instance' ); - t.end(); -}); - -tape( 'the method supports negative indices', function test( t ) { - var expected; - var arr; - var buf; - var out; - - arr = new Float16Array( [ 1.05, 1.05, 1.05, 1.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 1.05 ), - toWord( 1.05 ), - toWord( 2.05 ) - ]); - out = arr.with( -1, 2.05 ); - buf = new Uint16Array( out.buffer ); - - t.strictEqual( out instanceof Float16Array, true, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.at.js b/test/test.at.js deleted file mode 100644 index 19df3bd..0000000 --- a/test/test.at.js +++ /dev/null @@ -1,111 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `at` method for returning an array element', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.at ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.at.call( value, 0 ); - }; - } -}); - -tape( 'the method returns `undefined` if provided an index which exceeds array dimensions', function test( t ) { - var arr; - var v; - var i; - - arr = new Float16Array( 10 ); - for ( i = -arr.length; i < arr.length; i++ ) { - if ( i < 0 ) { - v = arr.at( i-arr.length ); - t.strictEqual( v, void 0, 'returns expected value for index '+(i-arr.length) ); - } else { - v = arr.at( arr.length+i ); - t.strictEqual( v, void 0, 'returns expected value for index '+(arr.length+i) ); - } - } - t.end(); -}); - -tape( 'the method returns an array element', function test( t ) { - var arr; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( i+0.05 ); - } - - arr = new Float16Array( arr ); - - for ( i = -arr.length; i < arr.length; i++ ) { - v = arr.at( i ); - if ( i < 0 ) { - t.strictEqual( v, float64ToFloat16( arr.length + i + 0.05 ), 'returns expected value for index '+i ); - } else { - t.strictEqual( v, float64ToFloat16( i + 0.05 ), 'returns expected value for index '+i ); - } - } - t.end(); -}); diff --git a/test/test.copy_within.js b/test/test.copy_within.js deleted file mode 100644 index d286509..0000000 --- a/test/test.copy_within.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `copyWithin` method for copying a sequence of array elements within a floating-point number array', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within an array', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( 0, 3 ); - buf = new Uint16Array( arr.buffer ); - - // Overwritten: - t.strictEqual( buf[ 0 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 4.05 ), 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 2 ], toWord( 2.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (negative target)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( -arr.length, 3 ); - buf = new Uint16Array( arr.buffer ); - - // Overwritten: - t.strictEqual( buf[ 0 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 4.05 ), 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 2 ], toWord( 2.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (negative start)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( 0, -2 ); - buf = new Uint16Array( arr.buffer ); - - // Overwritten: - t.strictEqual( buf[ 0 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 4.05 ), 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 2 ], toWord( 2.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (end=length)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( 0, 3, arr.length ); - buf = new Uint16Array( arr.buffer ); - - // Overwritten: - t.strictEqual( buf[ 0 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 4.05 ), 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 2 ], toWord( 2.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (non-inclusive end)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( 2, 0, 2 ); - buf = new Uint16Array( arr.buffer ); - - // Remain the same: - t.strictEqual( buf[ 0 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - - // Overwritten: - t.strictEqual( buf[ 2 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 1.05 ), 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (negative end)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( 2, 0, -3 ); - buf = new Uint16Array( arr.buffer ); - - // Remain the same: - t.strictEqual( buf[ 0 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - - // Overwritten: - t.strictEqual( buf[ 2 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 1.05 ), 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (target >= length)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( arr.length, 3 ); - buf = new Uint16Array( arr.buffer ); - - // Remain the same: - t.strictEqual( buf[ 0 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 2 ], toWord( 2.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (target > start)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( 2, 0 ); - buf = new Uint16Array( arr.buffer ); - - // Remain the same: - t.strictEqual( buf[ 0 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - - // Overwritten: - t.strictEqual( buf[ 2 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 4 ], toWord( 2.05 ), 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.entries.js b/test/test.entries.js deleted file mode 100644 index 396dd8e..0000000 --- a/test/test.entries.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isNumber = require( '@stdlib/assert-is-number' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `entries` method for returning an iterator for iterating over array key-value pairs', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.entries ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.entries.call( value ); - }; - } -}); - -tape( 'the method returns an iterator protocol-compliant object', function test( t ) { - var buf; - var arr; - var it; - var v; - var i; - - buf = [ 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( buf ); - - it = arr.entries(); - t.strictEqual( it.next.length, 0, 'has zero arity' ); - - for ( i = 0; i < arr.length; i++ ) { - v = it.next(); - t.strictEqual( isArray( v.value ), true, 'returns expected value' ); - t.strictEqual( v.value[ 0 ], i, 'returns expected value' ); - t.strictEqual( isNumber( v.value[ 1 ] ), true, 'returns expected value' ); - t.strictEqual( v.value[ 1 ], float64ToFloat16( buf[ i ] ), 'returns expected value' ); - t.strictEqual( typeof v.done, 'boolean', 'returns expected value' ); - } - t.end(); -}); diff --git a/test/test.every.js b/test/test.every.js deleted file mode 100644 index 0742d6a..0000000 --- a/test/test.every.js +++ /dev/null @@ -1,172 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `every` method for returning boolean indicating whether all elements pass a test', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.every ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.every.call( value, predicate ); - }; - } - - function predicate( v ) { - return v === 0.0; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.every( value ); - }; - } -}); - -tape( 'the method returns `true` if operating on an empty floating-point number array', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( 0 ); - bool = arr.every( predicate ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns `true` if all elements pass a test', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 1.05, 1.05, 1.05 ] ); - bool = arr.every( predicate ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v === float64ToFloat16( 1.05 ); - } -}); - -tape( 'the method returns `false` if one or more elements fail a test', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 1.05, 0.05, 1.05 ] ); - bool = arr.every( predicate ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v === float64ToFloat16( 1.05 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var bool; - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ 1.05, 1.05, 1.05, 1.05 ] ); - bool = arr.every( predicate, ctx ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v === float64ToFloat16( 1.05 ); - } -}); diff --git a/test/test.fill.js b/test/test.fill.js deleted file mode 100644 index d434060..0000000 --- a/test/test.fill.js +++ /dev/null @@ -1,212 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `fill` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.fill ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.fill.call( value, 1.0 ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.fill( 1.05 ); - - t.strictEqual( out instanceof Float16Array, true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 10 ); - out = arr.fill( 1.05 ); - - t.strictEqual( out, arr, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'if called with one argument, the method sets each array element to the provided value', function test( t ) { - var arr; - var buf; - var i; - - arr = new Float16Array( 3 ); - arr.fill( 1.05 ); - - buf = new Uint16Array( arr.buffer ); - - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( buf[ i ], toWord( 1.05 ), 'returns expected value' ); - } - - t.end(); -}); - -tape( 'if called with two arguments, the method sets each array element to the provided value starting from a start index (inclusive)', function test( t ) { - var arr; - var buf; - - arr = new Float16Array( 3 ); - buf = new Uint16Array( arr.buffer ); - - arr.fill( 1.05, 1 ); - - t.strictEqual( buf[ 0 ], toWord( 0.0 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 2 ], toWord( 1.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'if called with three arguments, the method sets each array element to the provided value starting from a start index (inclusive) until a specified end index (exclusive)', function test( t ) { - var arr; - var buf; - - arr = new Float16Array( 3 ); - buf = new Uint16Array( arr.buffer ); - - arr.fill( 1.05, 0, 2 ); - - t.strictEqual( buf[ 0 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 2 ], toWord( 0.0 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method supports negative indices', function test( t ) { - var arr; - var buf; - - arr = new Float16Array( 3 ); - buf = new Uint16Array( arr.buffer ); - - arr.fill( 1.05, -3, -1 ); - - t.strictEqual( buf[ 0 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 2 ], toWord( 0.0 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'if a provided start index resolves to a negative index, the method fills an array starting from the first element', function test( t ) { - var arr; - var buf; - var i; - - arr = new Float16Array( 3 ); - buf = new Uint16Array( arr.buffer ); - - arr.fill( 1.05, -10 ); - - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( buf[ i ], toWord( 1.05 ), 'returns expected value' ); - } - - t.end(); -}); - -tape( 'if a provided end index resolves to an index exceeding the last array element index, the method fills an array until the last element (inclusive)', function test( t ) { - var arr; - var buf; - var i; - - arr = new Float16Array( 3 ); - buf = new Uint16Array( arr.buffer ); - - arr.fill( 1.05, 1, 10 ); - - t.strictEqual( buf[ 0 ], toWord( 0.0 ), 'returns expected value' ); - for ( i = 1; i < arr.length; i++ ) { - t.strictEqual( buf[ i ], toWord( 1.05 ), 'returns expected value' ); - } - - t.end(); -}); - -tape( 'if a provided start index resolves to an index which is greater than or equal to a resolved end index, the method does not fill an array', function test( t ) { - var arr; - var buf; - - arr = new Float16Array( 3 ); - buf = new Uint16Array( arr.buffer ); - - arr.fill( 1.0, 2, 1 ); - - t.strictEqual( buf[ 0 ], toWord( 0.0 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 0.0 ), 'returns expected value' ); - t.strictEqual( buf[ 2 ], toWord( 0.0 ), 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.filter.js b/test/test.filter.js deleted file mode 100644 index 1b77a61..0000000 --- a/test/test.filter.js +++ /dev/null @@ -1,224 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `filter` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.filter ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.filter.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( v === 1.0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.filter( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.filter( predicate ); - - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v === 1.0 ); - } -}); - -tape( 'the method returns a new floating-point number array containing only those elements which satisfy a test condition', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 1.05, 2.05 ] ); - expected = new Uint16Array( [ toWord( 1.05 ), toWord( 1.05 ) ] ); - actual = arr.filter( predicate ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v === float64ToFloat16( 1.05 ) ); - } -}); - -tape( 'the method copies all elements to a new array if all elements satisfy a test condition', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ) - ]); - actual = arr.filter( predicate ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.notEqual( actual, arr, 'returns a new instance' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v > 1.0 ); - } -}); - -tape( 'the method returns an empty array if no elements satisfy a test condition', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array( [] ); - actual = arr.filter( predicate ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.notEqual( actual, arr, 'returns a new instance' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 1.0 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var expected; - var actual; - var arr; - var buf; - var ctx; - - arr = new Float16Array( [ 1.05, 2.05, 1.05, 1.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 1.05 ), - toWord( 1.05 ) - ]); - ctx = { - 'count': 0 - }; - actual = arr.filter( predicate, ctx ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v === float64ToFloat16( 1.05 ) ); - } -}); diff --git a/test/test.find.js b/test/test.find.js deleted file mode 100644 index 1836dc3..0000000 --- a/test/test.find.js +++ /dev/null @@ -1,172 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `find` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.find ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.find.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( v === 1.0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.find( value ); - }; - } -}); - -tape( 'the method returns `undefined` if operating on an empty floating-point number array', function test( t ) { - var arr; - var v; - - arr = new Float16Array( 0 ); - v = arr.find( predicate ); - - t.strictEqual( v, void 0, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns the first element which passes a test', function test( t ) { - var arr; - var v; - - arr = new Float16Array( [ 1.05, -2.05, 3.05, -4.05 ] ); - v = arr.find( predicate ); - - t.strictEqual( v, float64ToFloat16( -2.05 ), 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method returns `undefined` if all elements fail a test', function test( t ) { - var arr; - var v; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - v = arr.find( predicate ); - - t.strictEqual( v, void 0, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - var v; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ -1.05, -2.05, 3.05, 4.05, 5.05 ] ); - v = arr.find( predicate, ctx ); - - t.strictEqual( v, float64ToFloat16( 3.05 ), 'returns expected value' ); - t.strictEqual( ctx.count, 3, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v > 0.0 ); - } -}); diff --git a/test/test.find_index.js b/test/test.find_index.js deleted file mode 100644 index b3e9023..0000000 --- a/test/test.find_index.js +++ /dev/null @@ -1,171 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `findIndex` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.findIndex ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.findIndex.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( v === 1.0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.findIndex( value ); - }; - } -}); - -tape( 'the method returns `-1` if operating on an empty floating-point number array', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( 0 ); - idx = arr.findIndex( predicate ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns the index of the first element which passes a test', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( [ 1.05, -2.05, 3.05, -4.05 ] ); - idx = arr.findIndex( predicate ); - - t.strictEqual( idx, 1, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0); - } -}); - -tape( 'the method returns `-1` if all elements fail a test', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - idx = arr.findIndex( predicate ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - var idx; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ -1.05, -2.05, 3.05, 4.05, 5.05 ] ); - idx = arr.findIndex( predicate, ctx ); - - t.strictEqual( idx, 2, 'returns expected value' ); - t.strictEqual( ctx.count, 3, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v > 0.0 ); - } -}); diff --git a/test/test.find_last.js b/test/test.find_last.js deleted file mode 100644 index 4451b22..0000000 --- a/test/test.find_last.js +++ /dev/null @@ -1,172 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `findLast` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.findLast ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.findLast.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( v === 0.0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.findLast( value ); - }; - } -}); - -tape( 'the method returns `undefined` if operating on an empty floating-point number array', function test( t ) { - var arr; - var v; - - arr = new Float16Array( 0 ); - v = arr.findLast( predicate ); - - t.strictEqual( v, void 0, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns the last element which passes a test', function test( t ) { - var arr; - var v; - - arr = new Float16Array( [ 1.05, -2.05, 3.05, -4.05 ] ); - v = arr.findLast( predicate ); - - t.strictEqual( v, float64ToFloat16( -4.05 ), 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method returns `undefined` if all elements fail a test', function test( t ) { - var arr; - var v; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - v = arr.findLast( predicate ); - - t.strictEqual( v, void 0, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - var v; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ -1.05, -2.05, 3.05, 4.05, 5.05 ] ); - v = arr.findLast( predicate, ctx ); - - t.strictEqual( v, float64ToFloat16( 5.05 ), 'returns expected value' ); - t.strictEqual( ctx.count, 1, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v > 0.0 ); - } -}); diff --git a/test/test.find_last_index.js b/test/test.find_last_index.js deleted file mode 100644 index c303468..0000000 --- a/test/test.find_last_index.js +++ /dev/null @@ -1,171 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `findLastIndex` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.findLastIndex ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.findLastIndex.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( v === 1.0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.findLastIndex( value ); - }; - } -}); - -tape( 'the method returns `-1` if operating on an empty floating-point number array', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( 0 ); - idx = arr.findLastIndex( predicate ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns the index of the last element which passes a test', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( [ 1.05, -2.05, 3.05, -4.05 ] ); - idx = arr.findLastIndex( predicate ); - - t.strictEqual( idx, 3, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method returns `-1` if all elements fail a test', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - idx = arr.findLastIndex( predicate ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - var idx; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ -1.05, -2.05, 3.05, 4.05, 5.05 ] ); - idx = arr.findLastIndex( predicate, ctx ); - - t.strictEqual( idx, 4, 'returns expected value' ); - t.strictEqual( ctx.count, 1, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v > 0.0 ); - } -}); diff --git a/test/test.for_each.js b/test/test.for_each.js deleted file mode 100644 index af6afda..0000000 --- a/test/test.for_each.js +++ /dev/null @@ -1,194 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `forEach` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.forEach ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.forEach.call( value, fcn ); - }; - } - - function fcn( v ) { - if ( !isNumber( v ) ) { - t.fail( 'should be a number' ); - } - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.forEach( value ); - }; - } -}); - -tape( 'the method should not invoke a provided callback function if operating on an empty floating-point array', function test( t ) { - var arr; - - arr = new Float16Array( 0 ); - arr.forEach( fcn ); - - t.end(); - - function fcn() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns `undefined`', function test( t ) { - var arr; - var out; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - out = arr.forEach( fcn ); - - t.strictEqual( out, void 0, 'returns expected value' ); - t.end(); - - function fcn( v ) { - if ( !isNumber( v ) ) { - t.fail( 'should be a number' ); - } - } -}); - -tape( 'the method invokes a provided function for each element in an array', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var arr; - - indices = []; - values = []; - arrays = []; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - arr.forEach( fcn ); - - expected = [ - float64ToFloat16( 1.05 ), - float64ToFloat16( 2.05 ), - float64ToFloat16( 3.05 ), - float64ToFloat16( 4.05 ) - ]; - - t.deepEqual( values, expected, 'returns expected value' ); - t.deepEqual( indices, [ 0, 1, 2, 3 ], 'returns expected value' ); - t.strictEqual( arrays[ 0 ], arr, 'returns expected value' ); - t.strictEqual( arrays[ 1 ], arr, 'returns expected value' ); - t.strictEqual( arrays[ 2 ], arr, 'returns expected value' ); - t.strictEqual( arrays[ 3 ], arr, 'returns expected value' ); - - t.end(); - - function fcn( v, i, arr ) { - values.push( v ); - indices.push( i ); - arrays.push( arr ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - arr.forEach( fcn, ctx ); - - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function fcn() { - this.count += 1; // eslint-disable-line no-invalid-this - } -}); diff --git a/test/test.from.js b/test/test.from.js deleted file mode 100644 index 15a43a2..0000000 --- a/test/test.from.js +++ /dev/null @@ -1,309 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 Uint16Array = require( '@stdlib/array-uint16' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is a `from` method for creating a 16-bit floating-point number array from an array-like object or an iterable', function test( t ) { - var arr; - - t.strictEqual( isFunction( Float16Array.from ), true, 'has method' ); - - arr = Float16Array.from( [] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a constructor', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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 Float16Array.from.call( value, [] ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array constructor', function test( t ) { - var values; - var i; - - values = [ - {}, - null, - 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 Float16Array.from.call( value, [] ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - {}, - [] - ]; - 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 Float16Array.from( [], value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not a function (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - {}, - [] - ]; - 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 Float16Array.from( [], value, {} ); - }; - } -}); - -tape( 'the method returns a floating-point number array', function test( t ) { - var arr; - var v; - - // Generic array: - arr = Float16Array.from( [] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Float16Array.from( [ 1.0, 2.0, 3.0, 4.0 ] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - // Generic array containing non-numeric values: - arr = Float16Array.from( [ 'beep' ] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - arr = Float16Array.from( [ null, 4 ] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - arr = Float16Array.from( [ true, {}, '' ] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 3, 'returns expected value' ); - - // Typed array: - arr = Float16Array.from( new Uint16Array( 0 ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Float16Array.from( new Uint16Array( [ 1, 1 ] ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // Floating-point number typed array: - arr = Float16Array.from( new Float16Array( 0 ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Float16Array.from( new Float16Array( [ 1.0, 2.0 ] ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method supports providing a "map" function which is invoked for each source element', function test( t ) { - var arr; - var v; - - // Generic array: - arr = Float16Array.from( [], clbk1 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Float16Array.from( [ 1.0, 2.0, 3.0, 4.0 ], clbk1 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - // Generic array containing non-numeric values: - arr = Float16Array.from( [ 'beep' ], clbk2 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - arr = Float16Array.from( [ null ], clbk2 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - arr = Float16Array.from( [ [], {} ], clbk1 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - arr = Float16Array.from( [ 4, 5 ], clbk1 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // Typed array: - arr = Float16Array.from( new Uint16Array( 0 ), clbk1 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Float16Array.from( new Uint16Array( [ 1, 1 ] ), clbk1 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // Floating-point number typed array: - arr = Float16Array.from( new Float16Array( 0 ), clbk2 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Float16Array.from( new Float16Array( [ true, true ] ), clbk2 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - t.end(); - - function clbk1( v ) { - return v; - } - - function clbk2() { - return true; - } -}); - -tape( 'the method supports providing a `this` context for a provided map function', function test( t ) { - var arr; - var ctx; - - ctx = { - 'count': 0 - }; - arr = Float16Array.from( [ 1.0, 2.0, 3.0, 4.0 ], clbk1, ctx ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function clbk1( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v; - } -}); diff --git a/test/test.includes.js b/test/test.includes.js deleted file mode 100644 index a367b40..0000000 --- a/test/test.includes.js +++ /dev/null @@ -1,160 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `includes` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.includes ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.includes.call( value, true ); - }; - } -}); - -tape( 'the method returns `false` if operating on an empty floating-point number array', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( 0 ); - bool = arr.includes( 1.0 ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `false` if a floating-point number is not found', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( 10 ); - bool = arr.includes( 1.0 ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `true` if an array contains a specified floating-point number', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05] ); - bool = arr.includes( float64ToFloat16( 1.05 ) ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `false` if provided a second argument which exceeds the input array length', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( 10 ); - bool = arr.includes( 0.0, 20 ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 1.05, 1.05, 1.05 ] ); - - bool = arr.includes( float64ToFloat16( 1.05 ), 0 ); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = arr.includes( float64ToFloat16( 2.05 ), 1 ); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = arr.includes( float64ToFloat16( 2.05 ), 3 ); - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index (negative)', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 1.05, 1.05, 1.05 ] ); - - bool = arr.includes( float64ToFloat16( 1.05 ), -5 ); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = arr.includes( float64ToFloat16( 2.05 ), -2 ); - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'when provided a starting index which resolves to an index which is less than zero, the method searches from the first array element', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 1.05, 1.05, 1.05 ] ); - - bool = arr.includes( float64ToFloat16( 1.05 ), -10 ); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = arr.includes( float64ToFloat16( 2.05 ), -10 ); - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.index_of.js b/test/test.index_of.js deleted file mode 100644 index 2a684aa..0000000 --- a/test/test.index_of.js +++ /dev/null @@ -1,160 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `indexOf` method for returning the index of an array element', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.indexOf ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.indexOf.call( value, 1.0 ); - }; - } -}); - -tape( 'the method returns `-1` if operating on an empty floating-point number array', function test( t ) { - var arr; - var idx; - - arr = new Float16Array(); - idx = arr.indexOf( 1.0 ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `-1` if a numeric value is not found', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( 10 ); - idx = arr.indexOf( 1.0 ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns the index of the first match if a numeric value is found', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - idx = arr.indexOf( float64ToFloat16( 2.05 ) ); - - t.strictEqual( idx, 1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `-1` if provided a second argument which exceeds the input array length', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( 10 ); - idx = arr.indexOf( 1.0, 20 ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 2.05, 5.05 ] ); - - idx = arr.indexOf( float64ToFloat16( 2.05 ), 0 ); - t.strictEqual( idx, 1, 'returns expected value' ); - - idx = arr.indexOf( float64ToFloat16( 2.05 ), 2 ); - t.strictEqual( idx, 3, 'returns expected value' ); - - idx = arr.indexOf( float64ToFloat16( 2.05 ), 4 ); - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index (negative)', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 2.05, 5.05 ] ); - - idx = arr.indexOf( float64ToFloat16( 2.05 ), -5 ); - t.strictEqual( idx, 1, 'returns expected value' ); - - idx = arr.indexOf( float64ToFloat16( 2.05 ), -1 ); - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'when provided a starting index which resolves to an index which is less than zero, the method searches from the first array element', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 2.05, 5.05 ] ); - - idx = arr.indexOf( float64ToFloat16( 2.05 ), -10 ); - t.strictEqual( idx, 1, 'returns expected value' ); - - idx = arr.indexOf( float64ToFloat16( 1.05 ), -10 ); - t.strictEqual( idx, 0, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.join.js b/test/test.join.js deleted file mode 100644 index 800bb1f..0000000 --- a/test/test.join.js +++ /dev/null @@ -1,141 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `join` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.join ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.join.call( value ); - }; - } -}); - -tape( 'the method returns an empty string if invoked on an empty array', function test( t ) { - var str; - var arr; - - arr = new Float16Array( 0 ); - str = arr.join(); - - t.strictEqual( str, '', 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a string representation of a floating-point number array with elements separated by a separator', function test( t ) { - var expected; - var str; - var arr; - var i; - - arr = new Float16Array( [ 0.05, 1.05, 2.05, 3.05, 4.05 ] ); - - expected = float64ToFloat16( 0.05 ); - for ( i = 1; i < arr.length; i++ ) { - expected += '@' + float64ToFloat16( i + 0.05 ); - } - - str = arr.join( '@' ); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a string representation of a floating-point number array with elements separated by a separator (single element)', function test( t ) { - var expected; - var str; - var arr; - - arr = new Float16Array( [ 1.05 ] ); - expected = '' + float64ToFloat16( 1.05 ); - - str = arr.join(); - - t.strictEqual( str, expected, 'returns expected value' ); - - arr = new Float16Array( [ 1.05 ] ); - expected = '' + float64ToFloat16( 1.05 ); - - str = arr.join( '@' ); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if the method is invoked without a separator argument, the method returns a string representation of a floating-point number array with elements separated by a comma', function test( t ) { - var expected; - var str; - var arr; - var i; - - arr = new Float16Array( [ 0.05, 1.05, 2.05, 3.05, 4.05 ] ); - - expected = float64ToFloat16( 0.05 ); - for ( i = 1; i < arr.length; i++ ) { - expected += ',' + float64ToFloat16( i + 0.05 ); - } - - str = arr.join(); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 930feef..0000000 --- a/test/test.js +++ /dev/null @@ -1,320 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var arr = new Float16Array( 0 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (no argument)', function test( t ) { - var arr = new Float16Array(); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (length)', function test( t ) { - var arr = new Float16Array( 10 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (array)', function test( t ) { - var arr = new Float16Array( [] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (typed array)', function test( t ) { - var arr = new Float16Array( new Uint16Array( 0 ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (ArrayBuffer)', function test( t ) { - var arr = new Float16Array( new ArrayBuffer( 0 ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (ArrayBuffer, byte offset)', function test( t ) { - var arr = new Float16Array( new ArrayBuffer( 8 ), 8 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (ArrayBuffer, byte offset, length)', function test( t ) { - var arr = new Float16Array( new ArrayBuffer( 8 ), 8, 0 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the constructor is a property returning the number of bytes per array element', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Float16Array.BYTES_PER_ELEMENT, 2, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the constructor is a property returning the constructor name', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array, 'name' ), true, 'has property' ); - t.strictEqual( Float16Array.name, 'Float16Array', 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance having a `BYTES_PER_ELEMENT` property returning the number of bytes per array element', function test( t ) { - var arr; - - t.strictEqual( hasOwnProp( Float16Array.prototype, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Float16Array.prototype.BYTES_PER_ELEMENT, 2, 'returns expected value' ); - - arr = new Float16Array( 0 ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance having a `buffer` property for returning the underlying memory (i.e., ArrayBuffer)', function test( t ) { - var arr; - var buf; - - arr = new Float16Array( 0 ); - buf = arr.buffer; - t.strictEqual( isArrayBuffer( buf ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance having a `byteLength` property for returning the number of bytes belonging to the array view', function test( t ) { - var arr; - var v; - - arr = new Float16Array( 0 ); - v = arr.byteLength; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( new ArrayBuffer( 64 ), 8 ); - v = arr.byteLength; - t.strictEqual( v, 56, 'returns expected value' ); - - arr = new Float16Array( new ArrayBuffer( 64 ), 64 ); - v = arr.byteLength; - t.strictEqual( v, 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance having a `byteOffset` property for returning the byte offset pointing to the first array element in the underlying memory', function test( t ) { - var arr; - var v; - - arr = new Float16Array( 0 ); - v = arr.byteOffset; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( new ArrayBuffer( 64 ), 32 ); - v = arr.byteOffset; - t.strictEqual( v, 32, 'returns expected value' ); - - arr = new Float16Array( new ArrayBuffer( 64 ), 64 ); - v = arr.byteOffset; - t.strictEqual( v, 64, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance having a `length` property for returning the number of array elements', function test( t ) { - var arr; - var v; - - // No arguments: - arr = new Float16Array(); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - // Explicit array length: - arr = new Float16Array( 0 ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( 10 ); - v = arr.length; - t.strictEqual( v, 10, 'returns expected value' ); - - // Generic array: - arr = new Float16Array( [] ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - // Typed array: - arr = new Float16Array( new Uint16Array( 0 ) ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( new Uint16Array( [ 1.0, 1.0 ] ) ); - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // Float16 typed array: - arr = new Float16Array( new Float16Array( 0 ) ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( new Float16Array( [ 1.0, 2.0 ] ) ); - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // ArrayBuffer: - arr = new Float16Array( new ArrayBuffer( 64 ), 32 ); - v = arr.length; - t.strictEqual( v, 16, 'returns expected value' ); - - arr = new Float16Array( new ArrayBuffer( 64 ), 64 ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( new ArrayBuffer( 64 ), 32, 2 ); - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor throws an error if provided an ArrayBuffer which is not a multiple of 2', function test( t ) { - var values; - var i; - - values = [ - 1, - 3, - 5, - 7, - 9, - 11, - 101, - 1001 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided an ArrayBuffer having a byte length equal to '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Float16Array( new ArrayBuffer( value ) ); - }; - } -}); - -tape( 'the constructor throws an error if provided a byte offset argument which is not a multiple of 2', function test( t ) { - var values; - var i; - - values = [ - 1, - 3, - 5, - 7, - 9, - 11, - 101, - 1001 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Float16Array( new ArrayBuffer( 1e3 ), value ); - }; - } -}); - -tape( 'the constructor throws an error if provided a byte offset argument such that the view byte length is not a multiple of 8', function test( t ) { - var values; - var i; - - values = [ - 2, - 4, - 6, - 8, - 10, - 12, - 14, - 16, - 18, - 20 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Float16Array( new ArrayBuffer( 101 ), value ); - }; - } -}); - -tape( 'the constructor throws an error if provided insufficient memory to accommodate byte offset and length arguments', function test( t ) { - var values; - var i; - - values = [ - 8, - 16, - 24, - 32 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Float16Array( new ArrayBuffer( 100 ), value, 1e3 ); - }; - } -}); diff --git a/test/test.keys.js b/test/test.keys.js deleted file mode 100644 index 283d682..0000000 --- a/test/test.keys.js +++ /dev/null @@ -1,144 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `keys` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.keys ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.keys.call( value ); - }; - } -}); - -tape( 'the method returns an iterator protocol-compliant object', function test( t ) { - var expected; - var arr; - var it; - var i; - var r; - var e; - - arr = new Float16Array( [ 1.05, 2.05 ] ); - expected = [ - { - 'value': 0, - 'done': false - }, - { - 'value': 1, - 'done': false - }, - { - 'done': true - } - ]; - it = arr.keys(); - - t.strictEqual( typeof it, 'object', 'returns expected value' ); - t.strictEqual( typeof it.next, 'function', 'has next method' ); - - for ( i = 0; i < expected.length; i++ ) { - r = it.next(); - e = expected[ i ]; - if ( e.value === void 0 ) { - t.strictEqual( r.value, e.value, 'returns expected value' ); - t.strictEqual( r.done, e.done, 'returns expected value' ); - } else { - t.strictEqual( r.value, e.value, 'returns expected value' ); - t.strictEqual( r.done, e.done, 'returns expected value' ); - } - } - - t.end(); -}); - -tape( 'the method returns an iterator which does not iterate over empty arrays', function test( t ) { - var expected; - var arr; - var it; - var i; - var v; - - arr = new Float16Array( [] ); - expected = [ - { - 'done': true - }, - { - 'done': true - }, - { - 'done': true - } - ]; - it = arr.keys(); - - t.strictEqual( typeof it, 'object', 'returns expected value' ); - t.strictEqual( typeof it.next, 'function', 'has next method' ); - - for ( i = 0; i < expected.length; i++ ) { - v = it.next(); - t.strictEqual( v.value, expected[ i ].value, 'returns expected value' ); - t.strictEqual( v.done, expected[ i ].done, 'returns expected value' ); - } - t.end(); -}); diff --git a/test/test.last_index_of.js b/test/test.last_index_of.js deleted file mode 100644 index 5a42168..0000000 --- a/test/test.last_index_of.js +++ /dev/null @@ -1,149 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `lastIndexOf` method for returning the index of an array element', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.lastIndexOf ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.lastIndexOf.call( value, true ); - }; - } -}); - -tape( 'the method returns `-1` if operating on an empty floating-point number array', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( 0 ); - idx = arr.lastIndexOf( 0.0 ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `-1` if a numeric value is not found', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( 10 ); - idx = arr.lastIndexOf( 1.0 ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns the index of the first match when searching from the end of the array if a search element is found', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 1.05, 2.05 ] ); - idx = arr.lastIndexOf( float64ToFloat16( 1.05 ) ); - - t.strictEqual( idx, 2, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 2.05, 1.05, 1.05 ] ); - - idx = arr.lastIndexOf( float64ToFloat16( 1.05 ), 4 ); - t.strictEqual( idx, 4, 'returns expected value' ); - - idx = arr.lastIndexOf( float64ToFloat16( 2.05 ), 2 ); - t.strictEqual( idx, 2, 'returns expected value' ); - - idx = arr.lastIndexOf( float64ToFloat16( 2.05 ), 0 ); - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index (negative)', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 2.05, 1.05, 1.05 ] ); - - idx = arr.lastIndexOf( float64ToFloat16( 1.05 ), -3 ); - t.strictEqual( idx, 0, 'returns expected value' ); - - idx = arr.lastIndexOf( float64ToFloat16( 2.05 ), -1 ); - t.strictEqual( idx, 2, 'returns expected value' ); - t.end(); -}); - -tape( 'when the method is provided a starting index which resolves to an index which exceeds the maximum array index, the method searches from the last array element', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 2.05, 1.05, 1.05 ] ); - - idx = arr.lastIndexOf( float64ToFloat16( 1.05 ), 10 ); - t.strictEqual( idx, 4, 'returns expected value' ); - - idx = arr.lastIndexOf( float64ToFloat16( 2.05 ), 10 ); - t.strictEqual( idx, 2, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.map.js b/test/test.map.js deleted file mode 100644 index f7e5594..0000000 --- a/test/test.map.js +++ /dev/null @@ -1,176 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var identity = require( '@stdlib/utils-identity-function' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `map` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.map ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.map.call( value, identity ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.map( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.map( identity ); - - t.strictEqual( instanceOf( out, Float16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - t.notEqual( out, arr, 'returns a new instance' ); - t.end(); -}); - -tape( 'the method returns a new floating-point number array containing elements which are the result of a provided callback function', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( -1.05 ), - toWord( -2.05 ), - toWord( -3.05 ), - toWord( -4.05 ) - ]); - actual = arr.map( invert ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.notEqual( actual, arr, 'returns a new instance' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); - - function invert( v ) { - return -v; - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var expected; - var actual; - var arr; - var buf; - var ctx; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( -1.05 ), - toWord( -2.05 ), - toWord( -3.05 ), - toWord( -4.05 ) - ]); - ctx = { - 'count': 0 - }; - actual = arr.map( invert, ctx ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.strictEqual( ctx.count, 6, 'returns expected value' ); - t.end(); - - function invert( v, i ) { - this.count += i; // eslint-disable-line no-invalid-this - return -v; - } -}); diff --git a/test/test.of.js b/test/test.of.js deleted file mode 100644 index 6486686..0000000 --- a/test/test.of.js +++ /dev/null @@ -1,128 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `of` method for creating a 16-bit floating-point number array from a variable number of arguments', function test( t ) { - var arr; - - t.strictEqual( isFunction( Float16Array.of ), true, 'has method' ); - - arr = Float16Array.of(); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a constructor', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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 Float16Array.of.call( value, true, true ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point array constructor', function test( t ) { - var values; - var i; - - values = [ - {}, - null, - 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 Float16Array.of.call( value, true, true ); - }; - } -}); - -tape( 'the method returns a floating-point number array', function test( t ) { - var arr; - var v; - - // No arguments: - arr = Float16Array.of(); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - // Numeric arguments: - arr = Float16Array.of( 1.0, 2.0, 3.0, 4.0 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - // Non-numeric arguments: - arr = Float16Array.of( 1, {}, 0, null, 'beep' ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 5, 'returns expected value' ); - - // Mixed arguments: - arr = Float16Array.of( true, 1, false, 0 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 2010bde..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 proxyquire = require( 'proxyquire' ); -var hasFloat16ArraySupport = require( '@stdlib/assert-has-float16array-support' ); -var polyfill = require( './../lib/polyfill' ); -var ctor = require( './../lib' ); - - -// VARIABLES // - -var hasFloat16Arrays = hasFloat16ArraySupport(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports `Float16Array`, the export is an alias for `Float16Array`', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-float16array-support': isTrue, - './main.js': Mock - }); - t.strictEqual( Foo, Mock, 'returns builtin' ); - - if ( hasFloat16Arrays ) { - t.strictEqual( ctor, Float16Array, 'is alias' ); // eslint-disable-line stdlib/require-globals, no-undef - } - - t.end(); - - function Mock() { - return this; - } - - function isTrue() { - return true; - } -}); - -tape( 'if an environment does not support `Float16Array`, the export is a polyfill', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-float16array-support': isFalse - }); - - t.strictEqual( Foo, polyfill, 'returns polyfill' ); - t.end(); - - function isFalse() { - return false; - } -}); diff --git a/test/test.reduce.js b/test/test.reduce.js deleted file mode 100644 index 34786fc..0000000 --- a/test/test.reduce.js +++ /dev/null @@ -1,187 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `reduce` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.reduce ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.reduce.call( value, reducer ); - }; - } - - function reducer( acc, value ) { - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.reduce( value ); - }; - } -}); - -tape( 'the method throws an error if not provided an initial value when operating on an empty floating-point number array', function test( t ) { - var arr; - - arr = new Float16Array( 0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - arr.reduce( reducer ); - } - - function reducer( acc, value ) { - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method uses the first element of the array as the initial value when an initial value is not provided', function test( t ) { - var valueArray; - var accArray; - var expected; - var actual; - var arr; - var ind; - - arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - accArray = [ 1.0, 3.0 ]; - valueArray = [ 2.0, 3.0 ]; - expected = float64ToFloat16( 6.0 ); - actual = arr.reduce( reducer ); - - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); - - function reducer( acc, value, index ) { - ind = index-1; - t.strictEqual( acc, float64ToFloat16( accArray[ ind ] ), 'returns expected value' ); - t.strictEqual( value, float64ToFloat16( valueArray[ ind ] ), 'returns expected value' ); - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method supports providing an initial value as the second argument', function test( t ) { - var valueArray; - var accArray; - var expected; - var actual; - var arr; - - arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - accArray = [ 2.0, 3.0, 5.0 ]; - valueArray = [ 1.0, 2.0, 3.0 ]; - expected = 8.0; - actual = arr.reduce( reducer, 2.0 ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value, index ) { - t.strictEqual( acc, float64ToFloat16( accArray[ index ] ), 'returns expected value' ); - t.strictEqual( value, float64ToFloat16( valueArray[ index ] ), 'returns expected value' ); - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method returns the accumulated result', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = float64ToFloat16( 10.20 ); - actual = arr.reduce( reducer ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value ) { - return float64ToFloat16( acc + value ); - } -}); diff --git a/test/test.reduce_right.js b/test/test.reduce_right.js deleted file mode 100644 index 313b948..0000000 --- a/test/test.reduce_right.js +++ /dev/null @@ -1,190 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `reduceRight` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.reduceRight ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.reduceRight.call( value, reducer ); - }; - } - - function reducer( acc, value ) { - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.reduceRight( value ); - }; - } -}); - -tape( 'the method throws an error if not provided an initial value when operating on an empty floating-point number array', function test( t ) { - var arr; - - arr = new Float16Array( 0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - arr.reduceRight( reducer ); - } - - function reducer( acc, value ) { - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method uses the last element of the array as the initial value when an initial value is not provided', function test( t ) { - var valueArray; - var accArray; - var expected; - var actual; - var arr; - var len; - - arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - len = arr.length; - accArray = [ 3.0, 5.0 ]; - valueArray = [ 2.0, 1.0 ]; - expected = float64ToFloat16( 6.0 ); - actual = arr.reduceRight( reducer ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value, index ) { - var ind = (len-index-2); - t.strictEqual( acc, float64ToFloat16( accArray[ ind ] ), 'returns expected value' ); - t.strictEqual( value, float64ToFloat16( valueArray[ ind ] ), 'returns expected value' ); - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method supports providing an initial value as the second argument', function test( t ) { - var valueArray; - var accArray; - var expected; - var actual; - var arr; - var len; - - arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - len = arr.length; - accArray = [ 2.0, 5.0, 7.0 ]; - valueArray = [ 3.0, 2.0, 1.0 ]; - expected = 8.0; - actual = arr.reduceRight( reducer, 2.0 ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value, index ) { - var ind = (len-index-1); - t.strictEqual( acc, float64ToFloat16( accArray[ ind ] ), 'returns expected value' ); - t.strictEqual( value, float64ToFloat16( valueArray[ ind ] ), 'returns expected value' ); - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method returns the accumulated result', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = float64ToFloat16( 10.20 ); - actual = arr.reduceRight( reducer ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value ) { - return float64ToFloat16( acc + value ); - } -}); diff --git a/test/test.reverse.js b/test/test.reverse.js deleted file mode 100644 index 147a4a0..0000000 --- a/test/test.reverse.js +++ /dev/null @@ -1,120 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, '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( isFunction( Float16Array.prototype.reverse ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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 floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - 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 floating-point number array in-place', function test( t ) { - var expected; - var arr; - var buf; - var out; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05, 5.05 ] ); - expected = new Uint16Array([ - toWord( 5.05 ), - toWord( 4.05 ), - toWord( 3.05 ), - toWord( 2.05 ), - toWord( 1.05 ) - ]); - out = arr.reverse(); - buf = new Uint16Array( arr.buffer ); - - t.strictEqual( instanceOf( arr, Float16Array ), true, 'returns expected value' ); - t.strictEqual( out, arr, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 10 ); - out = arr.reverse(); - - t.strictEqual( out.length, 10, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.set.js b/test/test.set.js deleted file mode 100644 index 559efab..0000000 --- a/test/test.set.js +++ /dev/null @@ -1,225 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `set` method for setting one or more array elements', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.set ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.set.call( value, 0 ); - }; - } -}); - -tape( 'the method throws an error if provided an index argument which is out-of-bounds', function test( t ) { - var values; - var arr1; - var arr2; - var i; - - arr1 = new Float16Array( 10 ); - arr2 = []; - for ( i = 0; i < arr1.length; i++ ) { - arr2.push( 1.0 ); - } - - values = [ - 1, - 2, - 3, - 4, - 5 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr1.set( arr2, value ); - }; - } -}); - -tape( 'the method sets one or more array elements', function test( t ) { - var arr; - var v; - var i; - - arr = new Float16Array( 10 ); - - v = arr[ 0 ]; - t.strictEqual( v, 0.0, 'returns expected value' ); - - // No index argument: - arr.set( [ 1.0 ] ); - - v = arr[ 0 ]; - t.strictEqual( v, 1.0, 'returns expected value' ); - - arr.set( [ 0.0 ] ); - - // Index argument: - for ( i = 0; i < arr.length; i++ ) { - v = arr[ i ]; - t.strictEqual( v, 0.0, 'returns expected value' ); - - arr.set( [ 1.05 ], i ); - - v = arr[ i ]; - t.strictEqual( v, float64ToFloat16( 1.05 ), 'returns expected value' ); - } - - // Multiple values, no index argument: - arr.set( [ 1.05, 2.05 ] ); - - v = arr[ 0 ]; - t.strictEqual( v, float64ToFloat16( 1.05 ), 'returns expected value' ); - - v = arr[ 1 ]; - t.strictEqual( v, float64ToFloat16( 2.05 ), 'returns expected value' ); - - // Multiple values, index argument: - arr.set( [ 1.05, 2.05 ], 2 ); - - v = arr[ 2 ]; - t.strictEqual( v, float64ToFloat16( 1.05 ), 'returns expected value' ); - - v = arr[ 3 ]; - t.strictEqual( v, float64ToFloat16( 2.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method sets an array element (floating-point number array; shared buffer)', function test( t ) { - var byteOffset; - var arr; - var src; - var buf; - var ab; - var v; - var i; - - byteOffset = 112; - - ab = new ArrayBuffer( 240 ); - arr = new Float16Array( ab, byteOffset, 10 ); - - // Overlapping (requires copy), multiple values, no index argument: - buf = [ 1.05, 2.05 ]; - src = new Float16Array( ab, byteOffset-(1*arr.BYTES_PER_ELEMENT), 2 ); - for ( i = 0; i < buf.length; i++ ) { - src[ i ] = buf[ i ]; - } - arr.set( src ); - - v = arr[ 0 ]; - t.strictEqual( v, float64ToFloat16( buf[ 0 ] ), 'returns expected value' ); - - v = arr[ 1 ]; - t.strictEqual( v, float64ToFloat16( buf[ 1 ] ), 'returns expected value' ); - - // Overlapping (requires copy), multiple values, index argument: - buf = [ -1.05, -2.05 ]; - src = new Float16Array( ab, byteOffset+(1*arr.BYTES_PER_ELEMENT), 2 ); - for ( i = 0; i < buf.length; i++ ) { - src[ i ] = buf[ i ]; - } - arr.set( src, 2 ); - - v = arr[ 2 ]; - t.strictEqual( v, float64ToFloat16( buf[ 0 ] ), 'returns expected value' ); - - v = arr[ 3 ]; - t.strictEqual( v, float64ToFloat16( buf[ 1 ] ), 'returns expected value' ); - - // Overlapping (no copy), multiple values, no index argument: - buf = [ 3.05, 4.05 ]; - src = new Float16Array( ab, byteOffset+(1*arr.BYTES_PER_ELEMENT), 2 ); - for ( i = 0; i < buf.length; i++ ) { - src[ i ] = buf[ i ]; - } - arr.set( src ); - - v = arr[ 0 ]; - t.strictEqual( v, float64ToFloat16( buf[ 0 ] ), 'returns expected value' ); - - v = arr[ 1 ]; - t.strictEqual( v, float64ToFloat16( buf[ 1 ] ), 'returns expected value' ); - - // Overlapping (no copy), multiple values, index argument: - buf = [ -3.05, -4.05 ]; - src = new Float16Array( ab, byteOffset+(3*arr.BYTES_PER_ELEMENT), 2 ); - for ( i = 0; i < buf.length; i++ ) { - src[ i ] = buf[ i ]; - } - arr.set( src, 2 ); - - v = arr[ 2 ]; - t.strictEqual( v, float64ToFloat16( buf[ 0 ] ), 'returns expected value' ); - - v = arr[ 3 ]; - t.strictEqual( v, float64ToFloat16( buf[ 1 ] ), 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.slice.js b/test/test.slice.js deleted file mode 100644 index a9f9e04..0000000 --- a/test/test.slice.js +++ /dev/null @@ -1,249 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `slice` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.slice ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.slice.call( value ); - }; - } -}); - -tape( 'the method returns an empty typed array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.slice(); - - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'if called without arguments, the method returns a typed array containing the same elements as the original array', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ) - ]); - actual = arr.slice(); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.notEqual( actual, arr, 'returns a new instance' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if called with one argument, the method returns a typed array containing elements starting from a specified beginning index (inclusive)', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ) - ]); - actual = arr.slice( 1 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if provided two arguments, the method returns a typed array containing elements starting from a specified beginning index (inclusive) and ending at a specified stop index (exclusive)', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ) - ]); - actual = arr.slice( 1, 3 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ) - ]); - actual = arr.slice( 1, 30 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method resolves negative indices relative to the last element', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ) - ]); - actual = arr.slice( -3, -1 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ) - ]); - actual = arr.slice( -30, -2 ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty typed array if a resolved beginning index exceeds a resolved ending index', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array( [] ); - actual = arr.slice( 2, 0 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty typed array if a resolved beginning index exceeds the maximum array index', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array( [] ); - actual = arr.slice( 5 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty typed array if a resolved ending index is less than or equal to zero', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); - expected = new Uint16Array( [] ); - actual = arr.slice( 2, -8 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - - actual = arr.slice( 1, 0 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.some.js b/test/test.some.js deleted file mode 100644 index 238d1d9..0000000 --- a/test/test.some.js +++ /dev/null @@ -1,194 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `some` method for returning boolean indicating whether at least one element passes a test', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.some ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.some.call( value, predicate ); - }; - } - - function predicate( v ) { - return v === 1.0; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.some( value ); - }; - } -}); - -tape( 'the method returns `false` if operating on an empty floating-point number array', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( 0 ); - bool = arr.some( predicate ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns `true` if at least one element passes a test', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - bool = arr.some( predicate ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v === float64ToFloat16( 1.05 ); - } -}); - -tape( 'the method returns `false` if all elements fail a test', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - bool = arr.some( predicate ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v === float64ToFloat16( 5.05 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var bool; - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - bool = arr.some( predicate, ctx ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v === float64ToFloat16( 4.05 ); - } -}); - -tape( 'the method stops executing upon encountering the first element which passes a test', function test( t ) { - var bool; - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - bool = arr.some( predicate, ctx ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.strictEqual( ctx.count, 1, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v === float64ToFloat16( 1.05 ); - } -}); diff --git a/test/test.sort.js b/test/test.sort.js deleted file mode 100644 index e976a68..0000000 --- a/test/test.sort.js +++ /dev/null @@ -1,186 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Comparison function. -* -* @private -* @param {boolean} a - first value for comparison -* @param {boolean} b - second value for comparison -* @returns {number} comparison result -*/ -function compareFcn( a, b ) { - if ( a < b ) { - return -1; - } - if ( a > b ) { - return 1; - } - return 0; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `sort` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.sort ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.sort.call( value, compareFcn ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - {}, - [] - ]; - 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.sort( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.sort( compareFcn ); - - t.strictEqual( out.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the method sorts elements of a floating-point number array in-place', function test( t ) { - var expected; - var arr; - var out; - var buf; - - arr = new Float16Array( [ 4.05, 3.05, 1.05, 5.05, 2.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ), - toWord( 5.05 ) - ]); - out = arr.sort( compareFcn ); - buf = new Uint16Array( out.buffer ); - - t.strictEqual( instanceOf( arr, Float16Array ), true, 'returns expected value' ); - t.strictEqual( out, arr, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - - arr = new Float16Array( [ 2.05, 1.05, -1.05, 0.05, -2.05 ] ); - expected = new Uint16Array([ - toWord( -2.05 ), - toWord( -1.05 ), - toWord( 0.05 ), - toWord( 1.05 ), - toWord( 2.05 ) - ]); - out = arr.sort( compareFcn ); - buf = new Uint16Array( out.buffer ); - - t.strictEqual( instanceOf( arr, Float16Array ), true, 'returns expected value' ); - t.strictEqual( out, arr, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Float16Array( [ 4.05, 3.05, 1.05, 5.05, 2.05 ] ); - out = arr.sort( compareFcn ); - - t.strictEqual( out.length, arr.length, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.subarray.js b/test/test.subarray.js deleted file mode 100644 index 6684448..0000000 --- a/test/test.subarray.js +++ /dev/null @@ -1,246 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `subarray` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.subarray ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.subarray.call( value ); - }; - } -}); - -tape( 'the method returns empty array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.subarray(); - - t.strictEqual( out.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'if called without arguments, the method returns a view containing the same elements as the original array', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ) - ]); - actual = arr.subarray(); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if called with one argument, the method returns a view containing elements starting from a specified beginning index (inclusive)', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ) - ]); - actual = arr.subarray( 1 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if provided two arguments, the method returns a view containing elements starting from a specified beginning index (inclusive) and ending at a specified stop index (exclusive)', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ) - ]); - actual = arr.subarray( 1, 3 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method resolves negative indices relative to the last element', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ) - ]); - actual = arr.subarray( -3, -1 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 2.05 ) - ]); - actual = arr.subarray( -30, -2 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty view if a resolved beginning index exceeds a resolved ending index', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array( [] ); - actual = arr.subarray( 2, 0 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty view if a resolved beginning index exceeds the maximum array index', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array( [] ); - actual = arr.subarray( 5 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty view if a resolved ending index is less than or equal to zero', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array( [] ); - actual = arr.subarray( 2, -8 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - - actual = arr.subarray( 1, 0 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.to_locale_string.js b/test/test.to_locale_string.js deleted file mode 100644 index 6359a2c..0000000 --- a/test/test.to_locale_string.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `toLocaleString` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.toLocaleString ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.toLocaleString.call( value ); - }; - } -}); - -tape( 'the method returns an empty string if invoked on an empty array', function test( t ) { - var str; - var arr; - - arr = new Float16Array( 0 ); - str = arr.toLocaleString(); - - t.strictEqual( str, '', 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a string representation of a floating-point number array', function test( t ) { - var expected; - var str; - var arr; - - arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - expected = '1,2,3'; - - str = arr.toLocaleString(); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.to_reversed.js b/test/test.to_reversed.js deleted file mode 100644 index a82ad13..0000000 --- a/test/test.to_reversed.js +++ /dev/null @@ -1,119 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, '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( isFunction( Float16Array.prototype.toReversed ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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 floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - 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 buf; - var out; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05, 5.05 ] ); - expected = new Uint16Array([ - toWord( 5.05 ), - toWord( 4.05 ), - toWord( 3.05 ), - toWord( 2.05 ), - toWord( 1.05 ) - ]); - out = arr.toReversed(); - buf = new Uint16Array( out.buffer ); - - t.strictEqual( instanceOf( out, Float16Array ), true, 'returns expected value' ); - t.notEqual( out, arr, 'returns a new instance' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 10 ); - out = arr.toReversed(); - - t.strictEqual( out.length, 10, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.to_sorted.js b/test/test.to_sorted.js deleted file mode 100644 index 77508b5..0000000 --- a/test/test.to_sorted.js +++ /dev/null @@ -1,169 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Comparison function. -* -* @private -* @param {boolean} a - first value for comparison -* @param {boolean} b - second value for comparison -* @returns {number} comparison result -*/ -function compareFcn( a, b ) { - if ( a < b ) { - return -1; - } - if ( a > b ) { - return 1; - } - return 0; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `toSorted` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.toSorted ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.toSorted.call( value, compareFcn ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - {}, - [] - ]; - 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.toSorted( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.toSorted( compareFcn ); - - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a new typed array containing elements in sorted order', function test( t ) { - var expected; - var arr; - var out; - var buf; - - arr = new Float16Array( [ 4.05, 3.05, 1.05, 5.05, 2.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ), - toWord( 5.05 ) - ]); - out = arr.toSorted( compareFcn ); - buf = new Uint16Array( out.buffer ); - - t.strictEqual( instanceOf( out, Float16Array ), true, 'returns expected value' ); - t.notEqual( out, arr, 'returns a new instance' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Float16Array( [ 4.05, 3.05, 1.05, 5.05, 2.05 ] ); - out = arr.toSorted( compareFcn ); - - t.strictEqual( out.length, arr.length, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.to_string.js b/test/test.to_string.js deleted file mode 100644 index a2bb9e3..0000000 --- a/test/test.to_string.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `toString` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.toString ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with an invalid `this` context', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - null, - void 0 - ]; - 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.toString.call( value ); - }; - } -}); - -tape( 'the method returns an empty string if invoked on an empty array', function test( t ) { - var str; - var arr; - - arr = new Float16Array( 0 ); - str = arr.toString(); - - t.strictEqual( str, '', 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a string representation of a floating-point number array', function test( t ) { - var expected; - var str; - var arr; - - arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - expected = '1,2,3,4'; - - str = arr.toString(); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.values.js b/test/test.values.js deleted file mode 100644 index 225b3fe..0000000 --- a/test/test.values.js +++ /dev/null @@ -1,147 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var isNumber = require( '@stdlib/assert-is-number' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `values` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.values ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.values.call( value ); - }; - } -}); - -tape( 'the method returns an iterator protocol-compliant object', function test( t ) { - var expected; - var arr; - var it; - var i; - var r; - var e; - - arr = new Float16Array( [ 1.05, 2.05 ] ); - expected = [ - { - 'value': float64ToFloat16( 1.05 ), - 'done': false - }, - { - 'value': float64ToFloat16( 2.05 ), - 'done': false - }, - { - 'done': true - } - ]; - it = arr.values(); - - t.strictEqual( typeof it, 'object', 'returns expected value' ); - t.strictEqual( typeof it.next, 'function', 'has next method' ); - - for ( i = 0; i < expected.length; i++ ) { - r = it.next(); - e = expected[ i ]; - if ( e.value === void 0 ) { - t.strictEqual( r.value, e.value, 'returns expected value' ); - t.strictEqual( r.done, e.done, 'returns expected value' ); - } else { - t.strictEqual( isNumber( r.value ), true, 'returns expected value' ); - t.strictEqual( r.value, e.value, 'returns expected value' ); - t.strictEqual( r.done, e.done, 'returns expected value' ); - } - } - - t.end(); -}); - -tape( 'the method returns an iterator which does not iterate over empty arrays', function test( t ) { - var expected; - var arr; - var it; - var i; - var v; - - arr = new Float16Array( [] ); - expected = [ - { - 'done': true - }, - { - 'done': true - }, - { - 'done': true - } - ]; - it = arr.values(); - - t.strictEqual( typeof it, 'object', 'returns expected value' ); - t.strictEqual( typeof it.next, 'function', 'has next method' ); - - for ( i = 0; i < expected.length; i++ ) { - v = it.next(); - t.strictEqual( v.value, expected[ i ].value, 'returns expected value' ); - t.strictEqual( v.done, expected[ i ].done, 'returns expected value' ); - } - t.end(); -}); diff --git a/test/test.with.js b/test/test.with.js deleted file mode 100644 index de134c8..0000000 --- a/test/test.with.js +++ /dev/null @@ -1,151 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `with` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.with ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.with.call( value, 0, true ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not in bounds', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - -11, - -12, - 11, - 12 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.with( value, 1.0 ); - }; - } -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 10 ); - out = arr.with( 5, 1.0 ); - - t.strictEqual( out.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a new floating-point number array with the element at a provided index replaced with a provided value', function test( t ) { - var expected; - var arr; - var buf; - var out; - - arr = new Float16Array( [ 1.05, 1.05, 1.05, 1.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 1.05 ), - toWord( 1.05 ), - toWord( 2.05 ) - ]); - out = arr.with( 3, 2.05 ); - buf = new Uint16Array( out.buffer ); - - t.strictEqual( out instanceof Float16Array, true, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.notEqual( out, arr, 'returns new instance' ); - t.end(); -}); - -tape( 'the method supports negative indices', function test( t ) { - var expected; - var arr; - var buf; - var out; - - arr = new Float16Array( [ 1.05, 1.05, 1.05, 1.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 1.05 ), - toWord( 1.05 ), - toWord( 2.05 ) - ]); - out = arr.with( -1, 2.05 ); - buf = new Uint16Array( out.buffer ); - - t.strictEqual( out instanceof Float16Array, true, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); From 82dd12a9b8d2610fd6bd2daa3aca72d09807f036 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 14 May 2026 03:49:48 +0000 Subject: [PATCH 06/14] Transform error messages --- lib/polyfill/index.js | 102 +++++++++++++++++++++--------------------- package.json | 2 +- 2 files changed, 52 insertions(+), 52 deletions(-) diff --git a/lib/polyfill/index.js b/lib/polyfill/index.js index 5073dcb..063db06 100644 --- a/lib/polyfill/index.js +++ b/lib/polyfill/index.js @@ -38,7 +38,7 @@ var setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); var setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' ); var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var Uint16Array = require( '@stdlib/array-uint16' ); var f16 = require( '@stdlib/number-float64-base-to-float16' ); var toWord = require( '@stdlib/number-float16-base-to-word' ); @@ -234,49 +234,49 @@ function Float16Array() { } } else if ( isArrayBuffer( arg ) ) { if ( !isInteger( arg.byteLength/BYTES_PER_ELEMENT ) ) { - throw new RangeError( format( 'invalid argument. ArrayBuffer byte length must be a multiple of %u. Byte length: `%u`.', BYTES_PER_ELEMENT, arg.byteLength ) ); + throw new RangeError( format( 'nullE9', BYTES_PER_ELEMENT, arg.byteLength ) ); } buf = new Uint16Array( arg ); } else if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, ArrayBuffer, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( 'null29', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( 'null2A', arg ) ); } buf = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( buf.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( 'null2A', arg ) ); } buf = new Uint16Array( fromIterator( buf ) ); } else { - throw new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( 'null2A', arg ) ); } } else { buf = arguments[ 0 ]; if ( !isArrayBuffer( buf ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', buf ) ); + throw new TypeError( format( 'null2B', buf ) ); } byteOffset = arguments[ 1 ]; if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) ); + throw new TypeError( format( 'null2C', byteOffset ) ); } if ( !isInteger( byteOffset/BYTES_PER_ELEMENT ) ) { - throw new RangeError( format( 'invalid argument. Byte offset must be a multiple of %u. Value: `%u`.', BYTES_PER_ELEMENT, byteOffset ) ); + throw new RangeError( format( 'nullEA', BYTES_PER_ELEMENT, byteOffset ) ); } if ( nargs === 2 ) { len = buf.byteLength - byteOffset; if ( !isInteger( len/BYTES_PER_ELEMENT ) ) { - throw new RangeError( format( 'invalid arguments. ArrayBuffer view byte length must be a multiple of %u. View byte length: `%u`.', BYTES_PER_ELEMENT, len ) ); + throw new RangeError( format( 'null2E', BYTES_PER_ELEMENT, len ) ); } buf = new Uint16Array( buf, byteOffset ); } else { len = arguments[ 2 ]; if ( !isNonNegativeInteger( len ) ) { - throw new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', len ) ); + throw new TypeError( format( 'null2F', len ) ); } if ( (len*BYTES_PER_ELEMENT) > (buf.byteLength-byteOffset) ) { - throw new RangeError( format( 'invalid arguments. ArrayBuffer has insufficient capacity. Either decrease the array length or provide a bigger buffer. Minimum capacity: `%u`.', len*BYTES_PER_ELEMENT ) ); + throw new RangeError( format( 'null2G', len*BYTES_PER_ELEMENT ) ); } buf = new Uint16Array( buf, byteOffset, len ); } @@ -362,7 +362,7 @@ setReadOnly( Float16Array, 'from', function from( src ) { var len; var i; if ( !isFunction( this ) ) { - throw new TypeError( 'invalid invocation. `this` context must be a constructor.' ); + throw new TypeError( format('null01') ); } if ( !isFloatingPointArrayConstructor( this ) ) { throw new TypeError( 'invalid invocation. `this` is not a floating-point array.' ); @@ -371,7 +371,7 @@ setReadOnly( Float16Array, 'from', function from( src ) { if ( nargs > 1 ) { clbk = arguments[ 1 ]; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( 'null2H', clbk ) ); } if ( nargs > 2 ) { thisArg = arguments[ 2 ]; @@ -392,7 +392,7 @@ setReadOnly( Float16Array, 'from', function from( src ) { if ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) { // eslint-disable-line max-len buf = src[ ITERATOR_SYMBOL ](); if ( !isFunction( buf.next ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) ); + throw new TypeError( format( 'null2J', src ) ); } if ( clbk ) { tmp = fromIteratorMap( buf, clbk, thisArg ); @@ -410,7 +410,7 @@ setReadOnly( Float16Array, 'from', function from( src ) { } return out; } - throw new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) ); + throw new TypeError( format( 'null2J', src ) ); }); /** @@ -438,7 +438,7 @@ setReadOnly( Float16Array, 'of', function of() { var args; var i; if ( !isFunction( this ) ) { - throw new TypeError( 'invalid invocation. `this` context must be a constructor.' ); + throw new TypeError( format('null01') ); } if ( !isFloatingPointArrayConstructor( this ) ) { throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); @@ -478,7 +478,7 @@ setReadOnly( Float16Array.prototype, 'at', function at( idx ) { throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Must provide an integer. Value: `%s`.', idx ) ); + throw new TypeError( format( 'null8A', idx ) ); } if ( idx < 0 ) { idx += this._length; @@ -731,7 +731,7 @@ setReadOnly( Float16Array.prototype, 'every', function every( predicate, thisArg throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( 'null3c', predicate ) ); } buf = this._buffer; for ( i = 0; i < this._length; i++ ) { @@ -781,13 +781,13 @@ setReadOnly( Float16Array.prototype, 'fill', function fill( value, start, end ) throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isNumber( value ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a number. Value: `%s`.', value ) ); + throw new TypeError( format( 'null49', value ) ); } buf = this._buffer; len = this._length; if ( arguments.length > 1 ) { if ( !isInteger( start ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', start ) ); + throw new TypeError( format( 'null7f', start ) ); } if ( start < 0 ) { start += len; @@ -797,7 +797,7 @@ setReadOnly( Float16Array.prototype, 'fill', function fill( value, start, end ) } if ( arguments.length > 2 ) { if ( !isInteger( end ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', end ) ); + throw new TypeError( format( 'null2z', end ) ); } if ( end < 0 ) { end += len; @@ -863,7 +863,7 @@ setReadOnly( Float16Array.prototype, 'filter', function filter( predicate, thisA throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( 'null3c', predicate ) ); } buf = this._buffer; out = []; @@ -907,7 +907,7 @@ setReadOnly( Float16Array.prototype, 'find', function find( predicate, thisArg ) throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( 'null3c', predicate ) ); } buf = this._buffer; for ( i = 0; i < this._length; i++ ) { @@ -949,7 +949,7 @@ setReadOnly( Float16Array.prototype, 'findIndex', function findIndex( predicate, throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( 'null3c', predicate ) ); } buf = this._buffer; for ( i = 0; i < this._length; i++ ) { @@ -992,7 +992,7 @@ setReadOnly( Float16Array.prototype, 'findLast', function findLast( predicate, t throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( 'null3c', predicate ) ); } buf = this._buffer; for ( i = this._length-1; i >= 0; i-- ) { @@ -1034,7 +1034,7 @@ setReadOnly( Float16Array.prototype, 'findLastIndex', function findLastIndex( pr throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( 'null3c', predicate ) ); } buf = this._buffer; for ( i = this._length-1; i >= 0; i-- ) { @@ -1074,7 +1074,7 @@ setReadOnly( Float16Array.prototype, 'forEach', function forEach( fcn, thisArg ) throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( 'null3c', fcn ) ); } buf = this._buffer; for ( i = 0; i < this._length; i++ ) { @@ -1099,7 +1099,7 @@ setReadOnly( Float16Array.prototype, '_get', function get( idx ) { throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isNonNegativeInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Must provide a nonnegative integer. Value: `%s`.', idx ) ); + throw new TypeError( format( 'null2K', idx ) ); } if ( idx >= this._length ) { return; @@ -1141,11 +1141,11 @@ setReadOnly( Float16Array.prototype, 'includes', function includes( searchElemen throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isNumber( searchElement ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a number. Value: `%s`.', searchElement ) ); + throw new TypeError( format( 'null49', searchElement ) ); } if ( arguments.length > 1 ) { if ( !isInteger( fromIndex ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) ); + throw new TypeError( format( 'null7f', fromIndex ) ); } if ( fromIndex < 0 ) { fromIndex += this._length; @@ -1200,11 +1200,11 @@ setReadOnly( Float16Array.prototype, 'indexOf', function indexOf( searchElement, throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isNumber( searchElement ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a number. Value: `%s`.', searchElement ) ); + throw new TypeError( format( 'null49', searchElement ) ); } if ( arguments.length > 1 ) { if ( !isInteger( fromIndex ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) ); + throw new TypeError( format( 'null7f', fromIndex ) ); } if ( fromIndex < 0 ) { fromIndex += this._length; @@ -1255,7 +1255,7 @@ setReadOnly( Float16Array.prototype, 'join', function join( separator ) { } if ( arguments.length > 0 ) { if ( !isString( separator ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', separator ) ); + throw new TypeError( format( 'null3F', separator ) ); } } else { separator = ','; @@ -1404,11 +1404,11 @@ setReadOnly( Float16Array.prototype, 'lastIndexOf', function lastIndexOf( search throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isNumber( searchElement ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a number. Value: `%s`.', searchElement ) ); + throw new TypeError( format( 'null49', searchElement ) ); } if ( arguments.length > 1 ) { if ( !isInteger( fromIndex ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) ); + throw new TypeError( format( 'null7f', fromIndex ) ); } if ( fromIndex >= this._length ) { fromIndex = this._length - 1; @@ -1486,7 +1486,7 @@ setReadOnly( Float16Array.prototype, 'map', function map( fcn, thisArg ) { throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isFunction( fcn ) ) { - throw new TypeError( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ); + throw new TypeError( format('null3c'), fcn ); } buf = this._buffer; out = new this.constructor( this._length ); @@ -1529,7 +1529,7 @@ setReadOnly( Float16Array.prototype, 'reduce', function reduce( reducer, initial throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isFunction( reducer ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', reducer ) ); + throw new TypeError( format( 'null3c', reducer ) ); } buf = this._buffer; len = this._length; @@ -1581,7 +1581,7 @@ setReadOnly( Float16Array.prototype, 'reduceRight', function reduceRight( reduce throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isFunction( reducer ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', reducer ) ); + throw new TypeError( format( 'null3c', reducer ) ); } buf = this._buffer; len = this._length; @@ -1707,20 +1707,20 @@ setReadOnly( Float16Array.prototype, 'set', function set( value ) { throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isCollection( value ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', value ) ); + throw new TypeError( format( 'null2O', value ) ); } buf = this._buffer; if ( arguments.length > 1 ) { idx = arguments[ 1 ]; if ( !isNonNegativeInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Index argument must be a nonnegative integer. Value: `%s`.', idx ) ); + throw new TypeError( format( 'null2L', idx ) ); } } else { idx = 0; } N = value.length; if ( idx+N > this._length ) { - throw new RangeError( 'invalid arguments. Target array lacks sufficient storage to accommodate source values.' ); + throw new RangeError( format('null03') ); } if ( isFloat16Array( value ) ) { sbuf = value._buffer; // eslint-disable-line no-underscore-dangle @@ -1814,7 +1814,7 @@ setReadOnly( Float16Array.prototype, 'slice', function slice( begin, end ) { end = len; } else { if ( !isInteger( begin ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', begin ) ); + throw new TypeError( format( 'null7e', begin ) ); } if ( begin < 0 ) { begin += len; @@ -1826,7 +1826,7 @@ setReadOnly( Float16Array.prototype, 'slice', function slice( begin, end ) { end = len; } else { if ( !isInteger( end ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', end ) ); + throw new TypeError( format( 'null7f', end ) ); } if ( end < 0 ) { end += len; @@ -1881,7 +1881,7 @@ setReadOnly( Float16Array.prototype, 'some', function some( predicate, thisArg ) throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( 'null3c', predicate ) ); } buf = this._buffer; for ( i = 0; i < this._length; i++ ) { @@ -1939,7 +1939,7 @@ setReadOnly( Float16Array.prototype, 'sort', function sort( compareFcn ) { return this; } if ( !isFunction( compareFcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', compareFcn ) ); + throw new TypeError( format( 'null3c', compareFcn ) ); } buf.sort( compare ); return this; @@ -2044,7 +2044,7 @@ setReadOnly( Float16Array.prototype, 'subarray', function subarray( begin, end ) end = len; } else { if ( !isInteger( begin ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', begin ) ); + throw new TypeError( format( 'null7e', begin ) ); } if ( begin < 0 ) { begin += len; @@ -2056,7 +2056,7 @@ setReadOnly( Float16Array.prototype, 'subarray', function subarray( begin, end ) end = len; } else { if ( !isInteger( end ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', end ) ); + throw new TypeError( format( 'null7f', end ) ); } if ( end < 0 ) { end += len; @@ -2122,7 +2122,7 @@ setReadOnly( Float16Array.prototype, 'toLocaleString', function toLocaleString( } else if ( isObject( options ) ) { opts = options; } else { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( 'null2V', options ) ); } buf = this._buffer; out = []; @@ -2387,14 +2387,14 @@ setReadOnly( Float16Array.prototype, 'with', function copyWith( index, value ) { throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isInteger( index ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', index ) ); + throw new TypeError( format( 'null7e', index ) ); } len = this._length; if ( index < 0 ) { index += len; } if ( index < 0 || index >= len ) { - throw new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%s`.', index ) ); + throw new RangeError( format( 'nullFP', index ) ); } if ( !isNumber( value ) ) { throw new TypeError( format( 'invalid argument. Second argument must be a floating-point number. Value: `%s`.', value ) ); diff --git a/package.json b/package.json index 7f32128..0ed7acd 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "@stdlib/number-float16-base-from-word": "^0.2.1", "@stdlib/number-float16-base-to-word": "^0.1.1", "@stdlib/number-float64-base-to-float16": "^0.1.2", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/symbol-iterator": "^0.2.3", "@stdlib/types": "^0.4.3", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.4", From 0c0903b9dbcb6c1416a14ba21970ee31b1da2fb7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 14 May 2026 03:58:26 +0000 Subject: [PATCH 07/14] Remove files --- index.d.ts | 1312 -------------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 6159 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index ed52b06..0000000 --- a/index.d.ts +++ /dev/null @@ -1,1312 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2026 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. -*/ - -/* eslint-disable max-lines */ - -// TypeScript Version: 4.1 - -/// - -import { Iterator as Iter, IterableIterator, TypedIterator } from '@stdlib/types/iter'; -import { ArrayLike } from '@stdlib/types/array'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = Iter | IterableIterator; - -/** -* Locale-specific configuration options. -*/ -interface LocaleOptions { - /** - * Configuration property. - */ - [ key: string | symbol | number ]: T | undefined; -} - -/** -* Callback invoked for each element in a source object. -* -* @returns transformed value -*/ -type FromNullary = ( this: U ) => number; - -/** -* Callback invoked for each element in a source object. -* -* @param value - source element -* @returns transformed value -*/ -type FromUnary = ( this: U, value: number ) => number; - -/** -* Callback invoked for each element in a source object. -* -* @param value - source element -* @param index - source element index -* @returns transformed value -*/ -type FromBinary = ( this: U, value: number, index: number ) => number; - -/** -* Callback invoked for each element in a source object. -* -* @param value - source element -* @param index - source element index -* @returns transformed value -*/ -type FromCallback = FromNullary | FromUnary | FromBinary; - -/** -* Checks whether an element in an array passes a test. -* -* @returns boolean indicating whether an element in an array passes a test -*/ -type NullaryPredicate = ( this: U ) => boolean; - -/** -* Checks whether an element in an array passes a test. -* -* @param value - current array element -* @returns boolean indicating whether an element in an array passes a test -*/ -type UnaryPredicate = ( this: U, value: number ) => boolean; - -/** -* Checks whether an element in an array passes a test. -* -* @param value - current array element -* @param index - current array element index -* @returns boolean indicating whether an element in an array passes a test -*/ -type BinaryPredicate = ( this: U, value: number, index: number ) => boolean; - -/** -* Checks whether an element in an array passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - array on which the method was called -* @returns boolean indicating whether an element in an array passes a test -*/ -type TernaryPredicate = ( this: U, value: number, index: number, arr: Float16Array ) => boolean; - -/** -* Checks whether an element in an array passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - array on which the method was called -* @returns boolean indicating whether an element in an array passes a test -*/ -type Predicate = NullaryPredicate | UnaryPredicate | BinaryPredicate | TernaryPredicate; - -/** -* Callback invoked for each element in an array. -* -* @returns undefined -*/ -type NullaryCallback = ( this: U ) => void; - -/** -* Callback invoked for each element in an array. -* -* @param value - current array element -* @returns undefined -*/ -type UnaryCallback = ( this: U, value: number ) => void; - -/** -* Callback invoked for each element in an array. -* -* @param value - current array element -* @param index - current array element index -* @returns undefined -*/ -type BinaryCallback = ( this: U, value: number, index: number ) => void; - -/** -* Callback invoked for each element in an array. -* -* @param value - current array element -* @param index - current array element index -* @param arr - array on which the method was called -* @returns undefined -*/ -type TernaryCallback = ( this: U, value: number, index: number, arr: Float16Array ) => void; - -/** -* Callback invoked for each element in an array. -* -* @param value - current array element -* @param index - current array element index -* @param arr - array on which the method was called -* @returns undefined -*/ -type Callback = NullaryCallback | UnaryCallback | BinaryCallback | TernaryCallback; - -/** -* Callback invoked for each element in an array. -* -* @returns returned value -*/ -type NullaryMapFcn = ( this: U ) => number; - -/** -* Callback invoked for each element in an array. -* -* @param value - current array element -* @returns returned value -*/ -type UnaryMapFcn = ( this: U, value: number ) => number; - -/** -* Callback invoked for each element in an array. -* -* @param value - current array element -* @param index - current array element index -* @returns returned value -*/ -type BinaryMapFcn = ( this: U, value: number, index: number ) => number; - -/** -* Callback invoked for each element in an array. -* -* @param value - current array element -* @param index - current array element index -* @param arr - array on which the method was called -* @returns returned value -*/ -type TernaryMapFcn = ( this: U, value: number, index: number, arr: Float16Array ) => number; - -/** -* Callback invoked for each element in an array. -* -* @param value - current array element -* @param index - current array element index -* @param arr - array on which the method was called -* @returns returned value -*/ -type MapFcn = NullaryMapFcn | UnaryMapFcn | BinaryMapFcn | TernaryMapFcn; - -/** -* Reducer function invoked for each element in an array. -* -* @returns accumulated result -*/ -type NullaryReducer = () => U; - -/** -* Reducer function invoked for each element in an array. -* -* @param acc - accumulated result -* @returns accumulated result -*/ -type UnaryReducer = ( acc: U ) => U; - -/** -* Reducer function invoked for each element in an array. -* -* @param acc - accumulated result -* @param value - current array element -* @returns accumulated result -*/ -type BinaryReducer = ( acc: U, value: number ) => U; - -/** -* Reducer function invoked for each element in an array. -* -* @param acc - accumulated result -* @param value - current array element -* @param index - current array element index -* @returns accumulated result -*/ -type TernaryReducer = ( acc: U, value: number, index: number ) => U; - -/** -* @param acc - accumulated result -* @param value - current array element -* @param index - current array element index -* @param arr - array on which the method was called -* @returns accumulated result -*/ -type QuaternaryReducer = ( acc: U, value: number, index: number, arr: Float16Array ) => U; - -/** -* Reducer function invoked for each element in an array. -* -* @param acc - accumulated result -* @param value - current array element -* @param index - current array element index -* @param arr - array on which the method was called -* @returns accumulated result -*/ -type Reducer = NullaryReducer | UnaryReducer | BinaryReducer | TernaryReducer | QuaternaryReducer; - -/** -* Comparator function. -* -* @param a - first number for comparison -* @param b - second number for comparison -* @returns number indicating comparison result -*/ -type CompareFcn = ( a: number, b: number ) => number; - -/** -* Class for creating a half-precision floating-point number array. -*/ -declare class Float16Array { - /** - * Half-precision floating-point number array constructor. - * - * @param arg - length, typed array, array-like object, or buffer - * @param byteOffset - byte offset (default: 0) - * @param length - view length - * @throws ArrayBuffer byte length must be a multiple of `2` - * @throws if provided only a single argument, must provide a valid argument - * @throws byte offset must be a nonnegative integer - * @throws view length must be a positive multiple of `2` - * @throws must provide sufficient memory to accommodate byte offset and view length requirements - * @returns half-precision floating-point number array - * - * @example - * var arr = new Float16Array(); - * // returns - * - * var len = arr.length; - * // returns 0 - * - * @example - * var arr = new Float16Array( 2 ); - * // returns - * - * var len = arr.length; - * // returns 2 - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0 ] ); - * // returns - * - * var len = arr.length; - * // returns 2 - * - * @example - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = new Float16Array( buf ); - * // returns - * - * var len = arr.length; - * // returns 8 - * - * @example - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = new Float16Array( buf, 8 ); - * // returns - * - * var len = arr.length; - * // returns 4 - * - * @example - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = new Float16Array( buf, 8, 2 ); - * // returns - * - * var len = arr.length; - * // returns 2 - */ - constructor( arg?: number | ArrayLike | ArrayBuffer | Iterable, byteOffset?: number, length?: number ); - - /** - * Returns an array element located at integer position (index) `i`, with support for both nonnegative and negative integer indices. - * - * @param i - element index - * @throws index argument must be an integer - * @returns array element - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var v = arr.at( 0 ); - * // returns 1.0 - * - * v = arr.at( -1 ); - * // returns 3.0 - * - * v = arr.at( 100 ); - * // returns undefined - */ - at( i: number ): number | void; - - /** - * Pointer to the underlying data buffer. - * - * @example - * var arr = new Float16Array( 10 ); - * - * var buf = arr.buffer; - * // returns - */ - readonly buffer: ArrayBuffer; - - /** - * Length (in bytes) of the array. - * - * @example - * var arr = new Float16Array( 10 ); - * - * var byteLength = arr.byteLength; - * // returns 20 - */ - readonly byteLength: number; - - /** - * Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`. - * - * @example - * var arr = new Float16Array( 10 ); - * - * var byteOffset = arr.byteOffset; - * // returns 0 - */ - readonly byteOffset: number; - - /** - * Size (in bytes) of each array element. - * - * @example - * var arr = new Float16Array( 10 ); - * - * var nbytes = arr.BYTES_PER_ELEMENT; - * // returns 2 - */ - readonly BYTES_PER_ELEMENT: 2; - - /** - * Number of array elements. - * - * @example - * var arr = new Float16Array( 10 ); - * - * var len = arr.length; - * // returns 10 - */ - readonly length: number; - - /** - * Copies a sequence of elements within the array to the position starting at `target`. - * - * @param target - index at which to start copying elements - * @param start - source index at which to copy elements from - * @param end - source index at which to stop copying elements from - * @returns modified array - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - * - * // Copy the first two elements to the last two elements: - * arr.copyWithin( 2, 0, 2 ); - * - * var v = arr[ 2 ]; - * // returns 1.0 - * - * v = arr[ 3 ]; - * // returns 2.0 - */ - copyWithin( target: number, start: number, end?: number ): Float16Array; - - /** - * Returns an iterator for iterating over array key-value pairs. - * - * @returns iterator - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var it = arr.entries(); - * - * var v = it.next().value; - * // returns [ 0, 1.0 ] - * - * v = it.next().value; - * // returns [ 1, 2.0 ] - * - * v = it.next().value; - * // returns [ 2, 3.0 ] - * - * var bool = it.next().done; - * // returns true - */ - entries(): TypedIterator<[number, number]>; - - /** - * Tests whether all elements in an array pass a test implemented by a predicate function. - * - * @param predicate - predicate function - * @param thisArg - predicate function execution context - * @returns boolean indicating whether all elements pass a test - * - * @example - * function predicate( v ) { - * return v >= 0.0; - * } - * - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var bool = arr.every( predicate ); - * // returns true - */ - every( predicate: Predicate, thisArg?: ThisParameterType> ): boolean; - - /** - * Returns a modified typed array filled with a fill value. - * - * @param value - fill value - * @param start - starting index (inclusive) - * @param end - ending index (exclusive) - * @returns modified typed array - * - * @example - * var arr = new Float16Array( 3 ); - * - * arr.fill( 1.0, 1 ); - * - * var v = arr[ 0 ]; - * // returns 0.0 - * - * v = arr[ 1 ]; - * // returns 1.0 - * - * v = arr[ 2 ]; - * // returns 1.0 - */ - fill( value: number, start?: number, end?: number ): Float16Array; - - /** - * Returns a new array containing the elements of an array which pass a test implemented by a predicate function. - * - * @param predicate - test function - * @param thisArg - execution context - * @returns new array containing elements which pass a test implemented by a predicate function - * - * @example - * function predicate( v ) { - * return ( v >= 2.0 ); - * } - * - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var out = arr.filter( predicate ); - * // returns - * - * var len = out.length; - * // returns 2 - * - * var v = out[ 0 ]; - * // returns 2.0 - * - * v = out[ 1 ]; - * // returns 3.0 - */ - filter( predicate: Predicate, thisArg?: ThisParameterType> ): Float16Array; - - /** - * Returns the first element in an array for which a predicate function returns a truthy value. - * - * @param predicate - predicate function - * @param thisArg - predicate function execution context - * @returns array element or undefined - * - * @example - * function predicate( v ) { - * return v > 1.0; - * } - * - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var v = arr.find( predicate ); - * // returns 2.0 - */ - find( predicate: Predicate, thisArg?: ThisParameterType> ): number | void; - - /** - * Returns the index of the first element in an array for which a predicate function returns a truthy value. - * - * @param predicate - predicate function - * @param thisArg - predicate function execution context - * @returns array index or -1 - * - * @example - * function predicate( v ) { - * return v > 1.0; - * } - * - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var v = arr.findIndex( predicate ); - * // returns 1 - */ - findIndex( predicate: Predicate, thisArg?: ThisParameterType> ): number; - - /** - * Returns the last element in an array for which a predicate function returns a truthy value. - * - * @param predicate - predicate function - * @param thisArg - predicate function execution context - * @returns array element or undefined - * - * @example - * function predicate( v ) { - * return v > 1.0; - * } - * - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var v = arr.findLast( predicate ); - * // returns 3.0 - */ - findLast( predicate: Predicate, thisArg?: ThisParameterType> ): number | void; - - /** - * Returns the index of the last element in an array for which a predicate function returns a truthy value. - * - * @param predicate - predicate function - * @param thisArg - predicate function execution context - * @returns array index or -1 - * - * @example - * function predicate( v ) { - * return v > 1.0; - * } - * - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var v = arr.findLastIndex( predicate ); - * // returns 2 - */ - findLastIndex( predicate: Predicate, thisArg?: ThisParameterType> ): number; - - /** - * Invokes a function once for each array element. - * - * @param fcn - function to invoke - * @param thisArg - execution context - * @returns undefined - * - * @example - * function log( v, i ) { - * console.log( '%s: %s', i, v.toString() ); - * } - * - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * arr.forEach( log ); - */ - forEach( fcn: Callback, thisArg?: ThisParameterType> ): void; - - /** - * Returns a boolean indicating whether an array includes a provided value. - * - * @param searchElement - element to search for - * @param fromIndex - starting index (inclusive) - * @returns boolean indicating whether an array includes a value - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - * - * var bool = arr.includes( 3.0 ); - * // returns true - * - * bool = arr.includes( 3.0, 3 ); - * // returns false - */ - includes( searchElement: number, fromIndex?: number ): boolean; - - /** - * Returns the first index at which a given element can be found. - * - * @param searchElement - element to find - * @param fromIndex - starting index (inclusive) - * @returns index or -1 - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - * - * var idx = arr.indexOf( 3.0 ); - * // returns 2 - * - * idx = arr.indexOf( 3.0, 3 ); - * // returns -1 - * - * idx = arr.indexOf( 6.0 ); - * // returns -1 - */ - indexOf( searchElement: number, fromIndex?: number ): number; - - /** - * Returns a new string by concatenating all array elements. - * - * @param separator - value separator (default: ',') - * @returns string - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var str = arr.join(); - * // returns '1,2,3' - * - * str = arr.join( '|' ); - * // returns '1|2|3' - */ - join( separator?: string ): string; - - /** - * Returns an iterator for iterating over each index key in a typed array. - * - * @returns iterator - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0 ] ); - * - * var iter = arr.keys(); - * - * var v = iter.next().value; - * // returns 0 - * - * v = iter.next().value; - * // returns 1 - * - * var bool = iter.next().done; - * // returns true - */ - keys(): TypedIterator; - - /** - * Returns the last index at which a given element can be found. - * - * @param searchElement - element to find - * @param fromIndex - index at which to start searching backward (inclusive) - * @returns index or -1 - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0, 3.0, 2.0, 1.0 ] ); - * - * var idx = arr.lastIndexOf( 2.0 ); - * // returns 3 - * - * idx = arr.lastIndexOf( 2.0, 2 ); - * // returns 1 - * - * idx = arr.lastIndexOf( 5.0 ); - * // returns -1 - */ - lastIndexOf( searchElement: number, fromIndex?: number ): number; - - /** - * Returns a new array with each element being the result of a provided callback function. - * - * @param fcn - callback function - * @param thisArg - callback function execution context - * @returns new half-precision floating-point number array - * - * @example - * function scale( v ) { - * return v * 2.0; - * } - * - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var out = arr.map( scale ); - * // returns - * - * var v = out[ 0 ]; - * // returns 2.0 - * - * v = out[ 1 ]; - * // returns 4.0 - * - * v = out[ 2 ]; - * // returns 6.0 - */ - map( fcn: MapFcn, thisArg?: ThisParameterType> ): Float16Array; - - /** - * Applies a provided callback function to each element of the array, in order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion. - * - * @param reducer - callback function - * @param initialValue - initial value - * @returns accumulated result - * - * @example - * function reducer( acc, v ) { - * return acc + v; - * } - * - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var out = arr.reduce( reducer, 0.0 ); - * // returns 6.0 - */ - reduce( reducer: Reducer, initialValue?: U ): U; - - /** - * Applies a provided callback function to each element of the array, in reverse order, passing in the return value from the calculation on the following element and returning the accumulated result upon completion. - * - * @param reducer - callback function - * @param initialValue - initial value - * @returns accumulated result - * - * @example - * function reducer( acc, v ) { - * return acc + v; - * } - * - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var out = arr.reduceRight( reducer, 0.0 ); - * // returns 6.0 - */ - reduceRight( reducer: Reducer, initialValue?: U ): U; - - /** - * Reverses an array in-place. - * - * @returns reversed array - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var out = arr.reverse(); - * // returns - * - * var v = out[ 0 ]; - * // returns 3.0 - * - * v = out[ 1 ]; - * // returns 2.0 - * - * v = out[ 2 ]; - * // returns 1.0 - */ - reverse(): Float16Array; - - /** - * Sets one or more array elements. - * - * ## Notes - * - * - When provided a typed array, we must check whether the source array shares the same buffer as the target array and whether the underlying memory overlaps. In particular, we are concerned with the following scenario: - * - * ```text - * buf: --------------------- - * src: --------------------- - * ``` - * - * In the above, as we copy values from `src`, we will overwrite values in the `src` view, resulting in duplicated values copied into the end of `buf`, which is not intended. Hence, to avoid overwriting source values, we must **copy** source values to a temporary array. - * - * In the other overlapping scenario, - * - * ```text - * buf: --------------------- - * src: --------------------- - * ``` - * - * by the time we begin copying into the overlapping region, we are copying from the end of `src`, a non-overlapping region, which means we don't run the risk of copying copied values, rather than the original `src` values as intended. - * - * - * @param value - value(s) - * @param i - element index at which to start writing values (default: 0) - * @throws index argument must be a nonnegative integer - * @throws index argument is out-of-bounds - * @throws target array lacks sufficient storage to accommodate source values - * - * @example - * var arr = new Float16Array( 10 ); - * - * var v = arr[ 0 ]; - * // returns 0.0 - * - * arr.set( [ 1.0 ], 0 ); - * - * v = arr[ 0 ]; - * // returns 1.0 - */ - set( value: ArrayLike, i?: number ): void; - - /** - * Copies a portion of a typed array to a new typed array. - * - * @param start - starting index (inclusive) - * @param end - ending index (exclusive) - * @throws indices must be integers - * @returns output array - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - * - * var out = arr.slice(); - * // returns - * - * var len = out.length; - * // returns 5 - * - * var v = out[ 0 ]; - * // returns 1.0 - * - * v = out[ len-1 ]; - * // returns 5.0 - * - * out = arr.slice( 1, -2 ); - * // returns - * - * len = out.length; - * // returns 2 - * - * v = out[ 0 ]; - * // returns 2.0 - * - * v = out[ len-1 ]; - * // returns 3.0 - */ - slice( start?: number, end?: number ): Float16Array; - - /** - * Tests whether at least one element in an array passes a test implemented by a predicate function. - * - * @param predicate - predicate function - * @param thisArg - predicate function execution context - * @returns boolean indicating whether at least one element passes a test - * - * @example - * function predicate( v ) { - * return v > 2.0; - * } - * - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var bool = arr.some( predicate ); - * // returns true - */ - some( predicate: Predicate, thisArg?: ThisParameterType> ): boolean; - - /** - * Sorts an array in-place. - * - * @param compareFcn - comparison function - * @returns sorted array - * - * @example - * function compare( a, b ) { - * if ( a < b ) { - * return -1; - * } - * if ( a > b ) { - * return 1; - * } - * return 0; - * } - * - * var arr = new Float16Array( [ 3.0, 1.0, 2.0 ] ); - * - * arr.sort( compare ); - * - * var v = arr[ 0 ]; - * // returns 1.0 - * - * v = arr[ 1 ]; - * // returns 2.0 - * - * v = arr[ 2 ]; - * // returns 3.0 - */ - sort( compareFcn?: CompareFcn ): Float16Array; - - /** - * Creates a new typed array view over the same underlying `ArrayBuffer` and with the same underlying data type as the host array. - * - * @param begin - starting index (inclusive) - * @param end - ending index (exclusive) - * @throws indices must be integers - * @returns subarray - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - * - * var subarr = arr.subarray(); - * // returns - * - * var len = subarr.length; - * // returns 5 - * - * var v = subarr[ 0 ]; - * // returns 1.0 - * - * v = subarr[ len-1 ]; - * // returns 5.0 - * - * subarr = arr.subarray( 1, -2 ); - * // returns - * - * len = subarr.length; - * // returns 2 - * - * v = subarr[ 0 ]; - * // returns 2.0 - * - * v = subarr[ len-1 ]; - * // returns 3.0 - */ - subarray( begin?: number, end?: number ): Float16Array; - - /** - * Serializes an array as a locale-specific string. - * - * @param locales - locale identifier(s) - * @param options - configuration options - * @returns string - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var str = arr.toLocaleString(); - * // returns '1,2,3' - */ - toLocaleString( locales?: string | Array, options?: LocaleOptions ): string; - - /** - * Returns a new typed array containing the elements in reversed order. - * - * @returns reversed array - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var out = arr.toReversed(); - * // returns - * - * var v = out[ 0 ]; - * // returns 3.0 - * - * v = out[ 1 ]; - * // returns 2.0 - * - * v = out[ 2 ]; - * // returns 1.0 - */ - toReversed(): Float16Array; - - /** - * Returns a new typed array containing the elements in sorted order. - * - * @param compareFcn - comparison function - * @returns sorted array - * - * @example - * function compare( a, b ) { - * if ( a < b ) { - * return -1; - * } - * if ( a > b ) { - * return 1; - * } - * return 0; - * } - * - * var arr = new Float16Array( [ 3.0, 1.0, 2.0 ] ); - * - * var out = arr.toSorted( compare ); - * // returns - * - * var v = out[ 0 ]; - * // returns 1.0 - * - * v = out[ 1 ]; - * // returns 2.0 - * - * v = out[ 2 ]; - * // returns 3.0 - */ - toSorted( compareFcn?: CompareFcn ): Float16Array; - - /** - * Serializes an array as a string. - * - * @returns string - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var str = arr.toString(); - * // returns '1,2,3' - */ - toString(): string; - - /** - * Returns an iterator for iterating over each value in a typed array. - * - * @returns iterator - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0 ] ); - * - * var iter = arr.values(); - * - * var v = iter.next().value; - * // returns 1.0 - * - * v = iter.next().value; - * // returns 2.0 - * - * var bool = iter.next().done; - * // returns true - */ - values(): TypedIterator; - - /** - * Returns a new typed array with the element at a provided index replaced with a provided value. - * - * @param index - element index - * @param value - new value - * @throws first argument must be an integer - * @throws second argument must be a number - * @throws index argument is out-of-bounds - * @returns modified typed array - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var out = arr.with( 0, 4.0 ); - * // returns - * - * var v = out[ 0 ]; - * // returns 4.0 - */ - with( index: number, value: number ): Float16Array; -} - -/** -* Interface defining a Float16Array constructor which is both "newable" and "callable". -*/ -interface Float16ArrayConstructor { - /** - * Half-precision floating-point number array constructor. - * - * @param arg - length, typed array, array-like object, or buffer - * @param byteOffset - byte offset (default: 0) - * @param length - view length - * @throws ArrayBuffer byte length must be a multiple of `2` - * @throws if provided only a single argument, must provide a valid argument - * @throws byte offset must be a nonnegative integer - * @throws byte offset must be a multiple of `2` - * @throws view length must be a positive multiple of `2` - * @throws must provide sufficient memory to accommodate byte offset and view length requirements - * @returns half-precision floating-point number array - * - * @example - * var arr = new Float16Array(); - * // returns - * - * var len = arr.length; - * // returns 0 - * - * @example - * var arr = new Float16Array( 2 ); - * // returns - * - * var len = arr.length; - * // returns 2 - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0 ] ); - * // returns - * - * var len = arr.length; - * // returns 2 - * - * @example - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = new Float16Array( buf ); - * // returns - * - * var len = arr.length; - * // returns 8 - * - * @example - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = new Float16Array( buf, 8 ); - * // returns - * - * var len = arr.length; - * // returns 4 - * - * @example - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = new Float16Array( buf, 8, 2 ); - * // returns - * - * var len = arr.length; - * // returns 2 - */ - new( arg?: number | ArrayLike | ArrayBuffer | Iterable, byteOffset?: number, length?: number ): Float16Array; - - /** - * Constructor name. - * - * @example - * var str = Float16Array.name; - * // returns 'Float16Array' - */ - readonly name: 'Float16Array'; - - /** - * Size (in bytes) of each array element. - * - * @example - * var nbytes = Float16Array.BYTES_PER_ELEMENT; - * // returns 2 - */ - readonly BYTES_PER_ELEMENT: 2; - - /** - * Creates a new half-precision floating-point number array from an array-like object or an iterable. - * - * @param src - array-like object or iterable - * @param clbk - callback to invoke for each source element - * @param thisArg - context - * @returns half-precision floating-point number array - * - * @example - * var arr = Float16Array.from( [ 1.0, 2.0 ] ); - * // returns - * - * var len = arr.length; - * // returns 2 - * - * @example - * function clbk( v ) { - * return v * 2.0; - * } - * - * var arr = Float16Array.from( [ 1.0, 2.0 ], clbk ); - * // returns - * - * var len = arr.length; - * // returns 2 - */ - from( src: ArrayLike | Iterable, clbk?: FromCallback, thisArg?: ThisParameterType> ): Float16Array; - - /** - * Creates a new half-precision floating-point number array from a variable number of arguments. - * - * @param elements - array elements - * @returns half-precision floating-point number array - * - * @example - * var arr = Float16Array.of( 1.0, 2.0, 3.0, 4.0 ); - * // returns - * - * var len = arr.length; - * // returns 4 - */ - of( ...elements: Array ): Float16Array; -} - -/** -* Half-precision floating-point number array constructor. -* -* @param arg - length, typed array, array-like object, or buffer -* @param byteOffset - byte offset (default: 0) -* @param length - view length -* @throws ArrayBuffer byte length must be a multiple of `2` -* @throws if provided only a single argument, must provide a valid argument -* @throws byte offset must be a nonnegative integer -* @throws byte offset must be a multiple of `2` -* @throws view length must be a positive multiple of `2` -* @throws must provide sufficient memory to accommodate byte offset and view length requirements -* @returns half-precision floating-point number array -* -* @example -* var arr = new Float16Array(); -* // returns -* -* var len = arr.length; -* // returns 0 -* -* @example -* var arr = new Float16Array( 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var arr = new Float16Array( [ 1.0, 2.0 ] ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float16Array( buf ); -* // returns -* -* var len = arr.length; -* // returns 8 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float16Array( buf, 8 ); -* // returns -* -* var len = arr.length; -* // returns 4 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = new Float16Array( buf, 8, 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -*/ -declare var ctor: Float16ArrayConstructor; - - -// EXPORTS // - -export = ctor; - -// eslint-doctest-alias: Float16Array diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 16ac68e..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-float16array-support@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.3-esm/index.mjs";import{isPrimitive as n}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.3-esm/index.mjs";import{primitives as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string-array@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.3-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.3-esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.3-esm/index.mjs";import{isPrimitive as h}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.3-esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.3-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-assert-is-nan@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.4-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.3-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@v0.2.4-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint16@v0.2.3-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-float16@v0.1.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float16-base-to-word@v0.1.1-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float16-base-from-word@v0.2.1-esm/index.mjs";import T from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-base-gcopy@v0.2.3-esm/index.mjs";function _(t){var r,n;for(r=[];!(n=t.next()).done;)r.push(b(m(n.value)));return r}var j=g.BYTES_PER_ELEMENT,x=r();function L(t){return"object"==typeof t&&null!==t&&"Float16Array"===t.constructor.name&&t.BYTES_PER_ELEMENT===j}function R(t){return t===A}function O(t,r){return function(){return t._get(r)}}function S(t,r){return function(n){t.set([n],r)}}function A(){var t,r,i,h,l,u;if(r=arguments.length,!(this instanceof A))return 0===r?new A:1===r?new A(arguments[0]):2===r?new A(arguments[0],arguments[1]):new A(arguments[0],arguments[1],arguments[2]);if(0===r)i=new g(0);else if(1===r)if(n(l=arguments[0]))i=new g(l);else if(e(l))L(l)?(i=new g(l.length),T.ndarray(l.length,new g(l.buffer,l.byteOffset,l.length),1,0,i,1,0)):i=function(t,r){var n,i;for(n=r.length,i=0;ii.byteLength-t)throw new RangeError(d("null2G",h*j));i=new g(i,t,h)}}for(y(this,"_buffer",i),y(this,"_length",i.length),u=0;u1){if(!s(i=arguments[1]))throw new TypeError(d("null2H",i));n>2&&(r=arguments[2])}if(e(t)){if(i){for(f=(o=new this(l=t.length))._buffer,u=0;u=this._length))return E(this._buffer[t])})),w(A.prototype,"buffer",(function(){return this._buffer.buffer})),w(A.prototype,"byteLength",(function(){return this._buffer.byteLength})),w(A.prototype,"byteOffset",(function(){return this._buffer.byteOffset})),y(A.prototype,"BYTES_PER_ELEMENT",A.BYTES_PER_ELEMENT),y(A.prototype,"copyWithin",(function(t,r){if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");return 2===arguments.length?this._buffer.copyWithin(t,r):this._buffer.copyWithin(t,r,arguments[2]),this})),y(A.prototype,"entries",(function(){var t,r,n,i,e,o;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");return t=this,i=this._buffer,n=this._length,o=-1,y(r={},"next",(function(){if(o+=1,e||o>=n)return{done:!0};return{value:[o,E(i[o])],done:!1}})),y(r,"return",(function(t){if(e=!0,arguments.length)return{value:t,done:!0};return{done:!0}})),p&&y(r,p,(function(){return t.entries()})),r})),y(A.prototype,"every",(function(t,r){var n,i;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!s(t))throw new TypeError(d("null3c",t));for(n=this._buffer,i=0;i1){if(!f(r))throw new TypeError(d("null7f",r));if(r<0&&(r+=e)<0&&(r=0),arguments.length>2){if(!f(n))throw new TypeError(d("null2z",n));n<0&&(n+=e)<0&&(n=0),n>e&&(n=e)}else n=e}else r=0,n=e;for(s=b(t),o=r;o=0;e--)if(i=E(n[e]),t.call(r,i,e,this))return i})),y(A.prototype,"findLastIndex",(function(t,r){var n,i,e;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!s(t))throw new TypeError(d("null3c",t));for(n=this._buffer,e=this._length-1;e>=0;e--)if(i=E(n[e]),t.call(r,i,e,this))return e;return-1})),y(A.prototype,"forEach",(function(t,r){var n,i;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!s(t))throw new TypeError(d("null3c",t));for(n=this._buffer,i=0;i=this._length))return E(this._buffer[t])})),y(A.prototype,"includes",(function(t,r){var n,i,e;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!h(t))throw new TypeError(d("null49",t));if(arguments.length>1){if(!f(r))throw new TypeError(d("null7f",r));r<0&&(r+=this._length)<0&&(r=0)}else r=0;for(n=this._buffer,e=b(t),i=r;i1){if(!f(r))throw new TypeError(d("null7f",r));r<0&&(r+=this._length)<0&&(r=0)}else r=0;for(n=this._buffer,e=b(t),i=r;i0){if(!l(t))throw new TypeError(d("null3F",t))}else t=",";for(r=this._buffer,n=[],i=0;i=n)return{done:!0};return{value:e,done:!1}})),y(r,"return",(function(t){if(i=!0,arguments.length)return{value:t,done:!0};return{done:!0}})),p&&y(r,p,(function(){return t.keys()})),r})),y(A.prototype,"lastIndexOf",(function(t,r){var n,i,e;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!h(t))throw new TypeError(d("null49",t));if(arguments.length>1){if(!f(r))throw new TypeError(d("null7f",r));r>=this._length?r=this._length-1:r<0&&(r+=this._length)}else r=this._length-1;for(n=this._buffer,e=b(t),i=r;i>=0;i--)if(e===n[i])return i;return-1})),w(A.prototype,"length",(function(){return this._length})),y(A.prototype,"map",(function(t,r){var n,i,e,o;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!s(t))throw new TypeError(d("null3c"),t);for(e=this._buffer,n=(i=new this.constructor(this._length))._buffer,o=0;o1)e=r,o=0;else{if(0===i)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");e=E(n[0]),o=1}for(;o1)e=r,o=i-1;else{if(0===i)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");e=E(n[i-1]),o=i-2}for(;o>=0;o--)e=t(e,E(n[o]),o,this);return e})),y(A.prototype,"reverse",(function(){var t,r,n,i,e,o;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");for(t=this._buffer,n=this._length,i=v(n/2),e=0;e1){if(!n(i=arguments[1]))throw new TypeError(d("null2L",i))}else i=0;if(i+(h=t.length)>this._length)throw new RangeError(d("null03"));if(L(t)?(r=t._buffer,f=!0):(r=t,f=!1),a=o.byteOffset+i*j,r.buffer===o.buffer&&r.byteOffseta){for(s=new g(r.length),l=0;ls&&(r=s)}}for(n=ti)return 1;return 0})),this;if(!s(t))throw new TypeError(d("null3c",t));return r.sort((function(r,n){return t(E(r),E(n))})),this})),y(A.prototype,"subarray",(function(t,r){var n,i,e;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(i=this._buffer,e=this._length,0===arguments.length)t=0,r=e;else{if(!f(t))throw new TypeError(d("null7e",t));if(t<0&&(t+=e)<0&&(t=0),1===arguments.length)r=e;else{if(!f(r))throw new TypeError(d("null7f",r));r<0?(r+=e)<0&&(r=0):r>e&&(r=e)}}return t>=e?(e=0,n=i.byteLength):t>=r?(e=0,n=i.byteOffset+t*j):(e=r-t,n=i.byteOffset+t*j),new this.constructor(i.buffer,n,e<0?0:e)})),y(A.prototype,"toLocaleString",(function(t,r){var n,e,o,s,f;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(0===arguments.length)e=[];else{if(!l(t)&&!i(t))throw new TypeError(d("invalid argument. First argument must be a string or an array of strings. Value: `%s`.",t));e=t}if(arguments.length<2)n={};else{if(!a(r))throw new TypeError(d("null2V",r));n=r}for(s=this._buffer,o=[],f=0;f=n)return{done:!0};return{value:E(e[o]),done:!1}})),y(t,"return",(function(t){if(i=!0,arguments.length)return{value:t,done:!0};return{done:!0}})),p&&y(t,p,(function(){return r.values()})),t})),y(A.prototype,"with",(function(t,r){var n,i;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!f(t))throw new TypeError(d("null7e",t));if(i=this._length,t<0&&(t+=i),t<0||t>=i)throw new RangeError(d("nullFP",t));if(!h(r))throw new TypeError(d("invalid argument. Second argument must be a floating-point number. Value: `%s`.",r));return(n=new this.constructor(this))[t]=r,n}));var P="function"==typeof Float16Array?Float16Array:void 0,F=t()?P:A;export{F as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index d0d8a32..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/polyfill/from_iterator.js","../lib/polyfill/index.js","../lib/polyfill/from_array.js","../lib/polyfill/from_iterator_map.js","../lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport f16 from '@stdlib/number-float64-base-to-float16';\nimport toWord from '@stdlib/number-float16-base-to-word';\n\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @returns {Array} output array\n*/\nfunction fromIterator( it ) {\n\tvar out;\n\tvar v;\n\n\tout = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tout.push( toWord( f16( v.value ) ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIterator;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this, stdlib/jsdoc-typedef-typos, max-lines */\n\n'use strict';\n\n// MODULES //\n\nimport hasIteratorSymbolSupport from '@stdlib/assert-has-iterator-symbol-support';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport { primitives as isStringArray } from '@stdlib/assert-is-string-array';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isFunction from '@stdlib/assert-is-function';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isObject from '@stdlib/assert-is-object';\nimport isnan from '@stdlib/math-base-assert-is-nan';\nimport ITERATOR_SYMBOL from '@stdlib/symbol-iterator';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadWriteAccessor from '@stdlib/utils-define-read-write-accessor';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport Uint16Array from '@stdlib/array-uint16';\nimport f16 from '@stdlib/number-float64-base-to-float16';\nimport toWord from '@stdlib/number-float16-base-to-word';\nimport fromWord from '@stdlib/number-float16-base-from-word';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport fromArray from './from_array.js';\nimport fromIterator from './from_iterator.js';\nimport fromIteratorMap from './from_iterator_map.js';\n\n\n// VARIABLES //\n\nvar BYTES_PER_ELEMENT = Uint16Array.BYTES_PER_ELEMENT;\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\n\n\n// FUNCTIONS //\n\n/**\n* Returns a boolean indicating if a value is a `Float16Array`.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `Float16Array`\n*/\nfunction isFloat16Array( value ) {\n\treturn (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\tvalue.constructor.name === 'Float16Array' &&\n\t\tvalue.BYTES_PER_ELEMENT === BYTES_PER_ELEMENT\n\t);\n}\n\n/**\n* Returns a boolean indicating if a value is a floating-point typed array constructor.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a floating-point typed array constructor\n*/\nfunction isFloatingPointArrayConstructor( value ) { // eslint-disable-line id-length\n\treturn ( value === Float16Array );\n}\n\n/**\n* Returns a getter.\n*\n* @private\n* @param {Float16Array} ctx - typed array instance\n* @param {NonNegativeInteger} idx - element index\n* @returns {Function} getter\n*/\nfunction getter( ctx, idx ) {\n\treturn get;\n\n\t/**\n\t* Returns an array element.\n\t*\n\t* @private\n\t* @returns {(number|void)} array element\n\t*/\n\tfunction get() {\n\t\treturn ctx._get( idx ); // eslint-disable-line no-underscore-dangle\n\t}\n}\n\n/**\n* Returns a setter.\n*\n* @private\n* @param {Float16Array} ctx - typed array instance\n* @param {NonNegativeInteger} idx - element index\n* @returns {Function} setter\n*/\nfunction setter( ctx, idx ) {\n\treturn set;\n\n\t/**\n\t* Sets an array element.\n\t*\n\t* @private\n\t* @param {number} value - value to set\n\t*/\n\tfunction set( value ) {\n\t\tctx.set( [ value ], idx );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* 16-bit floating-point number array constructor.\n*\n* @constructor\n* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable\n* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n* @param {NonNegativeInteger} [length] - view length\n* @throws {RangeError} ArrayBuffer byte length must be a multiple of `2`\n* @throws {TypeError} if provided only a single argument, must provide a valid argument\n* @throws {TypeError} byte offset must be a nonnegative integer\n* @throws {RangeError} byte offset must be a multiple of `2`\n* @throws {TypeError} view length must be a positive multiple of `2`\n* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n* @returns {Float16Array} half-precision floating-point number array\n*\n* @example\n* var arr = new Float16Array();\n* // returns \n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var arr = new Float16Array( 5 );\n* // returns \n*\n* var len = arr.length;\n* // returns 5\n*\n* @example\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 5\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float16Array( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 8\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float16Array( buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 4\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Float16Array( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nfunction Float16Array() {\n\tvar byteOffset;\n\tvar nargs;\n\tvar buf;\n\tvar len;\n\tvar arg;\n\tvar i;\n\n\tnargs = arguments.length;\n\tif ( !(this instanceof Float16Array) ) {\n\t\tif ( nargs === 0 ) {\n\t\t\treturn new Float16Array();\n\t\t}\n\t\tif ( nargs === 1 ) {\n\t\t\treturn new Float16Array( arguments[0] );\n\t\t}\n\t\tif ( nargs === 2 ) {\n\t\t\treturn new Float16Array( arguments[0], arguments[1] );\n\t\t}\n\t\treturn new Float16Array( arguments[0], arguments[1], arguments[2] );\n\t}\n\t// Create the underlying data buffer...\n\tif ( nargs === 0 ) {\n\t\tbuf = new Uint16Array( 0 ); // backward-compatibility\n\t} else if ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\t\tif ( isNonNegativeInteger( arg ) ) {\n\t\t\tbuf = new Uint16Array( arg );\n\t\t} else if ( isCollection( arg ) ) {\n\t\t\tif ( isFloat16Array( arg ) ) {\n\t\t\t\tbuf = new Uint16Array( arg.length );\n\t\t\t\tgcopy.ndarray( arg.length, new Uint16Array( arg.buffer, arg.byteOffset, arg.length ), 1, 0, buf, 1, 0 ); // eslint-disable-line max-len\n\t\t\t} else {\n\t\t\t\tbuf = fromArray( new Uint16Array( arg.length ), arg );\n\t\t\t}\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tif ( !isInteger( arg.byteLength/BYTES_PER_ELEMENT ) ) {\n\t\t\t\tthrow new RangeError( format( 'nullE9', BYTES_PER_ELEMENT, arg.byteLength ) );\n\t\t\t}\n\t\t\tbuf = new Uint16Array( arg );\n\t\t} else if ( isObject( arg ) ) {\n\t\t\tif ( HAS_ITERATOR_SYMBOL === false ) {\n\t\t\t\tthrow new TypeError( format( 'null29', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2A', arg ) );\n\t\t\t}\n\t\t\tbuf = arg[ ITERATOR_SYMBOL ]();\n\t\t\tif ( !isFunction( buf.next ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2A', arg ) );\n\t\t\t}\n\t\t\tbuf = new Uint16Array( fromIterator( buf ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( 'null2A', arg ) );\n\t\t}\n\t} else {\n\t\tbuf = arguments[ 0 ];\n\t\tif ( !isArrayBuffer( buf ) ) {\n\t\t\tthrow new TypeError( format( 'null2B', buf ) );\n\t\t}\n\t\tbyteOffset = arguments[ 1 ];\n\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\tthrow new TypeError( format( 'null2C', byteOffset ) );\n\t\t}\n\t\tif ( !isInteger( byteOffset/BYTES_PER_ELEMENT ) ) {\n\t\t\tthrow new RangeError( format( 'nullEA', BYTES_PER_ELEMENT, byteOffset ) );\n\t\t}\n\t\tif ( nargs === 2 ) {\n\t\t\tlen = buf.byteLength - byteOffset;\n\t\t\tif ( !isInteger( len/BYTES_PER_ELEMENT ) ) {\n\t\t\t\tthrow new RangeError( format( 'null2E', BYTES_PER_ELEMENT, len ) );\n\t\t\t}\n\t\t\tbuf = new Uint16Array( buf, byteOffset );\n\t\t} else {\n\t\t\tlen = arguments[ 2 ];\n\t\t\tif ( !isNonNegativeInteger( len ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2F', len ) );\n\t\t\t}\n\t\t\tif ( (len*BYTES_PER_ELEMENT) > (buf.byteLength-byteOffset) ) {\n\t\t\t\tthrow new RangeError( format( 'null2G', len*BYTES_PER_ELEMENT ) );\n\t\t\t}\n\t\t\tbuf = new Uint16Array( buf, byteOffset, len );\n\t\t}\n\t}\n\tsetReadOnly( this, '_buffer', buf );\n\tsetReadOnly( this, '_length', buf.length );\n\tfor ( i = 0; i < buf.length; i++ ) {\n\t\tsetReadWriteAccessor( this, i, getter( this, i ), setter( this, i ) );\n\t}\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each array element.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Float16Array\n* @readonly\n* @type {PositiveInteger}\n* @default 2\n*\n* @example\n* var nbytes = Float16Array.BYTES_PER_ELEMENT;\n* // returns 2\n*/\nsetReadOnly( Float16Array, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT );\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof Float16Array\n* @readonly\n* @type {string}\n* @default 'Float16Array'\n*\n* @example\n* var str = Float16Array.name;\n* // returns 'Float16Array'\n*/\nsetReadOnly( Float16Array, 'name', 'Float16Array' );\n\n/**\n* Creates a new 16-bit floating-point number array from an array-like object or an iterable.\n*\n* @name from\n* @memberof Float16Array\n* @type {Function}\n* @param {(Collection|Iterable)} src - array-like object or iterable\n* @param {Function} [clbk] - callback to invoke for each source element\n* @param {*} [thisArg] - context\n* @throws {TypeError} `this` context must be a constructor\n* @throws {TypeError} `this` must be a floating-point array\n* @throws {TypeError} first argument must be an array-like object or an iterable\n* @throws {TypeError} second argument must be a function\n* @returns {Float16Array} half-precision floating-point number array\n*\n* @example\n* var arr = Float16Array.from( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* function clbk( v ) {\n* return v * 2.0;\n* }\n*\n* var arr = Float16Array.from( [ 1.0, 2.0 ], clbk );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nsetReadOnly( Float16Array, 'from', function from( src ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar clbk;\n\tvar out;\n\tvar buf;\n\tvar tmp;\n\tvar len;\n\tvar i;\n\tif ( !isFunction( this ) ) {\n\t\tthrow new TypeError( format('null01') );\n\t}\n\tif ( !isFloatingPointArrayConstructor( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point array.' );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs > 1 ) {\n\t\tclbk = arguments[ 1 ];\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'null2H', clbk ) );\n\t\t}\n\t\tif ( nargs > 2 ) {\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( isCollection( src ) ) {\n\t\tif ( clbk ) {\n\t\t\tlen = src.length;\n\t\t\tout = new this( len );\n\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tbuf[ i ] = toWord( f16( clbk.call( thisArg, src[ i ], i ) ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\treturn new this( src );\n\t}\n\tif ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) { // eslint-disable-line max-len\n\t\tbuf = src[ ITERATOR_SYMBOL ]();\n\t\tif ( !isFunction( buf.next ) ) {\n\t\t\tthrow new TypeError( format( 'null2J', src ) );\n\t\t}\n\t\tif ( clbk ) {\n\t\t\ttmp = fromIteratorMap( buf, clbk, thisArg );\n\t\t} else {\n\t\t\ttmp = fromIterator( buf );\n\t\t}\n\t\tif ( tmp instanceof Error ) {\n\t\t\tthrow tmp;\n\t\t}\n\t\tlen = tmp.length;\n\t\tout = new this( len );\n\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tbuf[ i ] = tmp[ i ];\n\t\t}\n\t\treturn out;\n\t}\n\tthrow new TypeError( format( 'null2J', src ) );\n});\n\n/**\n* Creates a new 16-bit floating-point number array from a variable number of arguments.\n*\n* @name of\n* @memberof Float16Array\n* @type {Function}\n* @param {...*} element - array elements\n* @throws {TypeError} `this` context must be a constructor\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Float16Array} half-precision floating-point number array\n*\n* @example\n* var arr = Float16Array.of( 1.0, 1.0, 1.0, 1.0 );\n* // returns \n*\n* var x = arr[ 0 ];\n* // returns 1.0\n*\n* var len = arr.length;\n* // returns 4\n*/\nsetReadOnly( Float16Array, 'of', function of() {\n\tvar args;\n\tvar i;\n\tif ( !isFunction( this ) ) {\n\t\tthrow new TypeError( format('null01') );\n\t}\n\tif ( !isFloatingPointArrayConstructor( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\targs = [];\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\targs.push( arguments[ i ] );\n\t}\n\treturn new this( args );\n});\n\n/**\n* Returns an array element with support for both nonnegative and negative integer indices.\n*\n* @name at\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} must provide an integer\n* @returns {(number|void)} array element\n*\n* @example\n* var arr = new Float16Array( [ 10.0, 20.0, 30.0 ] );\n*\n* var v = arr.at( 0 );\n* // returns 10.0\n*\n* v = arr.at( -1 );\n* // returns 30.0\n*\n* v = arr.at( 100 );\n* // returns undefined\n*/\nsetReadOnly( Float16Array.prototype, 'at', function at( idx ) {\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'null8A', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += this._length;\n\t}\n\tif ( idx < 0 || idx >= this._length ) {\n\t\treturn;\n\t}\n\treturn fromWord( this._buffer[ idx ] );\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name buffer\n* @memberof Float16Array.prototype\n* @readonly\n* @type {ArrayBuffer}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var buf = arr.buffer;\n* // returns \n*/\nsetReadOnlyAccessor( Float16Array.prototype, 'buffer', function get() {\n\treturn this._buffer.buffer;\n});\n\n/**\n* Size (in bytes) of the array.\n*\n* @name byteLength\n* @memberof Float16Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var byteLength = arr.byteLength;\n* // returns 20\n*/\nsetReadOnlyAccessor( Float16Array.prototype, 'byteLength', function get() {\n\treturn this._buffer.byteLength;\n});\n\n/**\n* Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`.\n*\n* @name byteOffset\n* @memberof Float16Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var byteOffset = arr.byteOffset;\n* // returns 0\n*/\nsetReadOnlyAccessor( Float16Array.prototype, 'byteOffset', function get() {\n\treturn this._buffer.byteOffset;\n});\n\n/**\n* Size (in bytes) of each array element.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Float16Array.prototype\n* @readonly\n* @type {PositiveInteger}\n* @default 2\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var nbytes = arr.BYTES_PER_ELEMENT;\n* // returns 2\n*/\nsetReadOnly( Float16Array.prototype, 'BYTES_PER_ELEMENT', Float16Array.BYTES_PER_ELEMENT );\n\n/**\n* Copies a sequence of elements within the array to the position starting at `target`.\n*\n* @name copyWithin\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} target - index at which to start copying elements\n* @param {integer} start - source index at which to copy elements from\n* @param {integer} [end] - source index at which to stop copying elements from\n* @throws {TypeError} `this` must be a floating-point array\n* @returns {Float16Array} modified array\n*\n* @example\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0 ] );\n*\n* // Copy the first two elements to the last two elements:\n* arr.copyWithin( 2, 0, 2 );\n*\n* var v = arr[ 2 ];\n* // returns 1.0\n*\n* v = arr[ 3 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'copyWithin', function copyWithin( target, start ) {\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\t// FIXME: prefer a functional `copyWithin` implementation which addresses lack of universal browser support (e.g., IE11 and Safari) or ensure that typed arrays are polyfilled\n\tif ( arguments.length === 2 ) {\n\t\tthis._buffer.copyWithin( target, start );\n\t} else {\n\t\tthis._buffer.copyWithin( target, start, arguments[2] );\n\t}\n\treturn this;\n});\n\n/**\n* Returns an iterator for iterating over array key-value pairs.\n*\n* @name entries\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] );\n*\n* var it = arr.entries();\n*\n* var v = it.next().value;\n* // returns [ 0, 1.0 ]\n*\n* v = it.next().value;\n* // returns [ 1, 2.0 ]\n*\n* v = it.next().value;\n* // returns [ 2, 3.0 ]\n*\n* var bool = it.next().done;\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'entries', function entries() {\n\tvar self;\n\tvar iter;\n\tvar len;\n\tvar buf;\n\tvar FLG;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tself = this;\n\tbuf = this._buffer;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': [ i, fromWord( buf[ i ] ) ],\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.entries();\n\t}\n});\n\n/**\n* Tests whether all elements in an array pass a test implemented by a predicate function.\n*\n* @name every\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {boolean} boolean indicating whether all elements pass a test\n*\n* @example\n* function predicate( v ) {\n* return v === 0.0;\n* }\n*\n* var arr = new Float16Array( 3 );\n*\n* var bool = arr.every( predicate );\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'every', function every( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( !predicate.call( thisArg, fromWord( buf[ i ] ), i, this ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n});\n\n/**\n* Returns a modified typed array filled with a fill value.\n*\n* @name fill\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {number} value - fill value\n* @param {integer} [start=0] - starting index (inclusive)\n* @param {integer} [end] - ending index (exclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a floating-point number\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be an integer\n* @returns {Float16Array} modified array\n*\n* @example\n* var arr = new Float16Array( 3 );\n*\n* arr.fill( 1.0, 1 );\n*\n* var v = arr[ 0 ];\n* // returns 0.0\n*\n* v = arr[ 1 ];\n* // returns 1.0\n*\n* v = arr[ 2 ];\n* // returns 1.0\n*/\nsetReadOnly( Float16Array.prototype, 'fill', function fill( value, start, end ) {\n\tvar buf;\n\tvar len;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNumber( value ) ) {\n\t\tthrow new TypeError( format( 'null49', value ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( start ) ) {\n\t\t\tthrow new TypeError( format( 'null7f', start ) );\n\t\t}\n\t\tif ( start < 0 ) {\n\t\t\tstart += len;\n\t\t\tif ( start < 0 ) {\n\t\t\t\tstart = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length > 2 ) {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2z', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t} else {\n\t\t\tend = len;\n\t\t}\n\t} else {\n\t\tstart = 0;\n\t\tend = len;\n\t}\n\tv = toWord( value );\n\tfor ( i = start; i < end; i++ ) {\n\t\tbuf[ i ] = v;\n\t}\n\treturn this;\n});\n\n/**\n* Returns a new array containing the elements of an array which pass a test implemented by a predicate function.\n*\n* @name filter\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {Float16Array} floating-point number array\n*\n* @example\n* function predicate( v ) {\n* return ( v === 0.0 );\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] );\n*\n* var out = arr.filter( predicate );\n* // returns \n*\n* var len = out.length;\n* // returns 2\n*\n* var v = out[ 0 ];\n* // returns 0.0\n*\n* v = out[ 1 ];\n* // returns 0.0\n*/\nsetReadOnly( Float16Array.prototype, 'filter', function filter( predicate, thisArg ) {\n\tvar buf;\n\tvar out;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\tout.push( v );\n\t\t}\n\t}\n\treturn new this.constructor( out );\n});\n\n/**\n* Returns the first element in an array for which a predicate function returns a truthy value.\n*\n* @name find\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {(boolean|void)} array element or undefined\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] );\n*\n* var v = arr.find( predicate );\n* // returns 1.0\n*/\nsetReadOnly( Float16Array.prototype, 'find', function find( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn v;\n\t\t}\n\t}\n});\n\n/**\n* Returns the index of the first element in an array for which a predicate function returns a truthy value.\n*\n* @name findIndex\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {integer} index or -1\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var v = arr.findIndex( predicate );\n* // returns 1\n*/\nsetReadOnly( Float16Array.prototype, 'findIndex', function findIndex( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Returns the last element in an array for which a predicate function returns a truthy value.\n*\n* @name findLast\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {(boolean|void)} array element or undefined\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] );\n*\n* var v = arr.findLast( predicate );\n* // returns 1.0\n*/\nsetReadOnly( Float16Array.prototype, 'findLast', function findLast( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = this._length-1; i >= 0; i-- ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn v;\n\t\t}\n\t}\n});\n\n/**\n* Returns the index of the last element in an array for which a predicate function returns a truthy value.\n*\n* @name findLastIndex\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {integer} index or -1\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] );\n*\n* var v = arr.findLastIndex( predicate );\n* // returns 1\n*/\nsetReadOnly( Float16Array.prototype, 'findLastIndex', function findLastIndex( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = this._length-1; i >= 0; i-- ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Invokes a function once for each array element.\n*\n* @name forEach\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} fcn - function to invoke\n* @param {*} [thisArg] - function invocation context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n*\n* @example\n* function log( v, i ) {\n* console.log( '%s: %s', i, v.toString() );\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* arr.forEach( log );\n*/\nsetReadOnly( Float16Array.prototype, 'forEach', function forEach( fcn, thisArg ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( fcn ) ) {\n\t\tthrow new TypeError( format( 'null3c', fcn ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tfcn.call( thisArg, fromWord( buf[ i ] ), i, this );\n\t}\n});\n\n/**\n* Returns an array element.\n*\n* @private\n* @name _get\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {NonNegativeInteger} idx - element index\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} must provide a nonnegative integer\n* @returns {(number|void)} array element\n*/\nsetReadOnly( Float16Array.prototype, '_get', function get( idx ) {\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNonNegativeInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'null2K', idx ) );\n\t}\n\tif ( idx >= this._length ) {\n\t\treturn;\n\t}\n\treturn fromWord( this._buffer[ idx ] );\n});\n\n/**\n* Returns a boolean indicating whether an array includes a provided value.\n*\n* @name includes\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {number} searchElement - search element\n* @param {integer} [fromIndex=0] - starting index (inclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a floating-point number\n* @throws {TypeError} second argument must be an integer\n* @returns {boolean} boolean indicating whether an array includes a value\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] );\n*\n* var bool = arr.includes( 1.0 );\n* // returns true\n*\n* bool = arr.includes( 1.0, 2 );\n* // returns false\n*\n* bool = arr.includes( 5.0 );\n* // returns false\n*/\nsetReadOnly( Float16Array.prototype, 'includes', function includes( searchElement, fromIndex ) {\n\tvar buf;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNumber( searchElement ) ) {\n\t\tthrow new TypeError( format( 'null49', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'null7f', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\tfromIndex = 0;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfromIndex = 0;\n\t}\n\tbuf = this._buffer;\n\tv = toWord( searchElement );\n\tfor ( i = fromIndex; i < this._length; i++ ) {\n\t\tif ( v === buf[ i ] ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n});\n\n/**\n* Returns the first index at which a given element can be found.\n*\n* @name indexOf\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {float16} searchElement - element to find\n* @param {integer} [fromIndex=0] - starting index (inclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a floating-point number\n* @throws {TypeError} second argument must be an integer\n* @returns {integer} index or -1\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] );\n*\n* var idx = arr.indexOf( 2.0 );\n* // returns 2\n*\n* idx = arr.indexOf( 2.0, 3 );\n* // returns -1\n*\n* idx = arr.indexOf( 3.0, 3 );\n* // returns 3\n*/\nsetReadOnly( Float16Array.prototype, 'indexOf', function indexOf( searchElement, fromIndex ) {\n\tvar buf;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNumber( searchElement ) ) {\n\t\tthrow new TypeError( format( 'null49', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'null7f', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\tfromIndex = 0;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfromIndex = 0;\n\t}\n\tbuf = this._buffer;\n\tv = toWord( searchElement );\n\tfor ( i = fromIndex; i < this._length; i++ ) {\n\t\tif ( v === buf[ i ] ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Returns a new string by concatenating all array elements.\n*\n* @name join\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {string} [separator=','] - element separator\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a string\n* @returns {string} string representation\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var str = arr.join();\n* // returns '0,1,2'\n*\n* str = arr.join( '|' );\n* // returns '0|1|2'\n*/\nsetReadOnly( Float16Array.prototype, 'join', function join( separator ) {\n\tvar buf;\n\tvar out;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( arguments.length > 0 ) {\n\t\tif ( !isString( separator ) ) {\n\t\t\tthrow new TypeError( format( 'null3F', separator ) );\n\t\t}\n\t} else {\n\t\tseparator = ',';\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( fromWord( buf[ i ] ) );\n\t}\n\treturn out.join( separator );\n});\n\n/**\n* Returns an iterator for iterating over each index key in a typed array.\n*\n* @name keys\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new Float16Array( [ 1.0, 2.0 ] );\n*\n* var iter = arr.keys();\n*\n* var v = iter.next().value;\n* // returns 0\n*\n* v = iter.next().value;\n* // returns 1\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'keys', function keys() {\n\tvar self;\n\tvar iter;\n\tvar len;\n\tvar FLG;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tself = this;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': i,\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.keys();\n\t}\n});\n\n/**\n* Returns the last index at which a given element can be found.\n*\n* @name lastIndexOf\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {number} searchElement - element to find\n* @param {integer} [fromIndex] - starting index (inclusive)\n* @throws {TypeError} `this` must be a floating-point number\n* @throws {TypeError} first argument must be a numeric value\n* @throws {TypeError} second argument must be an integer\n* @returns {integer} index or -1\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 2.0 ] );\n*\n* var idx = arr.lastIndexOf( 2.0 );\n* // returns 4\n*\n* idx = arr.lastIndexOf( 2.0, 3 );\n* // returns 2\n*\n* idx = arr.lastIndexOf( 4.0, 3 );\n* // returns -1\n*\n* idx = arr.lastIndexOf( 1.0, -3 );\n* // returns 1\n*/\nsetReadOnly( Float16Array.prototype, 'lastIndexOf', function lastIndexOf( searchElement, fromIndex ) {\n\tvar buf;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNumber( searchElement ) ) {\n\t\tthrow new TypeError( format( 'null49', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'null7f', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex >= this._length ) {\n\t\t\tfromIndex = this._length - 1;\n\t\t} else if ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t}\n\t} else {\n\t\tfromIndex = this._length - 1;\n\t}\n\tbuf = this._buffer;\n\tv = toWord( searchElement );\n\tfor ( i = fromIndex; i >= 0; i-- ) {\n\t\tif ( v === buf[ i ] ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Number of array elements.\n*\n* @name length\n* @memberof Float16Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var len = arr.length;\n* // returns 10\n*/\nsetReadOnlyAccessor( Float16Array.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Returns a new array with each element being the result of a provided callback function.\n*\n* @name map\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} fcn - callback function\n* @param {*} [thisArg] - callback function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {Float16Array} new floating-point number array\n*\n* @example\n* function scale( v ) {\n* return v * 2.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var out = arr.map( scale );\n* // returns \n*\n* var z = out[ 0 ];\n* // returns 0.0\n*\n* z = out[ 1 ];\n* // returns 2.0\n*\n* z = out[ 2 ];\n* // returns 4.0\n*/\nsetReadOnly( Float16Array.prototype, 'map', function map( fcn, thisArg ) {\n\tvar outbuf;\n\tvar out;\n\tvar buf;\n\tvar i;\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( fcn ) ) {\n\t\tthrow new TypeError( format('null3c'), fcn );\n\t}\n\tbuf = this._buffer;\n\tout = new this.constructor( this._length );\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\toutbuf[ i ] = toWord( fcn.call( thisArg, fromWord( buf[ i ] ), i, this ) ); // eslint-disable-line max-len\n\t}\n\treturn out;\n});\n\n/**\n* Applies a provided callback function to each element of the array, in order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion.\n*\n* @name reduce\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} reducer - callback function\n* @param {*} [initialValue] - initial value\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {Error} if not provided an initial value, the array must have at least one element\n* @returns {*} accumulated result\n*\n* @example\n* function add( acc, v ) {\n* return acc + v;\n* }\n*\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] );\n*\n* var out = arr.reduce( add, 0 );\n* // returns 6.0\n*/\nsetReadOnly( Float16Array.prototype, 'reduce', function reduce( reducer, initialValue ) {\n\tvar buf;\n\tvar len;\n\tvar acc;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( reducer ) ) {\n\t\tthrow new TypeError( format( 'null3c', reducer ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tacc = initialValue;\n\t\ti = 0;\n\t} else {\n\t\tif ( len === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' );\n\t\t}\n\t\tacc = fromWord( buf[ 0 ] );\n\t\ti = 1;\n\t}\n\tfor ( ; i < len; i++ ) {\n\t\tacc = reducer( acc, fromWord( buf[ i ] ), i, this );\n\t}\n\treturn acc;\n});\n\n/**\n* Applies a provided callback function to each element of the array, in reverse order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion.\n*\n* @name reduceRight\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} reducer - callback function\n* @param {*} [initialValue] - initial value\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {Error} if not provided an initial value, the array must have at least one element\n* @returns {*} accumulated result\n*\n* @example\n* function add( acc, v ) {\n* return acc + v;\n* }\n*\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] );\n*\n* var out = arr.reduceRight( add, 0 );\n* // returns 6.0\n*/\nsetReadOnly( Float16Array.prototype, 'reduceRight', function reduceRight( reducer, initialValue ) {\n\tvar buf;\n\tvar len;\n\tvar acc;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( reducer ) ) {\n\t\tthrow new TypeError( format( 'null3c', reducer ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tacc = initialValue;\n\t\ti = len - 1;\n\t} else {\n\t\tif ( len === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' );\n\t\t}\n\t\tacc = fromWord( buf[ len-1 ] );\n\t\ti = len - 2;\n\t}\n\tfor ( ; i >= 0; i-- ) {\n\t\tacc = reducer( acc, fromWord( buf[ i ] ), i, this );\n\t}\n\treturn acc;\n});\n\n/**\n* Reverses an array in-place.\n*\n* @name reverse\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Float16Array} reversed array\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var out = arr.reverse();\n* // returns \n*\n* var v = out[ 0 ];\n* // returns 2.0\n*\n* v = out[ 1 ];\n* // returns 1.0\n*\n* v = out[ 2 ];\n* // returns 0.0\n*/\nsetReadOnly( Float16Array.prototype, 'reverse', function reverse() {\n\tvar buf;\n\tvar tmp;\n\tvar len;\n\tvar N;\n\tvar i;\n\tvar j;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tN = floor( len / 2 );\n\tfor ( i = 0; i < N; i++ ) {\n\t\tj = len - i - 1;\n\t\ttmp = buf[ i ];\n\t\tbuf[ i ] = buf[ j ];\n\t\tbuf[ j ] = tmp;\n\t}\n\treturn this;\n});\n\n/**\n* Sets one or more array elements.\n*\n* ## Notes\n*\n* - When provided a typed array, we must check whether the source array shares the same buffer as the target array and whether the underlying memory overlaps. In particular, we are concerned with the following scenario:\n*\n* ```text\n* buf: ---------------------\n* src: ---------------------\n* ```\n*\n* In the above, as we copy values from `src`, we will overwrite values in the `src` view, resulting in duplicated values copied into the end of `buf`, which is not intended. Hence, to avoid overwriting source values, we must **copy** source values to a temporary array.\n*\n* In the other overlapping scenario,\n*\n* ```text\n* buf: ---------------------\n* src: ---------------------\n* ```\n*\n* by the time we begin copying into the overlapping region, we are copying from the end of `src`, a non-overlapping region, which means we don't run the risk of copying copied values, rather than the original `src` values, as intended.\n*\n* @name set\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {(Collection|Float16Array)} value - value(s)\n* @param {NonNegativeInteger} [i=0] - element index at which to start writing values\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a collection\n* @throws {TypeError} index argument must be a nonnegative integer\n* @throws {RangeError} index argument is out-of-bounds\n* @throws {RangeError} target array lacks sufficient storage to accommodate source values\n* @returns {void}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var v = arr[ 0 ];\n* // returns 0.0\n*\n* arr.set( [ 1.0, 2.0 ], 0 );\n*\n* v = arr[ 0 ];\n* // returns 1.0\n*/\nsetReadOnly( Float16Array.prototype, 'set', function set( value ) {\n\tvar sbuf;\n\tvar idx;\n\tvar buf;\n\tvar tmp;\n\tvar flg;\n\tvar N;\n\tvar i;\n\tvar j;\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isCollection( value ) ) {\n\t\tthrow new TypeError( format( 'null2O', value ) );\n\t}\n\tbuf = this._buffer;\n\tif ( arguments.length > 1 ) {\n\t\tidx = arguments[ 1 ];\n\t\tif ( !isNonNegativeInteger( idx ) ) {\n\t\t\tthrow new TypeError( format( 'null2L', idx ) );\n\t\t}\n\t} else {\n\t\tidx = 0;\n\t}\n\tN = value.length;\n\tif ( idx+N > this._length ) {\n\t\tthrow new RangeError( format('null03') );\n\t}\n\tif ( isFloat16Array( value ) ) {\n\t\tsbuf = value._buffer; // eslint-disable-line no-underscore-dangle\n\t\tflg = true;\n\t} else {\n\t\tsbuf = value;\n\t\tflg = false;\n\t}\n\t// Check for overlapping memory...\n\tj = buf.byteOffset + (idx*BYTES_PER_ELEMENT);\n\tif (\n\t\tsbuf.buffer === buf.buffer &&\n\t\t(\n\t\t\tsbuf.byteOffset < j &&\n\t\t\tsbuf.byteOffset+sbuf.byteLength > j\n\t\t)\n\t) {\n\t\t// We need to copy source values...\n\t\ttmp = new Uint16Array( sbuf.length );\n\t\tfor ( i = 0; i < sbuf.length; i++ ) {\n\t\t\ttmp[ i ] = sbuf[ i ];\n\t\t}\n\t\tsbuf = tmp;\n\t}\n\tif ( flg ) {\n\t\tfor ( i = 0; i < N; idx++, i++ ) {\n\t\t\tbuf[ idx ] = sbuf[ i ];\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < N; idx++, i++ ) {\n\t\t\tbuf[ idx ] = toWord( sbuf[ i ] );\n\t\t}\n\t}\n});\n\n/**\n* Copies a portion of a typed array to a new typed array.\n*\n* @name slice\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} [begin] - start index (inclusive)\n* @param {integer} [end] - end index (exclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be integer\n* @throws {TypeError} second argument must be integer\n* @returns {Float16Array} floating-point number array\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] );\n*\n* var out = arr.slice();\n* // returns \n*\n* var len = out.length;\n* // returns 5\n*\n* var v = out[ 0 ];\n* // returns 0.0\n*\n* v = out[ len-1 ];\n* // returns 4.0\n*\n* out = arr.slice( 1, -2 );\n* // returns \n*\n* len = out.length;\n* // returns 2\n*\n* v = out[ 0 ];\n* // returns 1.0\n*\n* v = out[ len-1 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'slice', function slice( begin, end ) {\n\tvar outlen;\n\tvar outbuf;\n\tvar out;\n\tvar buf;\n\tvar len;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length === 0 ) {\n\t\tbegin = 0;\n\t\tend = len;\n\t} else {\n\t\tif ( !isInteger( begin ) ) {\n\t\t\tthrow new TypeError( format( 'null7e', begin ) );\n\t\t}\n\t\tif ( begin < 0 ) {\n\t\t\tbegin += len;\n\t\t\tif ( begin < 0 ) {\n\t\t\t\tbegin = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\tend = len;\n\t\t} else {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'null7f', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t} else if ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t}\n\t}\n\tif ( begin < end ) {\n\t\toutlen = end - begin;\n\t} else {\n\t\toutlen = 0;\n\t}\n\tout = new this.constructor( outlen );\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < outlen; i++ ) {\n\t\toutbuf[ i ] = buf[ i+begin ];\n\t}\n\treturn out;\n});\n\n/**\n* Tests whether at least one element in an array passes a test implemented by a predicate function.\n*\n* @name some\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {boolean} boolean indicating whether at least one element passes a test\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var bool = arr.some( predicate );\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'some', function some( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( predicate.call( thisArg, fromWord( buf[ i ] ), i, this ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n});\n\n/**\n* Sorts an array in-place.\n*\n* @name sort\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} [compareFcn] - comparison function\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {Float16Array} sorted array\n*\n* @example\n* function compare( a, b ) {\n* if ( a < b ) {\n* return -1;\n* }\n* if ( a > b ) {\n* return 1;\n* }\n* return 0;\n* }\n*\n* var arr = new Float16Array( [ 1.0, 0.0, 2.0 ] );\n*\n* arr.sort( compare );\n*\n* var v = arr[ 0 ];\n* // returns 0.0\n*\n* v = arr[ 1 ];\n* // returns 1.0\n*\n* v = arr[ 2 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'sort', function sort( compareFcn ) {\n\tvar buf;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tif ( arguments.length === 0 ) {\n\t\tbuf.sort( defaultCompare );\n\t\treturn this;\n\t}\n\tif ( !isFunction( compareFcn ) ) {\n\t\tthrow new TypeError( format( 'null3c', compareFcn ) );\n\t}\n\tbuf.sort( compare );\n\treturn this;\n\n\t/**\n\t* Default comparison function for float16 values.\n\t*\n\t* @private\n\t* @param {unsigned16} a - unsigned 16-bit integer for comparison\n\t* @param {unsigned16} b - unsigned 16-bit integer for comparison\n\t* @returns {number} comparison result\n\t*/\n\tfunction defaultCompare( a, b ) { // eslint-disable-line stdlib/no-unnecessary-nested-functions\n\t\tvar x = fromWord( a );\n\t\tvar y = fromWord( b );\n\n\t\t// Handle NaN...\n\t\tif ( isnan( x ) && isnan( y ) ) {\n\t\t\treturn 0;\n\t\t}\n\t\tif ( isnan( x ) ) {\n\t\t\treturn 1;\n\t\t}\n\t\tif ( isnan( y ) ) {\n\t\t\treturn -1;\n\t\t}\n\t\t// Normal comparison\n\t\tif ( x < y ) {\n\t\t\treturn -1;\n\t\t}\n\t\tif ( x > y ) {\n\t\t\treturn 1;\n\t\t}\n\t\treturn 0;\n\t}\n\n\t/**\n\t* Comparison function wrapper.\n\t*\n\t* @private\n\t* @param {unsigned16} a - unsigned 16-bit integer for comparison\n\t* @param {unsigned16} b - unsigned 16-bit integer for comparison\n\t* @returns {number} comparison result\n\t*/\n\tfunction compare( a, b ) {\n\t\treturn compareFcn( fromWord( a ), fromWord( b ) );\n\t}\n});\n\n/**\n* Creates a new typed array view over the same underlying `ArrayBuffer` and with the same underlying data type as the host array.\n*\n* @name subarray\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} [begin] - start index (inclusive)\n* @param {integer} [end] - end index (exclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be an integer\n* @throws {TypeError} second argument must be an integer\n* @returns {Float16Array} subarray\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] );\n*\n* var subarr = arr.subarray();\n* // returns \n*\n* var len = subarr.length;\n* // returns 5\n*\n* var bool = subarr[ 0 ];\n* // returns 0.0\n*\n* bool = subarr[ len-1 ];\n* // returns 4.0\n*\n* subarr = arr.subarray( 1, -2 );\n* // returns \n*\n* len = subarr.length;\n* // returns 2\n*\n* bool = subarr[ 0 ];\n* // returns 1.0\n*\n* bool = subarr[ len-1 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'subarray', function subarray( begin, end ) {\n\tvar offset;\n\tvar buf;\n\tvar len;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length === 0 ) {\n\t\tbegin = 0;\n\t\tend = len;\n\t} else {\n\t\tif ( !isInteger( begin ) ) {\n\t\t\tthrow new TypeError( format( 'null7e', begin ) );\n\t\t}\n\t\tif ( begin < 0 ) {\n\t\t\tbegin += len;\n\t\t\tif ( begin < 0 ) {\n\t\t\t\tbegin = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\tend = len;\n\t\t} else {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'null7f', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t} else if ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t}\n\t}\n\tif ( begin >= len ) {\n\t\tlen = 0;\n\t\toffset = buf.byteLength;\n\t} else if ( begin >= end ) {\n\t\tlen = 0;\n\t\toffset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT );\n\t} else {\n\t\tlen = end - begin;\n\t\toffset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT );\n\t}\n\treturn new this.constructor( buf.buffer, offset, ( len < 0 ) ? 0 : len );\n});\n\n/**\n* Serializes an array as a locale-specific string.\n*\n* @name toLocaleString\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {(string|Array)} [locales] - locale identifier(s)\n* @param {Object} [options] - configuration options\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a string or an array of strings\n* @throws {TypeError} options argument must be an object\n* @returns {string} string representation\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var str = arr.toLocaleString();\n* // returns '0,1,2'\n*/\nsetReadOnly( Float16Array.prototype, 'toLocaleString', function toLocaleString( locales, options ) {\n\tvar opts;\n\tvar loc;\n\tvar out;\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( arguments.length === 0 ) {\n\t\tloc = [];\n\t} else if ( isString( locales ) || isStringArray( locales ) ) {\n\t\tloc = locales;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a string or an array of strings. Value: `%s`.', locales ) );\n\t}\n\tif ( arguments.length < 2 ) {\n\t\topts = {};\n\t} else if ( isObject( options ) ) {\n\t\topts = options;\n\t} else {\n\t\tthrow new TypeError( format( 'null2V', options ) );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( fromWord( buf[ i ] ) );\n\t}\n\treturn out.toLocaleString( loc, opts );\n});\n\n/**\n* Returns a new typed array containing the elements in reversed order.\n*\n* @name toReversed\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Float16Array} reversed array\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var out = arr.toReversed();\n* // returns \n*\n* var v = out[ 0 ];\n* // returns 2.0\n*\n* v = out[ 1 ];\n* // returns 1.0\n*\n* v = out[ 2 ];\n* // returns 0.0\n*/\nsetReadOnly( Float16Array.prototype, 'toReversed', function toReversed() {\n\tvar outbuf;\n\tvar out;\n\tvar len;\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tlen = this._length;\n\tout = new this.constructor( len );\n\tbuf = this._buffer;\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < len; i++ ) {\n\t\toutbuf[ i ] = buf[ len - i - 1 ];\n\t}\n\treturn out;\n});\n\n/**\n* Returns a new typed array containing the elements in sorted order.\n*\n* @name toSorted\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} [compareFcn] - comparison function\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {Float16Array} sorted array\n*\n* @example\n* function compare( a, b ) {\n* if ( a > b ) {\n* return 1;\n* }\n* if ( a < b ) {\n* return -1;\n* }\n* return 0;\n* }\n*\n* var arr = new Float16Array( [ 2.0, 0.0, 1.0 ] );\n*\n* var out = arr.toSorted( compare );\n* // returns \n*\n* var v = out[ 0 ];\n* // returns 0.0\n*\n* v = out[ 1 ];\n* // returns 1.0\n*\n* v = out[ 2 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'toSorted', function toSorted( compareFcn ) {\n\tvar out;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tout = new this.constructor( this );\n\tif ( arguments.length === 0 ) {\n\t\treturn out.sort();\n\t}\n\treturn out.sort( compareFcn );\n});\n\n/**\n* Serializes an array as a string.\n*\n* @name toString\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {string} string representation\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var str = arr.toString();\n* // returns '0,1,2'\n*/\nsetReadOnly( Float16Array.prototype, 'toString', function toString() {\n\tvar out;\n\tvar buf;\n\tvar i;\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( fromWord( buf[ i ] ) );\n\t}\n\treturn out.join( ',' );\n});\n\n/**\n* Returns an iterator for iterating over each value in a typed array.\n*\n* @name values\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0 ] );\n*\n* var iter = arr.values();\n*\n* var v = iter.next().value;\n* // returns 0.0\n*\n* v = iter.next().value;\n* // returns 1.0\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'values', function values() {\n\tvar iter;\n\tvar self;\n\tvar len;\n\tvar FLG;\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tself = this;\n\tbuf = this._buffer;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': fromWord( buf[ i ] ),\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.values();\n\t}\n});\n\n/**\n* Returns a new typed array with the element at a provided index replaced with a provided value.\n*\n* @name with\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} index - element index\n* @param {number} value - new value\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be an integer\n* @throws {RangeError} index argument is out-of-bounds\n* @throws {TypeError} second argument must be a floating-point number\n* @returns {Float16Array} new typed array\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var out = arr.with( 0, 3.0 );\n* // returns \n*\n* var v = out[ 0 ];\n* // returns 3.0\n*/\nsetReadOnly( Float16Array.prototype, 'with', function copyWith( index, value ) {\n\tvar out;\n\tvar len;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isInteger( index ) ) {\n\t\tthrow new TypeError( format( 'null7e', index ) );\n\t}\n\tlen = this._length;\n\tif ( index < 0 ) {\n\t\tindex += len;\n\t}\n\tif ( index < 0 || index >= len ) {\n\t\tthrow new RangeError( format( 'nullFP', index ) );\n\t}\n\tif ( !isNumber( value ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a floating-point number. Value: `%s`.', value ) );\n\t}\n\tout = new this.constructor( this );\n\tout[ index ] = value;\n\treturn out;\n});\n\n\n// EXPORTS //\n\nexport default Float16Array;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport f16 from '@stdlib/number-float64-base-to-float16';\nimport toWord from '@stdlib/number-float16-base-to-word';\n\n\n// MAIN //\n\n/**\n* Fills an output array with unsigned 16-bit integers corresponding to the IEEE 754 binary representation of respective half-precision floating-point numbers.\n*\n* @private\n* @param {Uint16Array} buf - output array\n* @param {Array} arr - input array\n* @returns {Uint16Array} output array\n*/\nfunction fromArray( buf, arr ) {\n\tvar len;\n\tvar i;\n\n\tlen = arr.length;\n\tfor ( i = 0; i < len; i++ ) {\n\t\tbuf[ i ] = toWord( f16( arr[ i ] ) );\n\t}\n\treturn buf;\n}\n\n\n// EXPORTS //\n\nexport default fromArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport f16 from '@stdlib/number-float64-base-to-float16';\nimport toWord from '@stdlib/number-float16-base-to-word';\n\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @param {Function} clbk - callback to invoke for each iterated value\n* @param {*} thisArg - invocation context\n* @returns {Array} output array\n*/\nfunction fromIteratorMap( it, clbk, thisArg ) {\n\tvar out;\n\tvar v;\n\tvar i;\n\n\tout = [];\n\ti = -1;\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\ti += 1;\n\t\tout.push( toWord( f16( clbk.call( thisArg, v.value, i ) ) ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIteratorMap;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Float16Array === 'function' ) ? Float16Array : void 0; // eslint-disable-line no-undef, stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* 16-bit floating-point number array constructor.\n*\n* @module @stdlib/array-float16\n*\n* @example\n* import Float16Array from '@stdlib/array-float16';\n*\n* var arr = new Float16Array();\n* // returns \n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* import Float16Array from '@stdlib/array-float16';\n*\n* var arr = new Float16Array( 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import Float16Array from '@stdlib/array-float16';\n*\n* var arr = new Float16Array( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n* import Float16Array from '@stdlib/array-float16';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float16Array( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 8\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n* import Float16Array from '@stdlib/array-float16';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float16Array( buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 4\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n* import Float16Array from '@stdlib/array-float16';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Float16Array( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\n\n// MODULES //\n\nimport hasFloat16ArraySupport from '@stdlib/assert-has-float16array-support';\nimport polyfill from './polyfill';\nimport builtin from './main.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasFloat16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n"],"names":["fromIterator","it","out","v","next","done","push","toWord","f16","value","BYTES_PER_ELEMENT","Uint16Array","HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","isFloat16Array","constructor","name","isFloatingPointArrayConstructor","Float16Array","getter","ctx","idx","_get","setter","set","byteOffset","nargs","buf","len","arg","i","arguments","length","this","isNonNegativeInteger","isCollection","gcopy","ndarray","buffer","arr","fromArray","isArrayBuffer","isInteger","byteLength","RangeError","format","isObject","TypeError","isFunction","ITERATOR_SYMBOL","setReadOnly","setReadWriteAccessor","src","thisArg","clbk","tmp","_buffer","call","fromIteratorMap","Error","args","prototype","_length","fromWord","setReadOnlyAccessor","target","start","copyWithin","self","iter","FLG","entries","predicate","end","isNumber","fcn","searchElement","fromIndex","separator","isString","join","keys","outbuf","reducer","initialValue","acc","N","j","floor","sbuf","flg","begin","outlen","compareFcn","sort","a","b","x","y","isnan","offset","locales","options","opts","loc","isStringArray","toLocaleString","values","index","ctor","ctor$1","hasFloat16ArraySupport","builtin","polyfill"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 41ab3bb..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 84605a719b3be7f50774711ab55a681512b7ab25 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 14 May 2026 03:58:48 +0000 Subject: [PATCH 08/14] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 204 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 52 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 49 +- SECURITY.md | 5 - benchmark/benchmark.at.js | 79 - benchmark/benchmark.copy_within.js | 52 - benchmark/benchmark.copy_within.length.js | 95 - benchmark/benchmark.entries.js | 52 - benchmark/benchmark.every.js | 83 - benchmark/benchmark.every.length.js | 107 - benchmark/benchmark.fill.js | 53 - benchmark/benchmark.fill.length.js | 97 - benchmark/benchmark.filter.js | 82 - benchmark/benchmark.filter.length.js | 106 - benchmark/benchmark.find.js | 84 - benchmark/benchmark.find.length.js | 106 - benchmark/benchmark.find_index.js | 84 - benchmark/benchmark.find_index.length.js | 106 - benchmark/benchmark.find_last.js | 84 - benchmark/benchmark.find_last.length.js | 106 - benchmark/benchmark.find_last_index.js | 84 - benchmark/benchmark.find_last_index.length.js | 110 - benchmark/benchmark.for_each.js | 90 - benchmark/benchmark.for_each.length.js | 108 - benchmark/benchmark.from.js | 238 - benchmark/benchmark.get.js | 55 - benchmark/benchmark.includes.js | 54 - benchmark/benchmark.includes.length.js | 97 - benchmark/benchmark.index_of.js | 54 - benchmark/benchmark.index_of.length.js | 96 - benchmark/benchmark.join.js | 53 - benchmark/benchmark.join.length.js | 96 - benchmark/benchmark.js | 338 -- benchmark/benchmark.keys.js | 52 - benchmark/benchmark.keys.length.js | 96 - benchmark/benchmark.last_index_of.js | 53 - benchmark/benchmark.last_index_of.length.js | 95 - benchmark/benchmark.length.js | 93 - benchmark/benchmark.map.js | 82 - benchmark/benchmark.map.length.js | 106 - benchmark/benchmark.of.js | 48 - benchmark/benchmark.reduce.js | 82 - benchmark/benchmark.reduce.length.js | 107 - benchmark/benchmark.reduce_right.js | 82 - benchmark/benchmark.reduce_right.length.js | 107 - benchmark/benchmark.reverse.js | 53 - benchmark/benchmark.reverse.length.js | 96 - benchmark/benchmark.set.js | 95 - benchmark/benchmark.set.length.js | 110 - benchmark/benchmark.slice.js | 53 - benchmark/benchmark.slice.length.js | 96 - benchmark/benchmark.some.js | 83 - benchmark/benchmark.some.length.js | 107 - benchmark/benchmark.sort.js | 53 - benchmark/benchmark.sort.length.js | 96 - benchmark/benchmark.subarray.js | 52 - benchmark/benchmark.subarray.length.js | 95 - benchmark/benchmark.to_locale_string.js | 53 - .../benchmark.to_locale_string.length.js | 96 - benchmark/benchmark.to_reversed.js | 52 - benchmark/benchmark.to_reversed.length.js | 95 - benchmark/benchmark.to_sorted.js | 53 - benchmark/benchmark.to_sorted.length.js | 96 - benchmark/benchmark.to_string.js | 53 - benchmark/benchmark.to_string.length.js | 96 - benchmark/benchmark.values.js | 52 - benchmark/benchmark.values.length.js | 96 - benchmark/benchmark.with.js | 54 - benchmark/benchmark.with.length.js | 98 - benchmark/polyfill/benchmark.at.js | 79 - benchmark/polyfill/benchmark.copy_within.js | 52 - .../polyfill/benchmark.copy_within.length.js | 95 - benchmark/polyfill/benchmark.entries.js | 52 - benchmark/polyfill/benchmark.every.js | 83 - benchmark/polyfill/benchmark.every.length.js | 107 - benchmark/polyfill/benchmark.fill.js | 53 - benchmark/polyfill/benchmark.fill.length.js | 97 - benchmark/polyfill/benchmark.filter.js | 82 - benchmark/polyfill/benchmark.filter.length.js | 106 - benchmark/polyfill/benchmark.find.js | 84 - benchmark/polyfill/benchmark.find.length.js | 106 - benchmark/polyfill/benchmark.find_index.js | 84 - .../polyfill/benchmark.find_index.length.js | 106 - benchmark/polyfill/benchmark.find_last.js | 84 - .../polyfill/benchmark.find_last.length.js | 106 - .../polyfill/benchmark.find_last_index.js | 84 - .../benchmark.find_last_index.length.js | 110 - benchmark/polyfill/benchmark.for_each.js | 90 - .../polyfill/benchmark.for_each.length.js | 108 - benchmark/polyfill/benchmark.from.js | 238 - benchmark/polyfill/benchmark.get.js | 55 - benchmark/polyfill/benchmark.includes.js | 54 - .../polyfill/benchmark.includes.length.js | 97 - benchmark/polyfill/benchmark.index_of.js | 54 - .../polyfill/benchmark.index_of.length.js | 96 - benchmark/polyfill/benchmark.join.js | 53 - benchmark/polyfill/benchmark.join.length.js | 96 - benchmark/polyfill/benchmark.js | 338 -- benchmark/polyfill/benchmark.keys.js | 52 - benchmark/polyfill/benchmark.keys.length.js | 96 - benchmark/polyfill/benchmark.last_index_of.js | 53 - .../benchmark.last_index_of.length.js | 95 - benchmark/polyfill/benchmark.length.js | 93 - benchmark/polyfill/benchmark.map.js | 82 - benchmark/polyfill/benchmark.map.length.js | 106 - benchmark/polyfill/benchmark.of.js | 48 - benchmark/polyfill/benchmark.reduce.js | 82 - benchmark/polyfill/benchmark.reduce.length.js | 107 - benchmark/polyfill/benchmark.reduce_right.js | 82 - .../polyfill/benchmark.reduce_right.length.js | 107 - benchmark/polyfill/benchmark.reverse.js | 53 - .../polyfill/benchmark.reverse.length.js | 96 - benchmark/polyfill/benchmark.set.js | 95 - benchmark/polyfill/benchmark.set.length.js | 110 - benchmark/polyfill/benchmark.slice.js | 53 - benchmark/polyfill/benchmark.slice.length.js | 96 - benchmark/polyfill/benchmark.some.js | 83 - benchmark/polyfill/benchmark.some.length.js | 107 - benchmark/polyfill/benchmark.sort.js | 53 - benchmark/polyfill/benchmark.sort.length.js | 96 - benchmark/polyfill/benchmark.subarray.js | 52 - .../polyfill/benchmark.subarray.length.js | 95 - .../polyfill/benchmark.to_locale_string.js | 53 - .../benchmark.to_locale_string.length.js | 96 - benchmark/polyfill/benchmark.to_reversed.js | 52 - .../polyfill/benchmark.to_reversed.length.js | 95 - benchmark/polyfill/benchmark.to_sorted.js | 53 - .../polyfill/benchmark.to_sorted.length.js | 96 - benchmark/polyfill/benchmark.to_string.js | 53 - .../polyfill/benchmark.to_string.length.js | 96 - benchmark/polyfill/benchmark.values.js | 52 - benchmark/polyfill/benchmark.values.length.js | 96 - benchmark/polyfill/benchmark.with.js | 54 - benchmark/polyfill/benchmark.with.length.js | 98 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 1222 ----- docs/types/test.ts | 129 - examples/index.js | 42 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 106 - lib/main.js | 28 - lib/polyfill/from_array.js | 51 - lib/polyfill/from_iterator.js | 54 - lib/polyfill/from_iterator_map.js | 59 - lib/polyfill/index.js | 2410 -------- package.json | 86 +- stats.html | 4842 +++++++++++++++++ test/dist/test.js | 33 - test/polyfill/test.at.js | 144 - test/polyfill/test.copy_within.js | 281 - test/polyfill/test.entries.js | 238 - test/polyfill/test.every.js | 174 - test/polyfill/test.fill.js | 305 -- test/polyfill/test.filter.js | 226 - test/polyfill/test.find.js | 174 - test/polyfill/test.find_index.js | 173 - test/polyfill/test.find_last.js | 174 - test/polyfill/test.find_last_index.js | 173 - test/polyfill/test.for_each.js | 196 - test/polyfill/test.from.js | 654 --- test/polyfill/test.includes.js | 222 - test/polyfill/test.index_of.js | 222 - test/polyfill/test.join.js | 173 - test/polyfill/test.js | 740 --- test/polyfill/test.keys.js | 261 - test/polyfill/test.last_index_of.js | 211 - test/polyfill/test.map.js | 178 - test/polyfill/test.of.js | 130 - test/polyfill/test.reduce.js | 189 - test/polyfill/test.reduce_right.js | 192 - test/polyfill/test.reverse.js | 122 - test/polyfill/test.set.js | 259 - test/polyfill/test.slice.js | 311 -- test/polyfill/test.some.js | 196 - test/polyfill/test.sort.js | 189 - test/polyfill/test.subarray.js | 308 -- test/polyfill/test.to_locale_string.js | 187 - test/polyfill/test.to_reversed.js | 121 - test/polyfill/test.to_sorted.js | 172 - test/polyfill/test.to_string.js | 97 - test/polyfill/test.values.js | 264 - test/polyfill/test.with.js | 213 - test/test.at.js | 111 - test/test.copy_within.js | 279 - test/test.entries.js | 96 - test/test.every.js | 172 - test/test.fill.js | 212 - test/test.filter.js | 224 - test/test.find.js | 172 - test/test.find_index.js | 171 - test/test.find_last.js | 172 - test/test.find_last_index.js | 171 - test/test.for_each.js | 194 - test/test.from.js | 309 -- test/test.includes.js | 160 - test/test.index_of.js | 160 - test/test.join.js | 141 - test/test.js | 320 -- test/test.keys.js | 144 - test/test.last_index_of.js | 149 - test/test.map.js | 176 - test/test.of.js | 128 - test/test.polyfill.js | 80 - test/test.reduce.js | 187 - test/test.reduce_right.js | 190 - test/test.reverse.js | 120 - test/test.set.js | 225 - test/test.slice.js | 249 - test/test.some.js | 194 - test/test.sort.js | 186 - test/test.subarray.js | 246 - test/test.to_locale_string.js | 95 - test/test.to_reversed.js | 119 - test/test.to_sorted.js | 169 - test/test.to_string.js | 87 - test/test.values.js | 147 - test/test.with.js | 151 - 245 files changed, 4870 insertions(+), 33233 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.at.js delete mode 100644 benchmark/benchmark.copy_within.js delete mode 100644 benchmark/benchmark.copy_within.length.js delete mode 100644 benchmark/benchmark.entries.js delete mode 100644 benchmark/benchmark.every.js delete mode 100644 benchmark/benchmark.every.length.js delete mode 100644 benchmark/benchmark.fill.js delete mode 100644 benchmark/benchmark.fill.length.js delete mode 100644 benchmark/benchmark.filter.js delete mode 100644 benchmark/benchmark.filter.length.js delete mode 100644 benchmark/benchmark.find.js delete mode 100644 benchmark/benchmark.find.length.js delete mode 100644 benchmark/benchmark.find_index.js delete mode 100644 benchmark/benchmark.find_index.length.js delete mode 100644 benchmark/benchmark.find_last.js delete mode 100644 benchmark/benchmark.find_last.length.js delete mode 100644 benchmark/benchmark.find_last_index.js delete mode 100644 benchmark/benchmark.find_last_index.length.js delete mode 100644 benchmark/benchmark.for_each.js delete mode 100644 benchmark/benchmark.for_each.length.js delete mode 100644 benchmark/benchmark.from.js delete mode 100644 benchmark/benchmark.get.js delete mode 100644 benchmark/benchmark.includes.js delete mode 100644 benchmark/benchmark.includes.length.js delete mode 100644 benchmark/benchmark.index_of.js delete mode 100644 benchmark/benchmark.index_of.length.js delete mode 100644 benchmark/benchmark.join.js delete mode 100644 benchmark/benchmark.join.length.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.keys.js delete mode 100644 benchmark/benchmark.keys.length.js delete mode 100644 benchmark/benchmark.last_index_of.js delete mode 100644 benchmark/benchmark.last_index_of.length.js delete mode 100644 benchmark/benchmark.length.js delete mode 100644 benchmark/benchmark.map.js delete mode 100644 benchmark/benchmark.map.length.js delete mode 100644 benchmark/benchmark.of.js delete mode 100644 benchmark/benchmark.reduce.js delete mode 100644 benchmark/benchmark.reduce.length.js delete mode 100644 benchmark/benchmark.reduce_right.js delete mode 100644 benchmark/benchmark.reduce_right.length.js delete mode 100644 benchmark/benchmark.reverse.js delete mode 100644 benchmark/benchmark.reverse.length.js delete mode 100644 benchmark/benchmark.set.js delete mode 100644 benchmark/benchmark.set.length.js delete mode 100644 benchmark/benchmark.slice.js delete mode 100644 benchmark/benchmark.slice.length.js delete mode 100644 benchmark/benchmark.some.js delete mode 100644 benchmark/benchmark.some.length.js delete mode 100644 benchmark/benchmark.sort.js delete mode 100644 benchmark/benchmark.sort.length.js delete mode 100644 benchmark/benchmark.subarray.js delete mode 100644 benchmark/benchmark.subarray.length.js delete mode 100644 benchmark/benchmark.to_locale_string.js delete mode 100644 benchmark/benchmark.to_locale_string.length.js delete mode 100644 benchmark/benchmark.to_reversed.js delete mode 100644 benchmark/benchmark.to_reversed.length.js delete mode 100644 benchmark/benchmark.to_sorted.js delete mode 100644 benchmark/benchmark.to_sorted.length.js delete mode 100644 benchmark/benchmark.to_string.js delete mode 100644 benchmark/benchmark.to_string.length.js delete mode 100644 benchmark/benchmark.values.js delete mode 100644 benchmark/benchmark.values.length.js delete mode 100644 benchmark/benchmark.with.js delete mode 100644 benchmark/benchmark.with.length.js delete mode 100644 benchmark/polyfill/benchmark.at.js delete mode 100644 benchmark/polyfill/benchmark.copy_within.js delete mode 100644 benchmark/polyfill/benchmark.copy_within.length.js delete mode 100644 benchmark/polyfill/benchmark.entries.js delete mode 100644 benchmark/polyfill/benchmark.every.js delete mode 100644 benchmark/polyfill/benchmark.every.length.js delete mode 100644 benchmark/polyfill/benchmark.fill.js delete mode 100644 benchmark/polyfill/benchmark.fill.length.js delete mode 100644 benchmark/polyfill/benchmark.filter.js delete mode 100644 benchmark/polyfill/benchmark.filter.length.js delete mode 100644 benchmark/polyfill/benchmark.find.js delete mode 100644 benchmark/polyfill/benchmark.find.length.js delete mode 100644 benchmark/polyfill/benchmark.find_index.js delete mode 100644 benchmark/polyfill/benchmark.find_index.length.js delete mode 100644 benchmark/polyfill/benchmark.find_last.js delete mode 100644 benchmark/polyfill/benchmark.find_last.length.js delete mode 100644 benchmark/polyfill/benchmark.find_last_index.js delete mode 100644 benchmark/polyfill/benchmark.find_last_index.length.js delete mode 100644 benchmark/polyfill/benchmark.for_each.js delete mode 100644 benchmark/polyfill/benchmark.for_each.length.js delete mode 100644 benchmark/polyfill/benchmark.from.js delete mode 100644 benchmark/polyfill/benchmark.get.js delete mode 100644 benchmark/polyfill/benchmark.includes.js delete mode 100644 benchmark/polyfill/benchmark.includes.length.js delete mode 100644 benchmark/polyfill/benchmark.index_of.js delete mode 100644 benchmark/polyfill/benchmark.index_of.length.js delete mode 100644 benchmark/polyfill/benchmark.join.js delete mode 100644 benchmark/polyfill/benchmark.join.length.js delete mode 100644 benchmark/polyfill/benchmark.js delete mode 100644 benchmark/polyfill/benchmark.keys.js delete mode 100644 benchmark/polyfill/benchmark.keys.length.js delete mode 100644 benchmark/polyfill/benchmark.last_index_of.js delete mode 100644 benchmark/polyfill/benchmark.last_index_of.length.js delete mode 100644 benchmark/polyfill/benchmark.length.js delete mode 100644 benchmark/polyfill/benchmark.map.js delete mode 100644 benchmark/polyfill/benchmark.map.length.js delete mode 100644 benchmark/polyfill/benchmark.of.js delete mode 100644 benchmark/polyfill/benchmark.reduce.js delete mode 100644 benchmark/polyfill/benchmark.reduce.length.js delete mode 100644 benchmark/polyfill/benchmark.reduce_right.js delete mode 100644 benchmark/polyfill/benchmark.reduce_right.length.js delete mode 100644 benchmark/polyfill/benchmark.reverse.js delete mode 100644 benchmark/polyfill/benchmark.reverse.length.js delete mode 100644 benchmark/polyfill/benchmark.set.js delete mode 100644 benchmark/polyfill/benchmark.set.length.js delete mode 100644 benchmark/polyfill/benchmark.slice.js delete mode 100644 benchmark/polyfill/benchmark.slice.length.js delete mode 100644 benchmark/polyfill/benchmark.some.js delete mode 100644 benchmark/polyfill/benchmark.some.length.js delete mode 100644 benchmark/polyfill/benchmark.sort.js delete mode 100644 benchmark/polyfill/benchmark.sort.length.js delete mode 100644 benchmark/polyfill/benchmark.subarray.js delete mode 100644 benchmark/polyfill/benchmark.subarray.length.js delete mode 100644 benchmark/polyfill/benchmark.to_locale_string.js delete mode 100644 benchmark/polyfill/benchmark.to_locale_string.length.js delete mode 100644 benchmark/polyfill/benchmark.to_reversed.js delete mode 100644 benchmark/polyfill/benchmark.to_reversed.length.js delete mode 100644 benchmark/polyfill/benchmark.to_sorted.js delete mode 100644 benchmark/polyfill/benchmark.to_sorted.length.js delete mode 100644 benchmark/polyfill/benchmark.to_string.js delete mode 100644 benchmark/polyfill/benchmark.to_string.length.js delete mode 100644 benchmark/polyfill/benchmark.values.js delete mode 100644 benchmark/polyfill/benchmark.values.length.js delete mode 100644 benchmark/polyfill/benchmark.with.js delete mode 100644 benchmark/polyfill/benchmark.with.length.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill/from_array.js delete mode 100644 lib/polyfill/from_iterator.js delete mode 100644 lib/polyfill/from_iterator_map.js delete mode 100644 lib/polyfill/index.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/polyfill/test.at.js delete mode 100644 test/polyfill/test.copy_within.js delete mode 100644 test/polyfill/test.entries.js delete mode 100644 test/polyfill/test.every.js delete mode 100644 test/polyfill/test.fill.js delete mode 100644 test/polyfill/test.filter.js delete mode 100644 test/polyfill/test.find.js delete mode 100644 test/polyfill/test.find_index.js delete mode 100644 test/polyfill/test.find_last.js delete mode 100644 test/polyfill/test.find_last_index.js delete mode 100644 test/polyfill/test.for_each.js delete mode 100644 test/polyfill/test.from.js delete mode 100644 test/polyfill/test.includes.js delete mode 100644 test/polyfill/test.index_of.js delete mode 100644 test/polyfill/test.join.js delete mode 100644 test/polyfill/test.js delete mode 100644 test/polyfill/test.keys.js delete mode 100644 test/polyfill/test.last_index_of.js delete mode 100644 test/polyfill/test.map.js delete mode 100644 test/polyfill/test.of.js delete mode 100644 test/polyfill/test.reduce.js delete mode 100644 test/polyfill/test.reduce_right.js delete mode 100644 test/polyfill/test.reverse.js delete mode 100644 test/polyfill/test.set.js delete mode 100644 test/polyfill/test.slice.js delete mode 100644 test/polyfill/test.some.js delete mode 100644 test/polyfill/test.sort.js delete mode 100644 test/polyfill/test.subarray.js delete mode 100644 test/polyfill/test.to_locale_string.js delete mode 100644 test/polyfill/test.to_reversed.js delete mode 100644 test/polyfill/test.to_sorted.js delete mode 100644 test/polyfill/test.to_string.js delete mode 100644 test/polyfill/test.values.js delete mode 100644 test/polyfill/test.with.js delete mode 100644 test/test.at.js delete mode 100644 test/test.copy_within.js delete mode 100644 test/test.entries.js delete mode 100644 test/test.every.js delete mode 100644 test/test.fill.js delete mode 100644 test/test.filter.js delete mode 100644 test/test.find.js delete mode 100644 test/test.find_index.js delete mode 100644 test/test.find_last.js delete mode 100644 test/test.find_last_index.js delete mode 100644 test/test.for_each.js delete mode 100644 test/test.from.js delete mode 100644 test/test.includes.js delete mode 100644 test/test.index_of.js delete mode 100644 test/test.join.js delete mode 100644 test/test.js delete mode 100644 test/test.keys.js delete mode 100644 test/test.last_index_of.js delete mode 100644 test/test.map.js delete mode 100644 test/test.of.js delete mode 100644 test/test.polyfill.js delete mode 100644 test/test.reduce.js delete mode 100644 test/test.reduce_right.js delete mode 100644 test/test.reverse.js delete mode 100644 test/test.set.js delete mode 100644 test/test.slice.js delete mode 100644 test/test.some.js delete mode 100644 test/test.sort.js delete mode 100644 test/test.subarray.js delete mode 100644 test/test.to_locale_string.js delete mode 100644 test/test.to_reversed.js delete mode 100644 test/test.to_sorted.js delete mode 100644 test/test.to_string.js delete mode 100644 test/test.values.js delete mode 100644 test/test.with.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index fdc93ae..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-05-14T03:46:13.278Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index f756a5e..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/float16) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 44e2d76..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/float16) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 4584730..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '9 21 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -1587,7 +1578,7 @@ logEach( '%s', out ); ## Notice -This package is part of [stdlib][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. +This package is part of [stdlib][stdlib], a standard library 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][stdlib], see the main project [repository][stdlib]. @@ -1652,9 +1643,9 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. [mdn-iterator-protocol]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterator_protocol -[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed +[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed/tree/esm -[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer +[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.at.js b/benchmark/benchmark.at.js deleted file mode 100644 index 7068020..0000000 --- a/benchmark/benchmark.at.js +++ /dev/null @@ -1,79 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s::nonnegative_indices:at', pkg ), function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float16Array( uniform( 10, 0.0, 10.0 ) ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.at( i%N ); - if ( typeof v !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNumber( v ) ) { - b.fail( 'should return a number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::negative_indices:at', pkg ), function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float16Array( uniform( 10, 1.0, 10.0 ) ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.at( -(i%N)-1 ); - if ( typeof v !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNumber( v ) ) { - b.fail( 'should return a number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.copy_within.js b/benchmark/benchmark.copy_within.js deleted file mode 100644 index 2182e0d..0000000 --- a/benchmark/benchmark.copy_within.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:copyWithin', pkg ), function benchmark( b ) { - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.copy_within.length.js b/benchmark/benchmark.copy_within.length.js deleted file mode 100644 index 9c952bb..0000000 --- a/benchmark/benchmark.copy_within.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - 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( format( '%s:copyWithin:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.entries.js b/benchmark/benchmark.entries.js deleted file mode 100644 index ddef73f..0000000 --- a/benchmark/benchmark.entries.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:entries', pkg ), function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.every.js b/benchmark/benchmark.every.js deleted file mode 100644 index ec830e9..0000000 --- a/benchmark/benchmark.every.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:every', pkg ), function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0.0; - } -}); - -bench( format( '%s::this_context:every', pkg ), function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0.0; - } -}); diff --git a/benchmark/benchmark.every.length.js b/benchmark/benchmark.every.length.js deleted file mode 100644 index a0f3d94..0000000 --- a/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,107 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - 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( format( '%s:every:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.fill.js b/benchmark/benchmark.fill.js deleted file mode 100644 index 7b27d39..0000000 --- a/benchmark/benchmark.fill.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:fill', pkg ), function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = [ 1.0, 2.0, 3.0 ]; - arr = new Float16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.fill( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.fill.length.js b/benchmark/benchmark.fill.length.js deleted file mode 100644 index 612d1b9..0000000 --- a/benchmark/benchmark.fill.length.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var values; - var out; - var i; - - values = [ 1.0, 2.0, 3.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.fill( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s:fill:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.filter.js b/benchmark/benchmark.filter.js deleted file mode 100644 index 555ad11..0000000 --- a/benchmark/benchmark.filter.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:filter', pkg ), function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0.0; - } -}); - -bench( format( '%s::this_context:filter', pkg ), function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0.0; - } -}); diff --git a/benchmark/benchmark.filter.length.js b/benchmark/benchmark.filter.length.js deleted file mode 100644 index 89f5124..0000000 --- a/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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 = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:filter:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.find.js b/benchmark/benchmark.find.js deleted file mode 100644 index b15c9fa..0000000 --- a/benchmark/benchmark.find.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:find', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); - -bench( format( '%s::this_context:find', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); diff --git a/benchmark/benchmark.find.length.js b/benchmark/benchmark.find.length.js deleted file mode 100644 index 58997d9..0000000 --- a/benchmark/benchmark.find.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value < 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - 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( format( '%s:find:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.find_index.js b/benchmark/benchmark.find_index.js deleted file mode 100644 index 4491bb3..0000000 --- a/benchmark/benchmark.find_index.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:findIndex', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); - -bench( format( '%s::this_context:findIndex', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); diff --git a/benchmark/benchmark.find_index.length.js b/benchmark/benchmark.find_index.length.js deleted file mode 100644 index 4bed308..0000000 --- a/benchmark/benchmark.find_index.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value < 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - 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( format( '%s:findIndex:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.find_last.js b/benchmark/benchmark.find_last.js deleted file mode 100644 index e134fbb..0000000 --- a/benchmark/benchmark.find_last.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:findLast', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findLast( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); - -bench( format( '%s::this_context:findLast', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findLast( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); diff --git a/benchmark/benchmark.find_last.length.js b/benchmark/benchmark.find_last.length.js deleted file mode 100644 index 50aad42..0000000 --- a/benchmark/benchmark.find_last.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value < 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.findLast( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - 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( format( '%s:findLast:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.find_last_index.js b/benchmark/benchmark.find_last_index.js deleted file mode 100644 index 85217bd..0000000 --- a/benchmark/benchmark.find_last_index.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:findLastIndex', pkg ), function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findLastIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -bench( format( '%s::this_context:findLastIndex', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findLastIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); diff --git a/benchmark/benchmark.find_last_index.length.js b/benchmark/benchmark.find_last_index.length.js deleted file mode 100644 index 69468cd..0000000 --- a/benchmark/benchmark.find_last_index.length.js +++ /dev/null @@ -1,110 +0,0 @@ -/** - * @license Apache-2.0 -* -* Copyright (c) 2026 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. -*/ - -/* eslint-disable stdlib/jsdoc-typedef-typos */ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {boolean} value - array element -* @param {NonNegativeInteger} idx - array element index -* @param {Float16Array} arr - array instance -* @returns {boolean} boolean indicating whether a value passes a test -*/ -function predicate( value ) { - return value < 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.findLastIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - 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( format( '%s:findLastIndex:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.for_each.js b/benchmark/benchmark.for_each.js deleted file mode 100644 index af73bce..0000000 --- a/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:forEach', pkg ), function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( format( '%s::this_context:forEach', pkg ), function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/benchmark/benchmark.for_each.length.js b/benchmark/benchmark.for_each.length.js deleted file mode 100644 index 935da80..0000000 --- a/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// 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( format( '%s:forEach:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.from.js b/benchmark/benchmark.from.js deleted file mode 100644 index 2242134..0000000 --- a/benchmark/benchmark.from.js +++ /dev/null @@ -1,238 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( format( '%s::typed_array:from', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::typed_array,clbk:from', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1.0; - } -}); - -bench( format( '%s::array:from', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1.0, 2.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::array,clbk:from', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1.0, 2.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1.0; - } -}); - -bench( format( '%s::iterable:from', pkg ), opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0.0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( format( '%s::iterable,clbk:from:', pkg ), opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1.0, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1.0; - } -}); diff --git a/benchmark/benchmark.get.js b/benchmark/benchmark.get.js deleted file mode 100644 index 90788e1..0000000 --- a/benchmark/benchmark.get.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:get', pkg ), function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float16Array( uniform( 10, 0.0, 10.0 ) ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( typeof v !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNumber( v ) ) { - b.fail( 'should return a number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.includes.js b/benchmark/benchmark.includes.js deleted file mode 100644 index c24dcc3..0000000 --- a/benchmark/benchmark.includes.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:includes', pkg ), function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Float16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1.0; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.includes.length.js b/benchmark/benchmark.includes.length.js deleted file mode 100644 index db686a1..0000000 --- a/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1.0; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - 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( format( '%s:includes:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.index_of.js b/benchmark/benchmark.index_of.js deleted file mode 100644 index 222370c..0000000 --- a/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:indexOf', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.indexOf( 11.0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( out ) ) { - b.fail( 'should return an integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.index_of.length.js b/benchmark/benchmark.index_of.length.js deleted file mode 100644 index ca2c5ee..0000000 --- a/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.indexOf( 11.0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( out ) ) { - b.fail( 'should return an integer' ); - } - 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( format( '%s:indexOf:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.join.js b/benchmark/benchmark.join.js deleted file mode 100644 index ce25730..0000000 --- a/benchmark/benchmark.join.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:join', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.join.length.js b/benchmark/benchmark.join.length.js deleted file mode 100644 index 26092d0..0000000 --- a/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - 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( format( '%s:join:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 1d756ec..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,338 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( format( '%s::instantiation,new', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array(); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::instantiation,no_new', pkg ), function benchmark( b ) { - var ctor; - var arr; - var i; - - ctor = Float16Array; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = ctor(); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::instantiation,length', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::instantiation,typed_array', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::instantiation,array', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = []; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::instantiation,iterable', pkg ), opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( createIterable() ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - return { - 'done': true - }; - } - } -}); - -bench( format( '%s::instantiation,arraybuffer', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::instantiation,arraybuffer,byte_offset', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 8 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( buf, 8 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::instantiation,arraybuffer,byte_offset,length', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 8 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( buf, 8, 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::get:buffer', pkg ), function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float16Array(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::get:byteLength', pkg ), function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float16Array(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::get:byteOffset', pkg ), function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float16Array(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::get:length', pkg ), function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float16Array(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.keys.js b/benchmark/benchmark.keys.js deleted file mode 100644 index 9bd4d5f..0000000 --- a/benchmark/benchmark.keys.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:keys', pkg ), function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.keys.length.js b/benchmark/benchmark.keys.length.js deleted file mode 100644 index a9b25c9..0000000 --- a/benchmark/benchmark.keys.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var iter; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isIteratorLike( iter ) ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - 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( format( '%s:keys:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.last_index_of.js b/benchmark/benchmark.last_index_of.js deleted file mode 100644 index 96d9d71..0000000 --- a/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:lastIndexOf', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.lastIndexOf( 11.0 ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.length.js b/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index 230c543..0000000 --- a/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.lastIndexOf( 11.0 ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - 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( format( '%s:lastIndexOf:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index c67eb26..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.map.js b/benchmark/benchmark.map.js deleted file mode 100644 index 7968e8c..0000000 --- a/benchmark/benchmark.map.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:map', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1.0; - } -}); - -bench( format( '%s::this_context:map', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1.0; - } -}); diff --git a/benchmark/benchmark.map.length.js b/benchmark/benchmark.map.length.js deleted file mode 100644 index 3948193..0000000 --- a/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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 = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:map:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.of.js b/benchmark/benchmark.of.js deleted file mode 100644 index 3b8ae26..0000000 --- a/benchmark/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:of', pkg ), function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.of( i, 2.0 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reduce.js b/benchmark/benchmark.reduce.js deleted file mode 100644 index 39ce31c..0000000 --- a/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:reduce', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1.0; - } -}); - -bench( format( '%s::initial_value:reduce', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3.14 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1.0; - } -}); diff --git a/benchmark/benchmark.reduce.length.js b/benchmark/benchmark.reduce.length.js deleted file mode 100644 index 763b4c2..0000000 --- a/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,107 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - 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( format( '%s:reduce:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.reduce_right.js b/benchmark/benchmark.reduce_right.js deleted file mode 100644 index 8a71b79..0000000 --- a/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:reduceRight', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1.0; - } -}); - -bench( format( '%s::initial_value:reduceRight', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3.14 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1.0; - } -}); diff --git a/benchmark/benchmark.reduce_right.length.js b/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index 2001fe5..0000000 --- a/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,107 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - 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( format( '%s:reduceRight:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.reverse.js b/benchmark/benchmark.reverse.js deleted file mode 100644 index a2a239c..0000000 --- a/benchmark/benchmark.reverse.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:reverse', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reverse.length.js b/benchmark/benchmark.reverse.length.js deleted file mode 100644 index 3b526c7..0000000 --- a/benchmark/benchmark.reverse.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s:reverse:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.set.js b/benchmark/benchmark.set.js deleted file mode 100644 index 7648c39..0000000 --- a/benchmark/benchmark.set.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s::array:set', pkg ), function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Float16Array( 2 ); - buf = [ 0.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::typed_array:set', pkg ), function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Float16Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Float16Array( 2 ); - buf = new Float16Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.set.length.js b/benchmark/benchmark.set.length.js deleted file mode 100644 index f174a4a..0000000 --- a/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - - arr1 = uniform( len, 0.0, 10.0 ); - arr2 = uniform( len, 0.0, 10.0 ); - arr = new Float16Array( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - 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( format( '%s:set:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.slice.js b/benchmark/benchmark.slice.js deleted file mode 100644 index 9f5005a..0000000 --- a/benchmark/benchmark.slice.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:slice', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.slice.length.js b/benchmark/benchmark.slice.length.js deleted file mode 100644 index 2374b1b..0000000 --- a/benchmark/benchmark.slice.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s:slice:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.some.js b/benchmark/benchmark.some.js deleted file mode 100644 index 0c81afa..0000000 --- a/benchmark/benchmark.some.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:some', pkg ), function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); - -bench( format( '%s::this_context:some', pkg ), function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); diff --git a/benchmark/benchmark.some.length.js b/benchmark/benchmark.some.length.js deleted file mode 100644 index dd32df4..0000000 --- a/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,107 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value < 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - 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( format( '%s:some:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.sort.js b/benchmark/benchmark.sort.js deleted file mode 100644 index d9e6c30..0000000 --- a/benchmark/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:sort', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.sort.length.js b/benchmark/benchmark.sort.length.js deleted file mode 100644 index 508049c..0000000 --- a/benchmark/benchmark.sort.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ i%len ] = i; - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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 = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:sort:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.subarray.js b/benchmark/benchmark.subarray.js deleted file mode 100644 index 9d6a26b..0000000 --- a/benchmark/benchmark.subarray.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:subarray', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.subarray.length.js b/benchmark/benchmark.subarray.length.js deleted file mode 100644 index c40760b..0000000 --- a/benchmark/benchmark.subarray.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s:subarray:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_locale_string.js b/benchmark/benchmark.to_locale_string.js deleted file mode 100644 index 682ca77..0000000 --- a/benchmark/benchmark.to_locale_string.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:toLocaleString', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_locale_string.length.js b/benchmark/benchmark.to_locale_string.length.js deleted file mode 100644 index 20f510e..0000000 --- a/benchmark/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - 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 = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:toLocaleString:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_reversed.js b/benchmark/benchmark.to_reversed.js deleted file mode 100644 index 1b78c11..0000000 --- a/benchmark/benchmark.to_reversed.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:toReversed', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - 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 ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_reversed.length.js b/benchmark/benchmark.to_reversed.length.js deleted file mode 100644 index 66bf5dc..0000000 --- a/benchmark/benchmark.to_reversed.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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 ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s:toReversed:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_sorted.js b/benchmark/benchmark.to_sorted.js deleted file mode 100644 index d2021b5..0000000 --- a/benchmark/benchmark.to_sorted.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:toSorted', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toSorted(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_sorted.length.js b/benchmark/benchmark.to_sorted.length.js deleted file mode 100644 index b74ea43..0000000 --- a/benchmark/benchmark.to_sorted.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ i%len ] = i; - out = arr.toSorted(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a isFloat16Array' ); - } - 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( format( '%s:toSorted:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_string.js b/benchmark/benchmark.to_string.js deleted file mode 100644 index 6a31520..0000000 --- a/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:toString', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_string.length.js b/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 375cc12..0000000 --- a/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - 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 = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:toString:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.values.js b/benchmark/benchmark.values.js deleted file mode 100644 index 4352d26..0000000 --- a/benchmark/benchmark.values.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:values', pkg ), function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.values.length.js b/benchmark/benchmark.values.length.js deleted file mode 100644 index e0ac1ed..0000000 --- a/benchmark/benchmark.values.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var iter; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isIteratorLike( iter ) ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - 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( format( '%s:values:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.with.js b/benchmark/benchmark.with.js deleted file mode 100644 index 0ca8231..0000000 --- a/benchmark/benchmark.with.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:with', pkg ), function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = uniform( 2, 0.0, 1.0 ); - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.with( i%arr.length, values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.with.length.js b/benchmark/benchmark.with.length.js deleted file mode 100644 index efdf808..0000000 --- a/benchmark/benchmark.with.length.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var values; - var out; - var i; - - values = uniform( 2, 0.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.with( i%len, values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s:with:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.at.js b/benchmark/polyfill/benchmark.at.js deleted file mode 100644 index f0b2b78..0000000 --- a/benchmark/polyfill/benchmark.at.js +++ /dev/null @@ -1,79 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill::nonnegative_indices:at', pkg ), function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float16Array( uniform( 10, 0.0, 10.0 ) ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.at( i%N ); - if ( typeof v !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNumber( v ) ) { - b.fail( 'should return a number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::negative_indices:at', pkg ), function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float16Array( uniform( 10, 1.0, 10.0 ) ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.at( -(i%N)-1 ); - if ( typeof v !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNumber( v ) ) { - b.fail( 'should return a number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.copy_within.js b/benchmark/polyfill/benchmark.copy_within.js deleted file mode 100644 index 867e40a..0000000 --- a/benchmark/polyfill/benchmark.copy_within.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:copyWithin', pkg ), function benchmark( b ) { - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.copy_within.length.js b/benchmark/polyfill/benchmark.copy_within.length.js deleted file mode 100644 index 86bd362..0000000 --- a/benchmark/polyfill/benchmark.copy_within.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - 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( format( '%s::polyfill:copyWithin:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.entries.js b/benchmark/polyfill/benchmark.entries.js deleted file mode 100644 index 013036c..0000000 --- a/benchmark/polyfill/benchmark.entries.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:entries', pkg ), function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.every.js b/benchmark/polyfill/benchmark.every.js deleted file mode 100644 index 2b505c5..0000000 --- a/benchmark/polyfill/benchmark.every.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:every', pkg ), function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0.0; - } -}); - -bench( format( '%s::polyfill::this_context:every', pkg ), function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0.0; - } -}); diff --git a/benchmark/polyfill/benchmark.every.length.js b/benchmark/polyfill/benchmark.every.length.js deleted file mode 100644 index df08cff..0000000 --- a/benchmark/polyfill/benchmark.every.length.js +++ /dev/null @@ -1,107 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - 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( format( '%s::polyfill:every:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.fill.js b/benchmark/polyfill/benchmark.fill.js deleted file mode 100644 index 0c6e740..0000000 --- a/benchmark/polyfill/benchmark.fill.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:fill', pkg ), function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = [ 1.0, 2.0, 3.0 ]; - arr = new Float16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.fill( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.fill.length.js b/benchmark/polyfill/benchmark.fill.length.js deleted file mode 100644 index 6e72c6a..0000000 --- a/benchmark/polyfill/benchmark.fill.length.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var values; - var out; - var i; - - values = [ 1.0, 2.0, 3.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.fill( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s::polyfill:fill:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.filter.js b/benchmark/polyfill/benchmark.filter.js deleted file mode 100644 index 328c3d1..0000000 --- a/benchmark/polyfill/benchmark.filter.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:filter', pkg ), function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0.0; - } -}); - -bench( format( '%s::polyfill::this_context:filter', pkg ), function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0.0; - } -}); diff --git a/benchmark/polyfill/benchmark.filter.length.js b/benchmark/polyfill/benchmark.filter.length.js deleted file mode 100644 index 8673396..0000000 --- a/benchmark/polyfill/benchmark.filter.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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 = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s::polyfill:filter:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.find.js b/benchmark/polyfill/benchmark.find.js deleted file mode 100644 index aef5da9..0000000 --- a/benchmark/polyfill/benchmark.find.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:find', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); - -bench( format( '%s::polyfill::this_context:find', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); diff --git a/benchmark/polyfill/benchmark.find.length.js b/benchmark/polyfill/benchmark.find.length.js deleted file mode 100644 index 0059567..0000000 --- a/benchmark/polyfill/benchmark.find.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value < 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - 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( format( '%s::polyfill:find:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.find_index.js b/benchmark/polyfill/benchmark.find_index.js deleted file mode 100644 index 183c1e4..0000000 --- a/benchmark/polyfill/benchmark.find_index.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:findIndex', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); - -bench( format( '%s::polyfill::this_context:findIndex', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); diff --git a/benchmark/polyfill/benchmark.find_index.length.js b/benchmark/polyfill/benchmark.find_index.length.js deleted file mode 100644 index c9d2887..0000000 --- a/benchmark/polyfill/benchmark.find_index.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value < 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - 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( format( '%s::polyfill:findIndex:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.find_last.js b/benchmark/polyfill/benchmark.find_last.js deleted file mode 100644 index 1d79bb8..0000000 --- a/benchmark/polyfill/benchmark.find_last.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:findLast', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findLast( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); - -bench( format( '%s::polyfill::this_context:findLast', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findLast( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); diff --git a/benchmark/polyfill/benchmark.find_last.length.js b/benchmark/polyfill/benchmark.find_last.length.js deleted file mode 100644 index 5abddac..0000000 --- a/benchmark/polyfill/benchmark.find_last.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value < 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.findLast( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - 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( format( '%s::polyfill:findLast:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.find_last_index.js b/benchmark/polyfill/benchmark.find_last_index.js deleted file mode 100644 index 9fc8543..0000000 --- a/benchmark/polyfill/benchmark.find_last_index.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:findLastIndex', pkg ), function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findLastIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -bench( format( '%s::polyfill::this_context:findLastIndex', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findLastIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); diff --git a/benchmark/polyfill/benchmark.find_last_index.length.js b/benchmark/polyfill/benchmark.find_last_index.length.js deleted file mode 100644 index cd49c40..0000000 --- a/benchmark/polyfill/benchmark.find_last_index.length.js +++ /dev/null @@ -1,110 +0,0 @@ -/** - * @license Apache-2.0 -* -* Copyright (c) 2026 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. -*/ - -/* eslint-disable stdlib/jsdoc-typedef-typos */ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {boolean} value - array element -* @param {NonNegativeInteger} idx - array element index -* @param {Float16Array} arr - array instance -* @returns {boolean} boolean indicating whether a value passes a test -*/ -function predicate( value ) { - return value < 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.findLastIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - 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( format( '%s::polyfill:findLastIndex:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.for_each.js b/benchmark/polyfill/benchmark.for_each.js deleted file mode 100644 index d16383b..0000000 --- a/benchmark/polyfill/benchmark.for_each.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:forEach', pkg ), function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( format( '%s::polyfill::this_context:forEach', pkg ), function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/benchmark/polyfill/benchmark.for_each.length.js b/benchmark/polyfill/benchmark.for_each.length.js deleted file mode 100644 index 5b4f977..0000000 --- a/benchmark/polyfill/benchmark.for_each.length.js +++ /dev/null @@ -1,108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// 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( format( '%s::polyfill:forEach:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.from.js b/benchmark/polyfill/benchmark.from.js deleted file mode 100644 index 8af766a..0000000 --- a/benchmark/polyfill/benchmark.from.js +++ /dev/null @@ -1,238 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( format( '%s::polyfill::typed_array:from', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::typed_array,clbk:from', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1.0; - } -}); - -bench( format( '%s::polyfill::array:from', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1.0, 2.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::array,clbk:from', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1.0, 2.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1.0; - } -}); - -bench( format( '%s::polyfill::iterable:from', pkg ), opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0.0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( format( '%s::polyfill::iterable,clbk:from:', pkg ), opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1.0, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1.0; - } -}); diff --git a/benchmark/polyfill/benchmark.get.js b/benchmark/polyfill/benchmark.get.js deleted file mode 100644 index 2bc111b..0000000 --- a/benchmark/polyfill/benchmark.get.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:get', pkg ), function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float16Array( uniform( 10, 0.0, 10.0 ) ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( typeof v !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNumber( v ) ) { - b.fail( 'should return a number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.includes.js b/benchmark/polyfill/benchmark.includes.js deleted file mode 100644 index 30fc8c4..0000000 --- a/benchmark/polyfill/benchmark.includes.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:includes', pkg ), function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Float16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1.0; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.includes.length.js b/benchmark/polyfill/benchmark.includes.length.js deleted file mode 100644 index 8ac1374..0000000 --- a/benchmark/polyfill/benchmark.includes.length.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1.0; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - 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( format( '%s::polyfill:includes:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.index_of.js b/benchmark/polyfill/benchmark.index_of.js deleted file mode 100644 index c11797c..0000000 --- a/benchmark/polyfill/benchmark.index_of.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:indexOf', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.indexOf( 11.0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( out ) ) { - b.fail( 'should return an integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.index_of.length.js b/benchmark/polyfill/benchmark.index_of.length.js deleted file mode 100644 index 96dfe78..0000000 --- a/benchmark/polyfill/benchmark.index_of.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.indexOf( 11.0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( out ) ) { - b.fail( 'should return an integer' ); - } - 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( format( '%s::polyfill:indexOf:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.join.js b/benchmark/polyfill/benchmark.join.js deleted file mode 100644 index d3d5a47..0000000 --- a/benchmark/polyfill/benchmark.join.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:join', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.join.length.js b/benchmark/polyfill/benchmark.join.length.js deleted file mode 100644 index ca50459..0000000 --- a/benchmark/polyfill/benchmark.join.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - 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( format( '%s::polyfill:join:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.js b/benchmark/polyfill/benchmark.js deleted file mode 100644 index 7c38bae..0000000 --- a/benchmark/polyfill/benchmark.js +++ /dev/null @@ -1,338 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( format( '%s::polyfill::instantiation,new', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array(); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::instantiation,no_new', pkg ), function benchmark( b ) { - var ctor; - var arr; - var i; - - ctor = Float16Array; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = ctor(); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::instantiation,length', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::instantiation,typed_array', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::instantiation,array', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = []; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::instantiation,iterable', pkg ), opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( createIterable() ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - return { - 'done': true - }; - } - } -}); - -bench( format( '%s::polyfill::instantiation,arraybuffer', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::instantiation,arraybuffer,byte_offset', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 8 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( buf, 8 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::instantiation,arraybuffer,byte_offset,length', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 8 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( buf, 8, 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::get:buffer', pkg ), function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float16Array(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::get:byteLength', pkg ), function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float16Array(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::get:byteOffset', pkg ), function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float16Array(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::get:length', pkg ), function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float16Array(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.keys.js b/benchmark/polyfill/benchmark.keys.js deleted file mode 100644 index b51d241..0000000 --- a/benchmark/polyfill/benchmark.keys.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:keys', pkg ), function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.keys.length.js b/benchmark/polyfill/benchmark.keys.length.js deleted file mode 100644 index c6ac13c..0000000 --- a/benchmark/polyfill/benchmark.keys.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var iter; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isIteratorLike( iter ) ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - 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( format( '%s::polyfill:keys:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.last_index_of.js b/benchmark/polyfill/benchmark.last_index_of.js deleted file mode 100644 index 950c98b..0000000 --- a/benchmark/polyfill/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:lastIndexOf', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.lastIndexOf( 11.0 ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.last_index_of.length.js b/benchmark/polyfill/benchmark.last_index_of.length.js deleted file mode 100644 index bf069bb..0000000 --- a/benchmark/polyfill/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.lastIndexOf( 11.0 ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - 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( format( '%s::polyfill:lastIndexOf:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.length.js b/benchmark/polyfill/benchmark.length.js deleted file mode 100644 index 488b91b..0000000 --- a/benchmark/polyfill/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s::polyfill:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.map.js b/benchmark/polyfill/benchmark.map.js deleted file mode 100644 index 810ce41..0000000 --- a/benchmark/polyfill/benchmark.map.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:map', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1.0; - } -}); - -bench( format( '%s::polyfill::this_context:map', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1.0; - } -}); diff --git a/benchmark/polyfill/benchmark.map.length.js b/benchmark/polyfill/benchmark.map.length.js deleted file mode 100644 index 6156472..0000000 --- a/benchmark/polyfill/benchmark.map.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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 = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s::polyfill:map:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.of.js b/benchmark/polyfill/benchmark.of.js deleted file mode 100644 index 165e244..0000000 --- a/benchmark/polyfill/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:of', pkg ), function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.of( i, 2.0 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.reduce.js b/benchmark/polyfill/benchmark.reduce.js deleted file mode 100644 index b8215bd..0000000 --- a/benchmark/polyfill/benchmark.reduce.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:reduce', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1.0; - } -}); - -bench( format( '%s::polyfill::initial_value:reduce', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3.14 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1.0; - } -}); diff --git a/benchmark/polyfill/benchmark.reduce.length.js b/benchmark/polyfill/benchmark.reduce.length.js deleted file mode 100644 index 6d74ccc..0000000 --- a/benchmark/polyfill/benchmark.reduce.length.js +++ /dev/null @@ -1,107 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - 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( format( '%s::polyfill:reduce:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.reduce_right.js b/benchmark/polyfill/benchmark.reduce_right.js deleted file mode 100644 index f2686f6..0000000 --- a/benchmark/polyfill/benchmark.reduce_right.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:reduceRight', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1.0; - } -}); - -bench( format( '%s::polyfill::initial_value:reduceRight', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3.14 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1.0; - } -}); diff --git a/benchmark/polyfill/benchmark.reduce_right.length.js b/benchmark/polyfill/benchmark.reduce_right.length.js deleted file mode 100644 index 62948e3..0000000 --- a/benchmark/polyfill/benchmark.reduce_right.length.js +++ /dev/null @@ -1,107 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - 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( format( '%s::polyfill:reduceRight:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.reverse.js b/benchmark/polyfill/benchmark.reverse.js deleted file mode 100644 index 386b361..0000000 --- a/benchmark/polyfill/benchmark.reverse.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:reverse', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.reverse.length.js b/benchmark/polyfill/benchmark.reverse.length.js deleted file mode 100644 index 5f051b7..0000000 --- a/benchmark/polyfill/benchmark.reverse.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s::polyfill:reverse:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.set.js b/benchmark/polyfill/benchmark.set.js deleted file mode 100644 index e2394cf..0000000 --- a/benchmark/polyfill/benchmark.set.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill::array:set', pkg ), function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Float16Array( 2 ); - buf = [ 0.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::typed_array:set', pkg ), function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Float16Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Float16Array( 2 ); - buf = new Float16Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.set.length.js b/benchmark/polyfill/benchmark.set.length.js deleted file mode 100644 index 72a56e7..0000000 --- a/benchmark/polyfill/benchmark.set.length.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - - arr1 = uniform( len, 0.0, 10.0 ); - arr2 = uniform( len, 0.0, 10.0 ); - arr = new Float16Array( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - 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( format( '%s::polyfill:set:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.slice.js b/benchmark/polyfill/benchmark.slice.js deleted file mode 100644 index 8ee2df0..0000000 --- a/benchmark/polyfill/benchmark.slice.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:slice', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.slice.length.js b/benchmark/polyfill/benchmark.slice.length.js deleted file mode 100644 index 232cff3..0000000 --- a/benchmark/polyfill/benchmark.slice.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s::polyfill:slice:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.some.js b/benchmark/polyfill/benchmark.some.js deleted file mode 100644 index c987ef3..0000000 --- a/benchmark/polyfill/benchmark.some.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:some', pkg ), function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); - -bench( format( '%s::polyfill::this_context:some', pkg ), function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); diff --git a/benchmark/polyfill/benchmark.some.length.js b/benchmark/polyfill/benchmark.some.length.js deleted file mode 100644 index fb689b5..0000000 --- a/benchmark/polyfill/benchmark.some.length.js +++ /dev/null @@ -1,107 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value < 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - 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( format( '%s::polyfill:some:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.sort.js b/benchmark/polyfill/benchmark.sort.js deleted file mode 100644 index 1ffaac3..0000000 --- a/benchmark/polyfill/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:sort', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.sort.length.js b/benchmark/polyfill/benchmark.sort.length.js deleted file mode 100644 index ec66cc2..0000000 --- a/benchmark/polyfill/benchmark.sort.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ i%len ] = i; - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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 = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s::polyfill:sort:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.subarray.js b/benchmark/polyfill/benchmark.subarray.js deleted file mode 100644 index b07f552..0000000 --- a/benchmark/polyfill/benchmark.subarray.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:subarray', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.subarray.length.js b/benchmark/polyfill/benchmark.subarray.length.js deleted file mode 100644 index 7313db0..0000000 --- a/benchmark/polyfill/benchmark.subarray.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s::polyfill:subarray:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.to_locale_string.js b/benchmark/polyfill/benchmark.to_locale_string.js deleted file mode 100644 index 7add18e..0000000 --- a/benchmark/polyfill/benchmark.to_locale_string.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:toLocaleString', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.to_locale_string.length.js b/benchmark/polyfill/benchmark.to_locale_string.length.js deleted file mode 100644 index 3f98d03..0000000 --- a/benchmark/polyfill/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - 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 = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s::polyfill:toLocaleString:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.to_reversed.js b/benchmark/polyfill/benchmark.to_reversed.js deleted file mode 100644 index ca7d6b5..0000000 --- a/benchmark/polyfill/benchmark.to_reversed.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:toReversed', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - 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 ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.to_reversed.length.js b/benchmark/polyfill/benchmark.to_reversed.length.js deleted file mode 100644 index e9fee39..0000000 --- a/benchmark/polyfill/benchmark.to_reversed.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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 ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s::polyfill:toReversed:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.to_sorted.js b/benchmark/polyfill/benchmark.to_sorted.js deleted file mode 100644 index 736fcf1..0000000 --- a/benchmark/polyfill/benchmark.to_sorted.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:toSorted', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toSorted(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.to_sorted.length.js b/benchmark/polyfill/benchmark.to_sorted.length.js deleted file mode 100644 index 32884b3..0000000 --- a/benchmark/polyfill/benchmark.to_sorted.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ i%len ] = i; - out = arr.toSorted(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a isFloat16Array' ); - } - 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( format( '%s::polyfill:toSorted:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.to_string.js b/benchmark/polyfill/benchmark.to_string.js deleted file mode 100644 index a2f7647..0000000 --- a/benchmark/polyfill/benchmark.to_string.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:toString', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.to_string.length.js b/benchmark/polyfill/benchmark.to_string.length.js deleted file mode 100644 index a772983..0000000 --- a/benchmark/polyfill/benchmark.to_string.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - 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 = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s::polyfill:toString:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.values.js b/benchmark/polyfill/benchmark.values.js deleted file mode 100644 index 59a4470..0000000 --- a/benchmark/polyfill/benchmark.values.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:values', pkg ), function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.values.length.js b/benchmark/polyfill/benchmark.values.length.js deleted file mode 100644 index f300b23..0000000 --- a/benchmark/polyfill/benchmark.values.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var iter; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isIteratorLike( iter ) ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - 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( format( '%s::polyfill:values:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.with.js b/benchmark/polyfill/benchmark.with.js deleted file mode 100644 index 05edb05..0000000 --- a/benchmark/polyfill/benchmark.with.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:with', pkg ), function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = uniform( 2, 0.0, 1.0 ); - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.with( i%arr.length, values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.with.length.js b/benchmark/polyfill/benchmark.with.length.js deleted file mode 100644 index cf76a7d..0000000 --- a/benchmark/polyfill/benchmark.with.length.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var values; - var out; - var i; - - values = uniform( 2, 0.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.with( i%len, values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s::polyfill:with:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 62eb7f0..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/float16" -%% click B href "https://github.com/stdlib-js/array-float16/tree/main" -%% click C href "https://github.com/stdlib-js/array-float16/tree/production" -%% click D href "https://github.com/stdlib-js/array-float16/tree/esm" -%% click E href "https://github.com/stdlib-js/array-float16/tree/deno" -%% click F href "https://github.com/stdlib-js/array-float16/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/float16 -[production-url]: https://github.com/stdlib-js/array-float16/tree/production -[deno-url]: https://github.com/stdlib-js/array-float16/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-float16/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-float16/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-float16/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-float16/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-float16/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 0b44231..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ctor from '../docs/types/index'; -export = ctor; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c93dada..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var T=function(o,r){return function(){return r||o((r={exports:{}}).exports,r),r.exports}};var O=T(function(pr,R){"use strict";var D=require("@stdlib/number-float64-base-to-float16"),J=require("@stdlib/number-float16-base-to-word");function K(o,r){var t,i;for(t=r.length,i=0;it.byteLength-o)throw new RangeError(s("invalid arguments. ArrayBuffer has insufficient capacity. Either decrease the array length or provide a bigger buffer. Minimum capacity: `%u`.",i*w));t=new b(t,o,i)}}for(f(this,"_buffer",t),f(this,"_length",t.length),n=0;n1){if(e=arguments[1],!p(e))throw new TypeError(s("invalid argument. Second argument must be a function. Value: `%s`.",e));i>2&&(t=arguments[2])}if(S(r)){if(e){for(h=r.length,n=new this(h),a=n._buffer,y=0;y=this._length))return g(this._buffer[r])});F(u.prototype,"buffer",function(){return this._buffer.buffer});F(u.prototype,"byteLength",function(){return this._buffer.byteLength});F(u.prototype,"byteOffset",function(){return this._buffer.byteOffset});f(u.prototype,"BYTES_PER_ELEMENT",u.BYTES_PER_ELEMENT);f(u.prototype,"copyWithin",function(r,t){if(!v(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");return arguments.length===2?this._buffer.copyWithin(r,t):this._buffer.copyWithin(r,t,arguments[2]),this});f(u.prototype,"entries",function(){var r,t,i,e,n,a;if(!v(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");return r=this,e=this._buffer,i=this._length,a=-1,t={},f(t,"next",l),f(t,"return",h),c&&f(t,c,y),t;function l(){return a+=1,n||a>=i?{done:!0}:{value:[a,g(e[a])],done:!1}}function h(q){return n=!0,arguments.length?{value:q,done:!0}:{done:!0}}function y(){return r.entries()}});f(u.prototype,"every",function(r,t){var i,e;if(!v(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!p(r))throw new TypeError(s("invalid argument. First argument must be a function. Value: `%s`.",r));for(i=this._buffer,e=0;e1){if(!m(t))throw new TypeError(s("invalid argument. Second argument must be an integer. Value: `%s`.",t));if(t<0&&(t+=n,t<0&&(t=0)),arguments.length>2){if(!m(i))throw new TypeError(s("invalid argument. Third argument must be an integer. Value: `%s`.",i));i<0&&(i+=n,i<0&&(i=0)),i>n&&(i=n)}else i=n}else t=0,i=n;for(l=E(r),a=t;a=0;n--)if(e=g(i[n]),r.call(t,e,n,this))return e});f(u.prototype,"findLastIndex",function(r,t){var i,e,n;if(!v(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!p(r))throw new TypeError(s("invalid argument. First argument must be a function. Value: `%s`.",r));for(i=this._buffer,n=this._length-1;n>=0;n--)if(e=g(i[n]),r.call(t,e,n,this))return n;return-1});f(u.prototype,"forEach",function(r,t){var i,e;if(!v(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!p(r))throw new TypeError(s("invalid argument. First argument must be a function. Value: `%s`.",r));for(i=this._buffer,e=0;e=this._length))return g(this._buffer[r])});f(u.prototype,"includes",function(r,t){var i,e,n;if(!v(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!d(r))throw new TypeError(s("invalid argument. First argument must be a number. Value: `%s`.",r));if(arguments.length>1){if(!m(t))throw new TypeError(s("invalid argument. Second argument must be an integer. Value: `%s`.",t));t<0&&(t+=this._length,t<0&&(t=0))}else t=0;for(i=this._buffer,n=E(r),e=t;e1){if(!m(t))throw new TypeError(s("invalid argument. Second argument must be an integer. Value: `%s`.",t));t<0&&(t+=this._length,t<0&&(t=0))}else t=0;for(i=this._buffer,n=E(r),e=t;e0){if(!P(r))throw new TypeError(s("invalid argument. First argument must be a string. Value: `%s`.",r))}else r=",";for(t=this._buffer,i=[],e=0;e=i?{done:!0}:{value:n,done:!1}}function l(y){return e=!0,arguments.length?{value:y,done:!0}:{done:!0}}function h(){return r.keys()}});f(u.prototype,"lastIndexOf",function(r,t){var i,e,n;if(!v(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!d(r))throw new TypeError(s("invalid argument. First argument must be a number. Value: `%s`.",r));if(arguments.length>1){if(!m(t))throw new TypeError(s("invalid argument. Second argument must be an integer. Value: `%s`.",t));t>=this._length?t=this._length-1:t<0&&(t+=this._length)}else t=this._length-1;for(i=this._buffer,n=E(r),e=t;e>=0;e--)if(n===i[e])return e;return-1});F(u.prototype,"length",function(){return this._length});f(u.prototype,"map",function(r,t){var i,e,n,a;if(!v(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!p(r))throw new TypeError("invalid argument. First argument must be a function. Value: `%s`.",r);for(n=this._buffer,e=new this.constructor(this._length),i=e._buffer,a=0;a1)n=t,a=0;else{if(e===0)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");n=g(i[0]),a=1}for(;a1)n=t,a=e-1;else{if(e===0)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");n=g(i[e-1]),a=e-2}for(;a>=0;a--)n=r(n,g(i[a]),a,this);return n});f(u.prototype,"reverse",function(){var r,t,i,e,n,a;if(!v(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");for(r=this._buffer,i=this._length,e=ir(i/2),n=0;n1){if(i=arguments[1],!_(i))throw new TypeError(s("invalid argument. Index argument must be a nonnegative integer. Value: `%s`.",i))}else i=0;if(l=r.length,i+l>this._length)throw new RangeError("invalid arguments. Target array lacks sufficient storage to accommodate source values.");if(v(r)?(t=r._buffer,a=!0):(t=r,a=!1),y=e.byteOffset+i*w,t.buffer===e.buffer&&t.byteOffsety){for(n=new b(t.length),h=0;hl&&(t=l)}}for(rh?1:0}function e(n,a){return r(g(n),g(a))}});f(u.prototype,"subarray",function(r,t){var i,e,n;if(!v(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(e=this._buffer,n=this._length,arguments.length===0)r=0,t=n;else{if(!m(r))throw new TypeError(s("invalid argument. First argument must be an integer. Value: `%s`.",r));if(r<0&&(r+=n,r<0&&(r=0)),arguments.length===1)t=n;else{if(!m(t))throw new TypeError(s("invalid argument. Second argument must be an integer. Value: `%s`.",t));t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n)}}return r>=n?(n=0,i=e.byteLength):r>=t?(n=0,i=e.byteOffset+r*w):(n=t-r,i=e.byteOffset+r*w),new this.constructor(e.buffer,i,n<0?0:n)});f(u.prototype,"toLocaleString",function(r,t){var i,e,n,a,l;if(!v(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(arguments.length===0)e=[];else if(P(r)||tr(r))e=r;else throw new TypeError(s("invalid argument. First argument must be a string or an array of strings. Value: `%s`.",r));if(arguments.length<2)i={};else if(A(t))i=t;else throw new TypeError(s("invalid argument. Options argument must be an object. Value: `%s`.",t));for(a=this._buffer,n=[],l=0;l=i?{done:!0}:{value:g(n[a]),done:!1}}function h(q){return e=!0,arguments.length?{value:q,done:!0}:{done:!0}}function y(){return t.values()}});f(u.prototype,"with",function(r,t){var i,e;if(!v(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!m(r))throw new TypeError(s("invalid argument. First argument must be an integer. Value: `%s`.",r));if(e=this._length,r<0&&(r+=e),r<0||r>=e)throw new RangeError(s("invalid argument. Index argument is out-of-bounds. Value: `%s`.",r));if(!d(t))throw new TypeError(s("invalid argument. Second argument must be a floating-point number. Value: `%s`.",t));return i=new this.constructor(this),i[r]=t,i});G.exports=u});var z=T(function(cr,U){"use strict";var lr=typeof Float16Array=="function"?Float16Array:void 0;U.exports=lr});var hr=require("@stdlib/assert-has-float16array-support"),vr=H(),gr=z(),L;hr()?L=gr:L=vr;module.exports=L; -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index c463d30..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/polyfill/from_array.js", "../lib/polyfill/from_iterator.js", "../lib/polyfill/from_iterator_map.js", "../lib/polyfill/index.js", "../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar f16 = require( '@stdlib/number-float64-base-to-float16' );\nvar toWord = require( '@stdlib/number-float16-base-to-word' );\n\n\n// MAIN //\n\n/**\n* Fills an output array with unsigned 16-bit integers corresponding to the IEEE 754 binary representation of respective half-precision floating-point numbers.\n*\n* @private\n* @param {Uint16Array} buf - output array\n* @param {Array} arr - input array\n* @returns {Uint16Array} output array\n*/\nfunction fromArray( buf, arr ) {\n\tvar len;\n\tvar i;\n\n\tlen = arr.length;\n\tfor ( i = 0; i < len; i++ ) {\n\t\tbuf[ i ] = toWord( f16( arr[ i ] ) );\n\t}\n\treturn buf;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fromArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar f16 = require( '@stdlib/number-float64-base-to-float16' );\nvar toWord = require( '@stdlib/number-float16-base-to-word' );\n\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @returns {Array} output array\n*/\nfunction fromIterator( it ) {\n\tvar out;\n\tvar v;\n\n\tout = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tout.push( toWord( f16( v.value ) ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fromIterator;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar f16 = require( '@stdlib/number-float64-base-to-float16' );\nvar toWord = require( '@stdlib/number-float16-base-to-word' );\n\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @param {Function} clbk - callback to invoke for each iterated value\n* @param {*} thisArg - invocation context\n* @returns {Array} output array\n*/\nfunction fromIteratorMap( it, clbk, thisArg ) {\n\tvar out;\n\tvar v;\n\tvar i;\n\n\tout = [];\n\ti = -1;\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\ti += 1;\n\t\tout.push( toWord( f16( clbk.call( thisArg, v.value, i ) ) ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fromIteratorMap;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this, stdlib/jsdoc-typedef-typos, max-lines */\n\n'use strict';\n\n// MODULES //\n\nvar hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' );\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar isStringArray = require( '@stdlib/assert-is-string-array' ).primitives;\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isObject = require( '@stdlib/assert-is-object' );\nvar isnan = require( '@stdlib/math-base-assert-is-nan' );\nvar ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' );\nvar floor = require( '@stdlib/math-base-special-floor' );\nvar format = require( '@stdlib/string-format' );\nvar Uint16Array = require( '@stdlib/array-uint16' );\nvar f16 = require( '@stdlib/number-float64-base-to-float16' );\nvar toWord = require( '@stdlib/number-float16-base-to-word' );\nvar fromWord = require( '@stdlib/number-float16-base-from-word' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar fromArray = require( './from_array.js' );\nvar fromIterator = require( './from_iterator.js' );\nvar fromIteratorMap = require( './from_iterator_map.js' );\n\n\n// VARIABLES //\n\nvar BYTES_PER_ELEMENT = Uint16Array.BYTES_PER_ELEMENT;\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\n\n\n// FUNCTIONS //\n\n/**\n* Returns a boolean indicating if a value is a `Float16Array`.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `Float16Array`\n*/\nfunction isFloat16Array( value ) {\n\treturn (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\tvalue.constructor.name === 'Float16Array' &&\n\t\tvalue.BYTES_PER_ELEMENT === BYTES_PER_ELEMENT\n\t);\n}\n\n/**\n* Returns a boolean indicating if a value is a floating-point typed array constructor.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a floating-point typed array constructor\n*/\nfunction isFloatingPointArrayConstructor( value ) { // eslint-disable-line id-length\n\treturn ( value === Float16Array );\n}\n\n/**\n* Returns a getter.\n*\n* @private\n* @param {Float16Array} ctx - typed array instance\n* @param {NonNegativeInteger} idx - element index\n* @returns {Function} getter\n*/\nfunction getter( ctx, idx ) {\n\treturn get;\n\n\t/**\n\t* Returns an array element.\n\t*\n\t* @private\n\t* @returns {(number|void)} array element\n\t*/\n\tfunction get() {\n\t\treturn ctx._get( idx ); // eslint-disable-line no-underscore-dangle\n\t}\n}\n\n/**\n* Returns a setter.\n*\n* @private\n* @param {Float16Array} ctx - typed array instance\n* @param {NonNegativeInteger} idx - element index\n* @returns {Function} setter\n*/\nfunction setter( ctx, idx ) {\n\treturn set;\n\n\t/**\n\t* Sets an array element.\n\t*\n\t* @private\n\t* @param {number} value - value to set\n\t*/\n\tfunction set( value ) {\n\t\tctx.set( [ value ], idx );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* 16-bit floating-point number array constructor.\n*\n* @constructor\n* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable\n* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n* @param {NonNegativeInteger} [length] - view length\n* @throws {RangeError} ArrayBuffer byte length must be a multiple of `2`\n* @throws {TypeError} if provided only a single argument, must provide a valid argument\n* @throws {TypeError} byte offset must be a nonnegative integer\n* @throws {RangeError} byte offset must be a multiple of `2`\n* @throws {TypeError} view length must be a positive multiple of `2`\n* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n* @returns {Float16Array} half-precision floating-point number array\n*\n* @example\n* var arr = new Float16Array();\n* // returns \n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var arr = new Float16Array( 5 );\n* // returns \n*\n* var len = arr.length;\n* // returns 5\n*\n* @example\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 5\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float16Array( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 8\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float16Array( buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 4\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Float16Array( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nfunction Float16Array() {\n\tvar byteOffset;\n\tvar nargs;\n\tvar buf;\n\tvar len;\n\tvar arg;\n\tvar i;\n\n\tnargs = arguments.length;\n\tif ( !(this instanceof Float16Array) ) {\n\t\tif ( nargs === 0 ) {\n\t\t\treturn new Float16Array();\n\t\t}\n\t\tif ( nargs === 1 ) {\n\t\t\treturn new Float16Array( arguments[0] );\n\t\t}\n\t\tif ( nargs === 2 ) {\n\t\t\treturn new Float16Array( arguments[0], arguments[1] );\n\t\t}\n\t\treturn new Float16Array( arguments[0], arguments[1], arguments[2] );\n\t}\n\t// Create the underlying data buffer...\n\tif ( nargs === 0 ) {\n\t\tbuf = new Uint16Array( 0 ); // backward-compatibility\n\t} else if ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\t\tif ( isNonNegativeInteger( arg ) ) {\n\t\t\tbuf = new Uint16Array( arg );\n\t\t} else if ( isCollection( arg ) ) {\n\t\t\tif ( isFloat16Array( arg ) ) {\n\t\t\t\tbuf = new Uint16Array( arg.length );\n\t\t\t\tgcopy.ndarray( arg.length, new Uint16Array( arg.buffer, arg.byteOffset, arg.length ), 1, 0, buf, 1, 0 ); // eslint-disable-line max-len\n\t\t\t} else {\n\t\t\t\tbuf = fromArray( new Uint16Array( arg.length ), arg );\n\t\t\t}\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tif ( !isInteger( arg.byteLength/BYTES_PER_ELEMENT ) ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer byte length must be a multiple of %u. Byte length: `%u`.', BYTES_PER_ELEMENT, arg.byteLength ) );\n\t\t\t}\n\t\t\tbuf = new Uint16Array( arg );\n\t\t} else if ( isObject( arg ) ) {\n\t\t\tif ( HAS_ITERATOR_SYMBOL === false ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, ArrayBuffer, typed array, or array-like object. Value: `%s`.', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t\t}\n\t\t\tbuf = arg[ ITERATOR_SYMBOL ]();\n\t\t\tif ( !isFunction( buf.next ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t\t}\n\t\t\tbuf = new Uint16Array( fromIterator( buf ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t}\n\t} else {\n\t\tbuf = arguments[ 0 ];\n\t\tif ( !isArrayBuffer( buf ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', buf ) );\n\t\t}\n\t\tbyteOffset = arguments[ 1 ];\n\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) );\n\t\t}\n\t\tif ( !isInteger( byteOffset/BYTES_PER_ELEMENT ) ) {\n\t\t\tthrow new RangeError( format( 'invalid argument. Byte offset must be a multiple of %u. Value: `%u`.', BYTES_PER_ELEMENT, byteOffset ) );\n\t\t}\n\t\tif ( nargs === 2 ) {\n\t\t\tlen = buf.byteLength - byteOffset;\n\t\t\tif ( !isInteger( len/BYTES_PER_ELEMENT ) ) {\n\t\t\t\tthrow new RangeError( format( 'invalid arguments. ArrayBuffer view byte length must be a multiple of %u. View byte length: `%u`.', BYTES_PER_ELEMENT, len ) );\n\t\t\t}\n\t\t\tbuf = new Uint16Array( buf, byteOffset );\n\t\t} else {\n\t\t\tlen = arguments[ 2 ];\n\t\t\tif ( !isNonNegativeInteger( len ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', len ) );\n\t\t\t}\n\t\t\tif ( (len*BYTES_PER_ELEMENT) > (buf.byteLength-byteOffset) ) {\n\t\t\t\tthrow new RangeError( format( 'invalid arguments. ArrayBuffer has insufficient capacity. Either decrease the array length or provide a bigger buffer. Minimum capacity: `%u`.', len*BYTES_PER_ELEMENT ) );\n\t\t\t}\n\t\t\tbuf = new Uint16Array( buf, byteOffset, len );\n\t\t}\n\t}\n\tsetReadOnly( this, '_buffer', buf );\n\tsetReadOnly( this, '_length', buf.length );\n\tfor ( i = 0; i < buf.length; i++ ) {\n\t\tsetReadWriteAccessor( this, i, getter( this, i ), setter( this, i ) );\n\t}\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each array element.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Float16Array\n* @readonly\n* @type {PositiveInteger}\n* @default 2\n*\n* @example\n* var nbytes = Float16Array.BYTES_PER_ELEMENT;\n* // returns 2\n*/\nsetReadOnly( Float16Array, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT );\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof Float16Array\n* @readonly\n* @type {string}\n* @default 'Float16Array'\n*\n* @example\n* var str = Float16Array.name;\n* // returns 'Float16Array'\n*/\nsetReadOnly( Float16Array, 'name', 'Float16Array' );\n\n/**\n* Creates a new 16-bit floating-point number array from an array-like object or an iterable.\n*\n* @name from\n* @memberof Float16Array\n* @type {Function}\n* @param {(Collection|Iterable)} src - array-like object or iterable\n* @param {Function} [clbk] - callback to invoke for each source element\n* @param {*} [thisArg] - context\n* @throws {TypeError} `this` context must be a constructor\n* @throws {TypeError} `this` must be a floating-point array\n* @throws {TypeError} first argument must be an array-like object or an iterable\n* @throws {TypeError} second argument must be a function\n* @returns {Float16Array} half-precision floating-point number array\n*\n* @example\n* var arr = Float16Array.from( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* function clbk( v ) {\n* return v * 2.0;\n* }\n*\n* var arr = Float16Array.from( [ 1.0, 2.0 ], clbk );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nsetReadOnly( Float16Array, 'from', function from( src ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar clbk;\n\tvar out;\n\tvar buf;\n\tvar tmp;\n\tvar len;\n\tvar i;\n\tif ( !isFunction( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` context must be a constructor.' );\n\t}\n\tif ( !isFloatingPointArrayConstructor( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point array.' );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs > 1 ) {\n\t\tclbk = arguments[ 1 ];\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t\tif ( nargs > 2 ) {\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( isCollection( src ) ) {\n\t\tif ( clbk ) {\n\t\t\tlen = src.length;\n\t\t\tout = new this( len );\n\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tbuf[ i ] = toWord( f16( clbk.call( thisArg, src[ i ], i ) ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\treturn new this( src );\n\t}\n\tif ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) { // eslint-disable-line max-len\n\t\tbuf = src[ ITERATOR_SYMBOL ]();\n\t\tif ( !isFunction( buf.next ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) );\n\t\t}\n\t\tif ( clbk ) {\n\t\t\ttmp = fromIteratorMap( buf, clbk, thisArg );\n\t\t} else {\n\t\t\ttmp = fromIterator( buf );\n\t\t}\n\t\tif ( tmp instanceof Error ) {\n\t\t\tthrow tmp;\n\t\t}\n\t\tlen = tmp.length;\n\t\tout = new this( len );\n\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tbuf[ i ] = tmp[ i ];\n\t\t}\n\t\treturn out;\n\t}\n\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) );\n});\n\n/**\n* Creates a new 16-bit floating-point number array from a variable number of arguments.\n*\n* @name of\n* @memberof Float16Array\n* @type {Function}\n* @param {...*} element - array elements\n* @throws {TypeError} `this` context must be a constructor\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Float16Array} half-precision floating-point number array\n*\n* @example\n* var arr = Float16Array.of( 1.0, 1.0, 1.0, 1.0 );\n* // returns \n*\n* var x = arr[ 0 ];\n* // returns 1.0\n*\n* var len = arr.length;\n* // returns 4\n*/\nsetReadOnly( Float16Array, 'of', function of() {\n\tvar args;\n\tvar i;\n\tif ( !isFunction( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` context must be a constructor.' );\n\t}\n\tif ( !isFloatingPointArrayConstructor( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\targs = [];\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\targs.push( arguments[ i ] );\n\t}\n\treturn new this( args );\n});\n\n/**\n* Returns an array element with support for both nonnegative and negative integer indices.\n*\n* @name at\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} must provide an integer\n* @returns {(number|void)} array element\n*\n* @example\n* var arr = new Float16Array( [ 10.0, 20.0, 30.0 ] );\n*\n* var v = arr.at( 0 );\n* // returns 10.0\n*\n* v = arr.at( -1 );\n* // returns 30.0\n*\n* v = arr.at( 100 );\n* // returns undefined\n*/\nsetReadOnly( Float16Array.prototype, 'at', function at( idx ) {\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += this._length;\n\t}\n\tif ( idx < 0 || idx >= this._length ) {\n\t\treturn;\n\t}\n\treturn fromWord( this._buffer[ idx ] );\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name buffer\n* @memberof Float16Array.prototype\n* @readonly\n* @type {ArrayBuffer}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var buf = arr.buffer;\n* // returns \n*/\nsetReadOnlyAccessor( Float16Array.prototype, 'buffer', function get() {\n\treturn this._buffer.buffer;\n});\n\n/**\n* Size (in bytes) of the array.\n*\n* @name byteLength\n* @memberof Float16Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var byteLength = arr.byteLength;\n* // returns 20\n*/\nsetReadOnlyAccessor( Float16Array.prototype, 'byteLength', function get() {\n\treturn this._buffer.byteLength;\n});\n\n/**\n* Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`.\n*\n* @name byteOffset\n* @memberof Float16Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var byteOffset = arr.byteOffset;\n* // returns 0\n*/\nsetReadOnlyAccessor( Float16Array.prototype, 'byteOffset', function get() {\n\treturn this._buffer.byteOffset;\n});\n\n/**\n* Size (in bytes) of each array element.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Float16Array.prototype\n* @readonly\n* @type {PositiveInteger}\n* @default 2\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var nbytes = arr.BYTES_PER_ELEMENT;\n* // returns 2\n*/\nsetReadOnly( Float16Array.prototype, 'BYTES_PER_ELEMENT', Float16Array.BYTES_PER_ELEMENT );\n\n/**\n* Copies a sequence of elements within the array to the position starting at `target`.\n*\n* @name copyWithin\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} target - index at which to start copying elements\n* @param {integer} start - source index at which to copy elements from\n* @param {integer} [end] - source index at which to stop copying elements from\n* @throws {TypeError} `this` must be a floating-point array\n* @returns {Float16Array} modified array\n*\n* @example\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0 ] );\n*\n* // Copy the first two elements to the last two elements:\n* arr.copyWithin( 2, 0, 2 );\n*\n* var v = arr[ 2 ];\n* // returns 1.0\n*\n* v = arr[ 3 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'copyWithin', function copyWithin( target, start ) {\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\t// FIXME: prefer a functional `copyWithin` implementation which addresses lack of universal browser support (e.g., IE11 and Safari) or ensure that typed arrays are polyfilled\n\tif ( arguments.length === 2 ) {\n\t\tthis._buffer.copyWithin( target, start );\n\t} else {\n\t\tthis._buffer.copyWithin( target, start, arguments[2] );\n\t}\n\treturn this;\n});\n\n/**\n* Returns an iterator for iterating over array key-value pairs.\n*\n* @name entries\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] );\n*\n* var it = arr.entries();\n*\n* var v = it.next().value;\n* // returns [ 0, 1.0 ]\n*\n* v = it.next().value;\n* // returns [ 1, 2.0 ]\n*\n* v = it.next().value;\n* // returns [ 2, 3.0 ]\n*\n* var bool = it.next().done;\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'entries', function entries() {\n\tvar self;\n\tvar iter;\n\tvar len;\n\tvar buf;\n\tvar FLG;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tself = this;\n\tbuf = this._buffer;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': [ i, fromWord( buf[ i ] ) ],\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.entries();\n\t}\n});\n\n/**\n* Tests whether all elements in an array pass a test implemented by a predicate function.\n*\n* @name every\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {boolean} boolean indicating whether all elements pass a test\n*\n* @example\n* function predicate( v ) {\n* return v === 0.0;\n* }\n*\n* var arr = new Float16Array( 3 );\n*\n* var bool = arr.every( predicate );\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'every', function every( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( !predicate.call( thisArg, fromWord( buf[ i ] ), i, this ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n});\n\n/**\n* Returns a modified typed array filled with a fill value.\n*\n* @name fill\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {number} value - fill value\n* @param {integer} [start=0] - starting index (inclusive)\n* @param {integer} [end] - ending index (exclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a floating-point number\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be an integer\n* @returns {Float16Array} modified array\n*\n* @example\n* var arr = new Float16Array( 3 );\n*\n* arr.fill( 1.0, 1 );\n*\n* var v = arr[ 0 ];\n* // returns 0.0\n*\n* v = arr[ 1 ];\n* // returns 1.0\n*\n* v = arr[ 2 ];\n* // returns 1.0\n*/\nsetReadOnly( Float16Array.prototype, 'fill', function fill( value, start, end ) {\n\tvar buf;\n\tvar len;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNumber( value ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a number. Value: `%s`.', value ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( start ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', start ) );\n\t\t}\n\t\tif ( start < 0 ) {\n\t\t\tstart += len;\n\t\t\tif ( start < 0 ) {\n\t\t\t\tstart = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length > 2 ) {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t} else {\n\t\t\tend = len;\n\t\t}\n\t} else {\n\t\tstart = 0;\n\t\tend = len;\n\t}\n\tv = toWord( value );\n\tfor ( i = start; i < end; i++ ) {\n\t\tbuf[ i ] = v;\n\t}\n\treturn this;\n});\n\n/**\n* Returns a new array containing the elements of an array which pass a test implemented by a predicate function.\n*\n* @name filter\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {Float16Array} floating-point number array\n*\n* @example\n* function predicate( v ) {\n* return ( v === 0.0 );\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] );\n*\n* var out = arr.filter( predicate );\n* // returns \n*\n* var len = out.length;\n* // returns 2\n*\n* var v = out[ 0 ];\n* // returns 0.0\n*\n* v = out[ 1 ];\n* // returns 0.0\n*/\nsetReadOnly( Float16Array.prototype, 'filter', function filter( predicate, thisArg ) {\n\tvar buf;\n\tvar out;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\tout.push( v );\n\t\t}\n\t}\n\treturn new this.constructor( out );\n});\n\n/**\n* Returns the first element in an array for which a predicate function returns a truthy value.\n*\n* @name find\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {(boolean|void)} array element or undefined\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] );\n*\n* var v = arr.find( predicate );\n* // returns 1.0\n*/\nsetReadOnly( Float16Array.prototype, 'find', function find( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn v;\n\t\t}\n\t}\n});\n\n/**\n* Returns the index of the first element in an array for which a predicate function returns a truthy value.\n*\n* @name findIndex\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {integer} index or -1\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var v = arr.findIndex( predicate );\n* // returns 1\n*/\nsetReadOnly( Float16Array.prototype, 'findIndex', function findIndex( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Returns the last element in an array for which a predicate function returns a truthy value.\n*\n* @name findLast\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {(boolean|void)} array element or undefined\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] );\n*\n* var v = arr.findLast( predicate );\n* // returns 1.0\n*/\nsetReadOnly( Float16Array.prototype, 'findLast', function findLast( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = this._length-1; i >= 0; i-- ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn v;\n\t\t}\n\t}\n});\n\n/**\n* Returns the index of the last element in an array for which a predicate function returns a truthy value.\n*\n* @name findLastIndex\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {integer} index or -1\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] );\n*\n* var v = arr.findLastIndex( predicate );\n* // returns 1\n*/\nsetReadOnly( Float16Array.prototype, 'findLastIndex', function findLastIndex( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = this._length-1; i >= 0; i-- ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Invokes a function once for each array element.\n*\n* @name forEach\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} fcn - function to invoke\n* @param {*} [thisArg] - function invocation context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n*\n* @example\n* function log( v, i ) {\n* console.log( '%s: %s', i, v.toString() );\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* arr.forEach( log );\n*/\nsetReadOnly( Float16Array.prototype, 'forEach', function forEach( fcn, thisArg ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( fcn ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tfcn.call( thisArg, fromWord( buf[ i ] ), i, this );\n\t}\n});\n\n/**\n* Returns an array element.\n*\n* @private\n* @name _get\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {NonNegativeInteger} idx - element index\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} must provide a nonnegative integer\n* @returns {(number|void)} array element\n*/\nsetReadOnly( Float16Array.prototype, '_get', function get( idx ) {\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNonNegativeInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a nonnegative integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx >= this._length ) {\n\t\treturn;\n\t}\n\treturn fromWord( this._buffer[ idx ] );\n});\n\n/**\n* Returns a boolean indicating whether an array includes a provided value.\n*\n* @name includes\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {number} searchElement - search element\n* @param {integer} [fromIndex=0] - starting index (inclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a floating-point number\n* @throws {TypeError} second argument must be an integer\n* @returns {boolean} boolean indicating whether an array includes a value\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] );\n*\n* var bool = arr.includes( 1.0 );\n* // returns true\n*\n* bool = arr.includes( 1.0, 2 );\n* // returns false\n*\n* bool = arr.includes( 5.0 );\n* // returns false\n*/\nsetReadOnly( Float16Array.prototype, 'includes', function includes( searchElement, fromIndex ) {\n\tvar buf;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNumber( searchElement ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a number. Value: `%s`.', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\tfromIndex = 0;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfromIndex = 0;\n\t}\n\tbuf = this._buffer;\n\tv = toWord( searchElement );\n\tfor ( i = fromIndex; i < this._length; i++ ) {\n\t\tif ( v === buf[ i ] ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n});\n\n/**\n* Returns the first index at which a given element can be found.\n*\n* @name indexOf\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {float16} searchElement - element to find\n* @param {integer} [fromIndex=0] - starting index (inclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a floating-point number\n* @throws {TypeError} second argument must be an integer\n* @returns {integer} index or -1\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] );\n*\n* var idx = arr.indexOf( 2.0 );\n* // returns 2\n*\n* idx = arr.indexOf( 2.0, 3 );\n* // returns -1\n*\n* idx = arr.indexOf( 3.0, 3 );\n* // returns 3\n*/\nsetReadOnly( Float16Array.prototype, 'indexOf', function indexOf( searchElement, fromIndex ) {\n\tvar buf;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNumber( searchElement ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a number. Value: `%s`.', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\tfromIndex = 0;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfromIndex = 0;\n\t}\n\tbuf = this._buffer;\n\tv = toWord( searchElement );\n\tfor ( i = fromIndex; i < this._length; i++ ) {\n\t\tif ( v === buf[ i ] ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Returns a new string by concatenating all array elements.\n*\n* @name join\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {string} [separator=','] - element separator\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a string\n* @returns {string} string representation\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var str = arr.join();\n* // returns '0,1,2'\n*\n* str = arr.join( '|' );\n* // returns '0|1|2'\n*/\nsetReadOnly( Float16Array.prototype, 'join', function join( separator ) {\n\tvar buf;\n\tvar out;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( arguments.length > 0 ) {\n\t\tif ( !isString( separator ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', separator ) );\n\t\t}\n\t} else {\n\t\tseparator = ',';\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( fromWord( buf[ i ] ) );\n\t}\n\treturn out.join( separator );\n});\n\n/**\n* Returns an iterator for iterating over each index key in a typed array.\n*\n* @name keys\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new Float16Array( [ 1.0, 2.0 ] );\n*\n* var iter = arr.keys();\n*\n* var v = iter.next().value;\n* // returns 0\n*\n* v = iter.next().value;\n* // returns 1\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'keys', function keys() {\n\tvar self;\n\tvar iter;\n\tvar len;\n\tvar FLG;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tself = this;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': i,\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.keys();\n\t}\n});\n\n/**\n* Returns the last index at which a given element can be found.\n*\n* @name lastIndexOf\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {number} searchElement - element to find\n* @param {integer} [fromIndex] - starting index (inclusive)\n* @throws {TypeError} `this` must be a floating-point number\n* @throws {TypeError} first argument must be a numeric value\n* @throws {TypeError} second argument must be an integer\n* @returns {integer} index or -1\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 2.0 ] );\n*\n* var idx = arr.lastIndexOf( 2.0 );\n* // returns 4\n*\n* idx = arr.lastIndexOf( 2.0, 3 );\n* // returns 2\n*\n* idx = arr.lastIndexOf( 4.0, 3 );\n* // returns -1\n*\n* idx = arr.lastIndexOf( 1.0, -3 );\n* // returns 1\n*/\nsetReadOnly( Float16Array.prototype, 'lastIndexOf', function lastIndexOf( searchElement, fromIndex ) {\n\tvar buf;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNumber( searchElement ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a number. Value: `%s`.', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex >= this._length ) {\n\t\t\tfromIndex = this._length - 1;\n\t\t} else if ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t}\n\t} else {\n\t\tfromIndex = this._length - 1;\n\t}\n\tbuf = this._buffer;\n\tv = toWord( searchElement );\n\tfor ( i = fromIndex; i >= 0; i-- ) {\n\t\tif ( v === buf[ i ] ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Number of array elements.\n*\n* @name length\n* @memberof Float16Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var len = arr.length;\n* // returns 10\n*/\nsetReadOnlyAccessor( Float16Array.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Returns a new array with each element being the result of a provided callback function.\n*\n* @name map\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} fcn - callback function\n* @param {*} [thisArg] - callback function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {Float16Array} new floating-point number array\n*\n* @example\n* function scale( v ) {\n* return v * 2.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var out = arr.map( scale );\n* // returns \n*\n* var z = out[ 0 ];\n* // returns 0.0\n*\n* z = out[ 1 ];\n* // returns 2.0\n*\n* z = out[ 2 ];\n* // returns 4.0\n*/\nsetReadOnly( Float16Array.prototype, 'map', function map( fcn, thisArg ) {\n\tvar outbuf;\n\tvar out;\n\tvar buf;\n\tvar i;\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( fcn ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be a function. Value: `%s`.', fcn );\n\t}\n\tbuf = this._buffer;\n\tout = new this.constructor( this._length );\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\toutbuf[ i ] = toWord( fcn.call( thisArg, fromWord( buf[ i ] ), i, this ) ); // eslint-disable-line max-len\n\t}\n\treturn out;\n});\n\n/**\n* Applies a provided callback function to each element of the array, in order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion.\n*\n* @name reduce\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} reducer - callback function\n* @param {*} [initialValue] - initial value\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {Error} if not provided an initial value, the array must have at least one element\n* @returns {*} accumulated result\n*\n* @example\n* function add( acc, v ) {\n* return acc + v;\n* }\n*\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] );\n*\n* var out = arr.reduce( add, 0 );\n* // returns 6.0\n*/\nsetReadOnly( Float16Array.prototype, 'reduce', function reduce( reducer, initialValue ) {\n\tvar buf;\n\tvar len;\n\tvar acc;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( reducer ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', reducer ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tacc = initialValue;\n\t\ti = 0;\n\t} else {\n\t\tif ( len === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' );\n\t\t}\n\t\tacc = fromWord( buf[ 0 ] );\n\t\ti = 1;\n\t}\n\tfor ( ; i < len; i++ ) {\n\t\tacc = reducer( acc, fromWord( buf[ i ] ), i, this );\n\t}\n\treturn acc;\n});\n\n/**\n* Applies a provided callback function to each element of the array, in reverse order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion.\n*\n* @name reduceRight\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} reducer - callback function\n* @param {*} [initialValue] - initial value\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {Error} if not provided an initial value, the array must have at least one element\n* @returns {*} accumulated result\n*\n* @example\n* function add( acc, v ) {\n* return acc + v;\n* }\n*\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] );\n*\n* var out = arr.reduceRight( add, 0 );\n* // returns 6.0\n*/\nsetReadOnly( Float16Array.prototype, 'reduceRight', function reduceRight( reducer, initialValue ) {\n\tvar buf;\n\tvar len;\n\tvar acc;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( reducer ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', reducer ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tacc = initialValue;\n\t\ti = len - 1;\n\t} else {\n\t\tif ( len === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' );\n\t\t}\n\t\tacc = fromWord( buf[ len-1 ] );\n\t\ti = len - 2;\n\t}\n\tfor ( ; i >= 0; i-- ) {\n\t\tacc = reducer( acc, fromWord( buf[ i ] ), i, this );\n\t}\n\treturn acc;\n});\n\n/**\n* Reverses an array in-place.\n*\n* @name reverse\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Float16Array} reversed array\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var out = arr.reverse();\n* // returns \n*\n* var v = out[ 0 ];\n* // returns 2.0\n*\n* v = out[ 1 ];\n* // returns 1.0\n*\n* v = out[ 2 ];\n* // returns 0.0\n*/\nsetReadOnly( Float16Array.prototype, 'reverse', function reverse() {\n\tvar buf;\n\tvar tmp;\n\tvar len;\n\tvar N;\n\tvar i;\n\tvar j;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tN = floor( len / 2 );\n\tfor ( i = 0; i < N; i++ ) {\n\t\tj = len - i - 1;\n\t\ttmp = buf[ i ];\n\t\tbuf[ i ] = buf[ j ];\n\t\tbuf[ j ] = tmp;\n\t}\n\treturn this;\n});\n\n/**\n* Sets one or more array elements.\n*\n* ## Notes\n*\n* - When provided a typed array, we must check whether the source array shares the same buffer as the target array and whether the underlying memory overlaps. In particular, we are concerned with the following scenario:\n*\n* ```text\n* buf: ---------------------\n* src: ---------------------\n* ```\n*\n* In the above, as we copy values from `src`, we will overwrite values in the `src` view, resulting in duplicated values copied into the end of `buf`, which is not intended. Hence, to avoid overwriting source values, we must **copy** source values to a temporary array.\n*\n* In the other overlapping scenario,\n*\n* ```text\n* buf: ---------------------\n* src: ---------------------\n* ```\n*\n* by the time we begin copying into the overlapping region, we are copying from the end of `src`, a non-overlapping region, which means we don't run the risk of copying copied values, rather than the original `src` values, as intended.\n*\n* @name set\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {(Collection|Float16Array)} value - value(s)\n* @param {NonNegativeInteger} [i=0] - element index at which to start writing values\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a collection\n* @throws {TypeError} index argument must be a nonnegative integer\n* @throws {RangeError} index argument is out-of-bounds\n* @throws {RangeError} target array lacks sufficient storage to accommodate source values\n* @returns {void}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var v = arr[ 0 ];\n* // returns 0.0\n*\n* arr.set( [ 1.0, 2.0 ], 0 );\n*\n* v = arr[ 0 ];\n* // returns 1.0\n*/\nsetReadOnly( Float16Array.prototype, 'set', function set( value ) {\n\tvar sbuf;\n\tvar idx;\n\tvar buf;\n\tvar tmp;\n\tvar flg;\n\tvar N;\n\tvar i;\n\tvar j;\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isCollection( value ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', value ) );\n\t}\n\tbuf = this._buffer;\n\tif ( arguments.length > 1 ) {\n\t\tidx = arguments[ 1 ];\n\t\tif ( !isNonNegativeInteger( idx ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Index argument must be a nonnegative integer. Value: `%s`.', idx ) );\n\t\t}\n\t} else {\n\t\tidx = 0;\n\t}\n\tN = value.length;\n\tif ( idx+N > this._length ) {\n\t\tthrow new RangeError( 'invalid arguments. Target array lacks sufficient storage to accommodate source values.' );\n\t}\n\tif ( isFloat16Array( value ) ) {\n\t\tsbuf = value._buffer; // eslint-disable-line no-underscore-dangle\n\t\tflg = true;\n\t} else {\n\t\tsbuf = value;\n\t\tflg = false;\n\t}\n\t// Check for overlapping memory...\n\tj = buf.byteOffset + (idx*BYTES_PER_ELEMENT);\n\tif (\n\t\tsbuf.buffer === buf.buffer &&\n\t\t(\n\t\t\tsbuf.byteOffset < j &&\n\t\t\tsbuf.byteOffset+sbuf.byteLength > j\n\t\t)\n\t) {\n\t\t// We need to copy source values...\n\t\ttmp = new Uint16Array( sbuf.length );\n\t\tfor ( i = 0; i < sbuf.length; i++ ) {\n\t\t\ttmp[ i ] = sbuf[ i ];\n\t\t}\n\t\tsbuf = tmp;\n\t}\n\tif ( flg ) {\n\t\tfor ( i = 0; i < N; idx++, i++ ) {\n\t\t\tbuf[ idx ] = sbuf[ i ];\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < N; idx++, i++ ) {\n\t\t\tbuf[ idx ] = toWord( sbuf[ i ] );\n\t\t}\n\t}\n});\n\n/**\n* Copies a portion of a typed array to a new typed array.\n*\n* @name slice\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} [begin] - start index (inclusive)\n* @param {integer} [end] - end index (exclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be integer\n* @throws {TypeError} second argument must be integer\n* @returns {Float16Array} floating-point number array\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] );\n*\n* var out = arr.slice();\n* // returns \n*\n* var len = out.length;\n* // returns 5\n*\n* var v = out[ 0 ];\n* // returns 0.0\n*\n* v = out[ len-1 ];\n* // returns 4.0\n*\n* out = arr.slice( 1, -2 );\n* // returns \n*\n* len = out.length;\n* // returns 2\n*\n* v = out[ 0 ];\n* // returns 1.0\n*\n* v = out[ len-1 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'slice', function slice( begin, end ) {\n\tvar outlen;\n\tvar outbuf;\n\tvar out;\n\tvar buf;\n\tvar len;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length === 0 ) {\n\t\tbegin = 0;\n\t\tend = len;\n\t} else {\n\t\tif ( !isInteger( begin ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', begin ) );\n\t\t}\n\t\tif ( begin < 0 ) {\n\t\t\tbegin += len;\n\t\t\tif ( begin < 0 ) {\n\t\t\t\tbegin = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\tend = len;\n\t\t} else {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t} else if ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t}\n\t}\n\tif ( begin < end ) {\n\t\toutlen = end - begin;\n\t} else {\n\t\toutlen = 0;\n\t}\n\tout = new this.constructor( outlen );\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < outlen; i++ ) {\n\t\toutbuf[ i ] = buf[ i+begin ];\n\t}\n\treturn out;\n});\n\n/**\n* Tests whether at least one element in an array passes a test implemented by a predicate function.\n*\n* @name some\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {boolean} boolean indicating whether at least one element passes a test\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var bool = arr.some( predicate );\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'some', function some( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( predicate.call( thisArg, fromWord( buf[ i ] ), i, this ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n});\n\n/**\n* Sorts an array in-place.\n*\n* @name sort\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} [compareFcn] - comparison function\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {Float16Array} sorted array\n*\n* @example\n* function compare( a, b ) {\n* if ( a < b ) {\n* return -1;\n* }\n* if ( a > b ) {\n* return 1;\n* }\n* return 0;\n* }\n*\n* var arr = new Float16Array( [ 1.0, 0.0, 2.0 ] );\n*\n* arr.sort( compare );\n*\n* var v = arr[ 0 ];\n* // returns 0.0\n*\n* v = arr[ 1 ];\n* // returns 1.0\n*\n* v = arr[ 2 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'sort', function sort( compareFcn ) {\n\tvar buf;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tif ( arguments.length === 0 ) {\n\t\tbuf.sort( defaultCompare );\n\t\treturn this;\n\t}\n\tif ( !isFunction( compareFcn ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', compareFcn ) );\n\t}\n\tbuf.sort( compare );\n\treturn this;\n\n\t/**\n\t* Default comparison function for float16 values.\n\t*\n\t* @private\n\t* @param {unsigned16} a - unsigned 16-bit integer for comparison\n\t* @param {unsigned16} b - unsigned 16-bit integer for comparison\n\t* @returns {number} comparison result\n\t*/\n\tfunction defaultCompare( a, b ) { // eslint-disable-line stdlib/no-unnecessary-nested-functions\n\t\tvar x = fromWord( a );\n\t\tvar y = fromWord( b );\n\n\t\t// Handle NaN...\n\t\tif ( isnan( x ) && isnan( y ) ) {\n\t\t\treturn 0;\n\t\t}\n\t\tif ( isnan( x ) ) {\n\t\t\treturn 1;\n\t\t}\n\t\tif ( isnan( y ) ) {\n\t\t\treturn -1;\n\t\t}\n\t\t// Normal comparison\n\t\tif ( x < y ) {\n\t\t\treturn -1;\n\t\t}\n\t\tif ( x > y ) {\n\t\t\treturn 1;\n\t\t}\n\t\treturn 0;\n\t}\n\n\t/**\n\t* Comparison function wrapper.\n\t*\n\t* @private\n\t* @param {unsigned16} a - unsigned 16-bit integer for comparison\n\t* @param {unsigned16} b - unsigned 16-bit integer for comparison\n\t* @returns {number} comparison result\n\t*/\n\tfunction compare( a, b ) {\n\t\treturn compareFcn( fromWord( a ), fromWord( b ) );\n\t}\n});\n\n/**\n* Creates a new typed array view over the same underlying `ArrayBuffer` and with the same underlying data type as the host array.\n*\n* @name subarray\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} [begin] - start index (inclusive)\n* @param {integer} [end] - end index (exclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be an integer\n* @throws {TypeError} second argument must be an integer\n* @returns {Float16Array} subarray\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] );\n*\n* var subarr = arr.subarray();\n* // returns \n*\n* var len = subarr.length;\n* // returns 5\n*\n* var bool = subarr[ 0 ];\n* // returns 0.0\n*\n* bool = subarr[ len-1 ];\n* // returns 4.0\n*\n* subarr = arr.subarray( 1, -2 );\n* // returns \n*\n* len = subarr.length;\n* // returns 2\n*\n* bool = subarr[ 0 ];\n* // returns 1.0\n*\n* bool = subarr[ len-1 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'subarray', function subarray( begin, end ) {\n\tvar offset;\n\tvar buf;\n\tvar len;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length === 0 ) {\n\t\tbegin = 0;\n\t\tend = len;\n\t} else {\n\t\tif ( !isInteger( begin ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', begin ) );\n\t\t}\n\t\tif ( begin < 0 ) {\n\t\t\tbegin += len;\n\t\t\tif ( begin < 0 ) {\n\t\t\t\tbegin = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\tend = len;\n\t\t} else {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t} else if ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t}\n\t}\n\tif ( begin >= len ) {\n\t\tlen = 0;\n\t\toffset = buf.byteLength;\n\t} else if ( begin >= end ) {\n\t\tlen = 0;\n\t\toffset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT );\n\t} else {\n\t\tlen = end - begin;\n\t\toffset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT );\n\t}\n\treturn new this.constructor( buf.buffer, offset, ( len < 0 ) ? 0 : len );\n});\n\n/**\n* Serializes an array as a locale-specific string.\n*\n* @name toLocaleString\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {(string|Array)} [locales] - locale identifier(s)\n* @param {Object} [options] - configuration options\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a string or an array of strings\n* @throws {TypeError} options argument must be an object\n* @returns {string} string representation\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var str = arr.toLocaleString();\n* // returns '0,1,2'\n*/\nsetReadOnly( Float16Array.prototype, 'toLocaleString', function toLocaleString( locales, options ) {\n\tvar opts;\n\tvar loc;\n\tvar out;\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( arguments.length === 0 ) {\n\t\tloc = [];\n\t} else if ( isString( locales ) || isStringArray( locales ) ) {\n\t\tloc = locales;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a string or an array of strings. Value: `%s`.', locales ) );\n\t}\n\tif ( arguments.length < 2 ) {\n\t\topts = {};\n\t} else if ( isObject( options ) ) {\n\t\topts = options;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( fromWord( buf[ i ] ) );\n\t}\n\treturn out.toLocaleString( loc, opts );\n});\n\n/**\n* Returns a new typed array containing the elements in reversed order.\n*\n* @name toReversed\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Float16Array} reversed array\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var out = arr.toReversed();\n* // returns \n*\n* var v = out[ 0 ];\n* // returns 2.0\n*\n* v = out[ 1 ];\n* // returns 1.0\n*\n* v = out[ 2 ];\n* // returns 0.0\n*/\nsetReadOnly( Float16Array.prototype, 'toReversed', function toReversed() {\n\tvar outbuf;\n\tvar out;\n\tvar len;\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tlen = this._length;\n\tout = new this.constructor( len );\n\tbuf = this._buffer;\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < len; i++ ) {\n\t\toutbuf[ i ] = buf[ len - i - 1 ];\n\t}\n\treturn out;\n});\n\n/**\n* Returns a new typed array containing the elements in sorted order.\n*\n* @name toSorted\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} [compareFcn] - comparison function\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {Float16Array} sorted array\n*\n* @example\n* function compare( a, b ) {\n* if ( a > b ) {\n* return 1;\n* }\n* if ( a < b ) {\n* return -1;\n* }\n* return 0;\n* }\n*\n* var arr = new Float16Array( [ 2.0, 0.0, 1.0 ] );\n*\n* var out = arr.toSorted( compare );\n* // returns \n*\n* var v = out[ 0 ];\n* // returns 0.0\n*\n* v = out[ 1 ];\n* // returns 1.0\n*\n* v = out[ 2 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'toSorted', function toSorted( compareFcn ) {\n\tvar out;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tout = new this.constructor( this );\n\tif ( arguments.length === 0 ) {\n\t\treturn out.sort();\n\t}\n\treturn out.sort( compareFcn );\n});\n\n/**\n* Serializes an array as a string.\n*\n* @name toString\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {string} string representation\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var str = arr.toString();\n* // returns '0,1,2'\n*/\nsetReadOnly( Float16Array.prototype, 'toString', function toString() {\n\tvar out;\n\tvar buf;\n\tvar i;\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( fromWord( buf[ i ] ) );\n\t}\n\treturn out.join( ',' );\n});\n\n/**\n* Returns an iterator for iterating over each value in a typed array.\n*\n* @name values\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0 ] );\n*\n* var iter = arr.values();\n*\n* var v = iter.next().value;\n* // returns 0.0\n*\n* v = iter.next().value;\n* // returns 1.0\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'values', function values() {\n\tvar iter;\n\tvar self;\n\tvar len;\n\tvar FLG;\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tself = this;\n\tbuf = this._buffer;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': fromWord( buf[ i ] ),\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.values();\n\t}\n});\n\n/**\n* Returns a new typed array with the element at a provided index replaced with a provided value.\n*\n* @name with\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} index - element index\n* @param {number} value - new value\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be an integer\n* @throws {RangeError} index argument is out-of-bounds\n* @throws {TypeError} second argument must be a floating-point number\n* @returns {Float16Array} new typed array\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var out = arr.with( 0, 3.0 );\n* // returns \n*\n* var v = out[ 0 ];\n* // returns 3.0\n*/\nsetReadOnly( Float16Array.prototype, 'with', function copyWith( index, value ) {\n\tvar out;\n\tvar len;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isInteger( index ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', index ) );\n\t}\n\tlen = this._length;\n\tif ( index < 0 ) {\n\t\tindex += len;\n\t}\n\tif ( index < 0 || index >= len ) {\n\t\tthrow new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%s`.', index ) );\n\t}\n\tif ( !isNumber( value ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a floating-point number. Value: `%s`.', value ) );\n\t}\n\tout = new this.constructor( this );\n\tout[ index ] = value;\n\treturn out;\n});\n\n\n// EXPORTS //\n\nmodule.exports = Float16Array;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Float16Array === 'function' ) ? Float16Array : void 0; // eslint-disable-line no-undef, stdlib/require-globals\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* 16-bit floating-point number array constructor.\n*\n* @module @stdlib/array-float16\n*\n* @example\n* var Float16Array = require( '@stdlib/array-float16' );\n*\n* var arr = new Float16Array();\n* // returns \n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var Float16Array = require( '@stdlib/array-float16' );\n*\n* var arr = new Float16Array( 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var Float16Array = require( '@stdlib/array-float16' );\n*\n* var arr = new Float16Array( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var Float16Array = require( '@stdlib/array-float16' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float16Array( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 8\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var Float16Array = require( '@stdlib/array-float16' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float16Array( buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 4\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var Float16Array = require( '@stdlib/array-float16' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Float16Array( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\n\n// MODULES //\n\nvar hasFloat16ArraySupport = require( '@stdlib/assert-has-float16array-support' );\nvar polyfill = require( './polyfill' );\nvar builtin = require( './main.js' );\n\n\n// MAIN //\n\nvar ctor;\nif ( hasFloat16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n"], - "mappings": "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", - "names": ["require_from_array", "__commonJSMin", "exports", "module", "f16", "toWord", "fromArray", "buf", "arr", "len", "require_from_iterator", "__commonJSMin", "exports", "module", "f16", "toWord", "fromIterator", "it", "out", "v", "require_from_iterator_map", "__commonJSMin", "exports", "module", "f16", "toWord", "fromIteratorMap", "it", "clbk", "thisArg", "out", "v", "i", "require_polyfill", "__commonJSMin", "exports", "module", "hasIteratorSymbolSupport", "isNonNegativeInteger", "isStringArray", "isCollection", "isArrayBuffer", "isFunction", "isInteger", "isNumber", "isString", "isObject", "isnan", "ITERATOR_SYMBOL", "setReadOnlyAccessor", "setReadOnly", "setReadWriteAccessor", "floor", "format", "Uint16Array", "f16", "toWord", "fromWord", "gcopy", "fromArray", "fromIterator", "fromIteratorMap", "BYTES_PER_ELEMENT", "HAS_ITERATOR_SYMBOL", "isFloat16Array", "value", "isFloatingPointArrayConstructor", "Float16Array", "getter", "ctx", "idx", "get", "setter", "set", "byteOffset", "nargs", "buf", "len", "arg", "i", "src", "thisArg", "clbk", "out", "tmp", "args", "target", "start", "self", "iter", "FLG", "next", "end", "factory", "predicate", "v", "fcn", "searchElement", "fromIndex", "separator", "outbuf", "reducer", "initialValue", "acc", "N", "j", "sbuf", "flg", "begin", "outlen", "compareFcn", "defaultCompare", "compare", "a", "b", "x", "y", "offset", "locales", "options", "opts", "loc", "index", "require_main", "__commonJSMin", "exports", "module", "ctor", "hasFloat16ArraySupport", "polyfill", "builtin", "ctor"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index e311742..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,1222 +0,0 @@ - -{{alias}}() - A 16-bit half-precision floating-point number array. - - Returns - ------- - out: Float16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Creates a half-precision floating-point number array having a specified - length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: Float16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - - > var len = arr.length - 5 - - -{{alias}}( typedarray ) - Creates a half-precision floating-point number array from a typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate a half-precision floating-point - number array. - - Returns - ------- - out: Float16Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/float64}}( [ 0.5, 0.5, 0.5 ] ) - - > var arr = new {{alias}}( buf ) - - > var len = arr.length - 3 - - -{{alias}}( obj ) - Creates a half-precision floating-point number array from an array-like - object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a half-precision - floating-point number array. - - Returns - ------- - out: Float16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( [ 0.5, 0.5, 0.5 ] ) - - > var len = arr.length - 3 - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a half-precision floating-point number array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - Returns - ------- - out: Float16Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 8 ); - > var arr1 = new {{alias}}( buf ) - - > var len = arr1.length - 4 - > var arr2 = new {{alias}}( buf, 2 ) - - > len = arr2.length - 3 - > var arr3 = new {{alias}}( buf, 2, 2 ) - - > len = arr3.length - 2 - - -{{alias}}.from( src[, clbk[, thisArg]] ) - Creates a new half-precision floating-point number array from an array-like - object or an iterable. - - A callback function is provided two arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - clbk: Function (optional) - Callback to invoke for each source element. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Float16Array - A typed array. - - Examples - -------- - > function clbkFcn( v ) { return v * 2.0 }; - > var arr = {{alias}}.from( [ 1.0, -1.0 ], clbkFcn ) - - > var len = arr.length - 2 - > var v = arr[ 0 ] - 2.0 - > v = arr[ 1 ] - -2.0 - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new half-precision floating-point number array from a variable - number of arguments. - - Parameters - ---------- - element0: number - Array element. - - element1: number (optional) - Array element. - - elementN: ...number (optional) - Array elements. - - Returns - ------- - out: Float16Array - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( 1.0, -1.0 ) - - > var len = arr.length - 2 - > var v = arr[ 0 ] - 1.0 - > v = arr[ 1 ] - -1.0 - - -{{alias}}.BYTES_PER_ELEMENT - The size of each array element in bytes. - - Examples - -------- - > var nbytes = {{alias}}.BYTES_PER_ELEMENT - 2 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > var str = {{alias}}.name - 'Float16Array' - - -{{alias}}.prototype.buffer - Pointer to the underlying data buffer. - - Examples - -------- - > var arr = new {{alias}}( 2 ) - - > var buf = arr.buffer - - - -{{alias}}.prototype.byteLength - Length of the array in bytes. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - - > var nbytes = arr.byteLength - 10 - - -{{alias}}.prototype.byteOffset - Offset (in bytes) of the array from the start of its underlying ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - - > var offset = arr.byteOffset - 0 - > var buf = new {{alias:@stdlib/array/buffer}}( 20 ); - > arr = new {{alias}}( buf, 10 ) - - > offset = arr.byteOffset - 10 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each array element. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - - > arr.BYTES_PER_ELEMENT - 2 - - -{{alias}}.prototype.length - The number of array elements. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - - > var len = arr.length - 5 - - -{{alias}}.prototype.at( i ) - Returns an array element located at integer position (index) `i`, with - support for both nonnegative and negative integer positions. - - If provided an index outside the array index range, the method returns - `undefined`. - - Parameters - ---------- - i: integer - Element index. - - Returns - ------- - out: float|void - An array element. - - Examples - -------- - > var arr = new {{alias}}( [ 10.0, 20.0, 30.0 ] ) - - > var v = arr.at( 0 ) - 10.0 - > v = arr.at( -1 ) - 30.0 - - -{{alias}}.prototype.copyWithin( target, start[, end] ) - Copies a sequence of elements within the array starting at `start` and - ending at `end` (non-inclusive) to the position starting at `target`. - - Parameters - ---------- - target: integer - Target start index position. - - start: integer - Source start index position. - - end: integer (optional) - Source end index position. Default: out.length. - - Returns - ------- - out: Float16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ) - - > arr.copyWithin( 0, 3 ) - - > var v = arr[ 0 ] - 4.0 - > v = arr[ 1 ] - 5.0 - - -{{alias}}.prototype.entries() - Returns an iterator for iterating over array key-value pairs. - - Returns - ------- - iterator: Iterator - Iterator for iterating over array key-value pairs. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var it = arr.entries(); - > var v = it.next().value - [ 0, 1.0 ] - > v = it.next().value - [ 1, 2.0 ] - > v = it.next().value - [ 2, 3.0 ] - > var bool = it.next().done - true - - -{{alias}}.prototype.every( predicate[, thisArg] ) - Returns a boolean indicating whether all elements in the array pass a test. - - A predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether all elements pass the test. - - Examples - -------- - > function predicate( v ) { return ( v > 0.0 ); }; - > var arr = new {{alias}}( [ 1.0, 2.0 ] ) - - > var bool = arr.every( predicate ) - true - - -{{alias}}.prototype.fill( value[, start[, end]] ) - Returns a modified typed array filled with a fill value. - - Parameters - ---------- - value: number - Fill value. - - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Float16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( 3 ) - - > arr.fill( 2.0 ); - > var v = arr[ 0 ] - 2.0 - > v = arr[ 1 ] - 2.0 - > v = arr[ 2 ] - 2.0 - - -{{alias}}.prototype.filter( predicate[, thisArg] ) - Returns a new array containing the elements of an array which pass a test - implemented by a predicate function. - - A predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - The returned array has the same data type as the host array. - - Parameters - ---------- - predicate: Function - Predicate function which filters array elements. If a predicate function - returns a truthy value, an array element is included in the output - array; otherwise, an array element is not included in the output array. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - out: Float16Array - A new typed array. - - Examples - -------- - > function predicate( v ) { return ( v > 1.0 ); }; - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var out = arr.filter( predicate ) - - > var len = out.length - 2 - > var v = out[ 0 ] - 2.0 - > v = out[ 1 ] - 3.0 - - -{{alias}}.prototype.find( predicate[, thisArg] ) - Returns the first element in an array for which a predicate function - returns a truthy value. - - A predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - out: number|void - Array element or `undefined`. - - Examples - -------- - > function predicate( v ) { return ( v > 1.0 ); }; - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var v = arr.find( predicate ) - 2.0 - - -{{alias}}.prototype.findIndex( predicate[, thisArg] ) - Returns the index of the first element in an array for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - out: integer - Array index or `-1`. - - Examples - -------- - > function predicate( v ) { return ( v > 2.0 ); }; - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var idx = arr.findIndex( predicate ) - 2 - - -{{alias}}.prototype.findLast( predicate[, thisArg] ) - Returns the last element in an array for which a predicate function returns - a truthy value. - - A predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - out: number|void - Array element or `undefined`. - - Examples - -------- - > function predicate( v ) { return ( v > 1.0 ); }; - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var v = arr.findLast( predicate ) - 3.0 - - -{{alias}}.prototype.findLastIndex( predicate[, thisArg] ) - Returns the index of the last element in an array for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - out: integer - Array index or `-1`. - - Examples - -------- - > function predicate( v ) { return ( v > 1.0 ); }; - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var idx = arr.findLastIndex( predicate ) - 2 - - -{{alias}}.prototype.forEach( clbk[, thisArg] ) - Invokes a function once for each array element. - - A callback function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - Parameters - ---------- - clbk: Function - Function to invoke for each array element. - - thisArg: Any (optional) - Execution context. - - Examples - -------- - > var str = '%'; - > function clbk( v ) { str += v.toString() + '%'; }; - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > arr.forEach( clbk ); - > str - '%1%2%3%' - - -{{alias}}.prototype.includes( searchElement[, fromIndex] ) - Returns a boolean indicating whether an array includes a provided value. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index at which to start the search. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - bool: boolean - Boolean indicating whether an array includes a search element. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var bool = arr.includes( 3.0 ) - true - > bool = arr.includes( 3.0, 3 ) - false - - -{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) - Returns the first index at which a given element can be found. - - If method does not find a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index at which to start the search. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - out: integer - Array index or `-1`. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var idx = arr.indexOf( 2.0 ) - 1 - > idx = arr.indexOf( 2.0, 2 ) - -1 - - -{{alias}}.prototype.join( [separator] ) - Returns a new string by concatenating all array elements separated by a - separator string. - - Parameters - ---------- - separator: string (optional) - Separator string. Default: ','. - - Returns - ------- - out: string - Array serialized as a string. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var str = arr.join() - '1,2,3' - > str = arr.join( '|' ) - '1|2|3' - - -{{alias}}.prototype.keys() - Returns an iterator for iterating over each index key in a typed array. - - Returns - ------- - iterator: Iterator - Iterator for iterating over array index keys. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0 ] ) - - > var it = arr.keys(); - > var v = it.next().value - 0 - > v = it.next().value - 1 - > v = it.next().done - true - - -{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) - Returns the last index at which a given element can be found. - - If method does not find a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index at which to start the search. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: out.length-1. - - Returns - ------- - out: integer - Array index or `-1`. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0, 1.0 ] ) - - > var idx = arr.lastIndexOf( 1.0 ) - 3 - > idx = arr.lastIndexOf( 1.0, 2 ) - 0 - - -{{alias}}.prototype.map( clbk[, thisArg] ) - Returns a new array with each element being the result of a provided - callback function. - - A callback function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - The returned array has the same data type as the host array. - - Parameters - ---------- - clbk: Function - Function which maps array elements to elements in the new array. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - out: Float16Array - A new typed array. - - Examples - -------- - > function clbk( v ) { return v * 2.0; }; - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var out = arr.map( clbk ) - - > var v = out[ 0 ] - 2.0 - > v = out[ 1 ] - 4.0 - > v = out[ 2 ] - 6.0 - - -{{alias}}.prototype.reduce( reducerFn[, initialValue] ) - Applies a provided function to each element of the array, in order, passing - in the return value from the calculation on the preceding element and - returning the accumulated result upon completion. - - A reducer function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the first array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the first array element as the first argument and the second array - element as the second argument. - - Parameters - ---------- - reducerFn: Function - Function to apply to each array element. - - initialValue: any (optional) - Initial accumulation value. - - Returns - ------- - out: any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > function reducerFn( acc, v ) { return acc + v; }; - > var v = arr.reduce( reducerFn, 0.0 ) - 6.0 - - -{{alias}}.prototype.reduceRight( reducerFn[, initialValue] ) - Applies a provided function to each element of the array, in reverse order, - passing in the return value from the calculation on the preceding element - and returning the accumulated result upon completion. - - A reducer function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the last array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the last array element as the first argument and the second-to-last - array element as the second argument. - - Parameters - ---------- - reducerFn: Function - Function to apply to each array element. - - initialValue: any (optional) - Initial accumulation value. - - Returns - ------- - out: any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > function reducerFn( acc, v ) { return acc + v; }; - > var v = arr.reduceRight( reducerFn, 0.0 ) - 6.0 - - -{{alias}}.prototype.reverse() - Reverses the array *in-place*. - - This method mutates the array on which the method is invoked. - - Returns - ------- - out: Float16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > arr.reverse(); - > var v = arr[ 0 ] - 3.0 - > v = arr[ 1 ] - 2.0 - > v = arr[ 2 ] - 1.0 - - -{{alias}}.prototype.set( arr[, offset] ) - Sets one or more array elements. - - If provided a single argument, the method sets array elements starting at - position (index) `i = 0`. To set elements starting elsewhere in the array, - provide an offset argument. - - Parameters - ---------- - arr: ArrayLike - Source array containing array values to set. - - offset: integer (optional) - Array index at which to start writing values. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > arr.set( [ 4.0, 5.0 ], 1 ); - > var v = arr[ 0 ] - 1.0 - > v = arr[ 1 ] - 4.0 - > v = arr[ 2 ] - 5.0 - - -{{alias}}.prototype.slice( [start[, end]] ) - Copies a portion of a typed array to a new typed array. - - Parameters - ---------- - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Float16Array - New typed array. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var out = arr.slice( 1 ) - - > var len = out.length - 2 - > var v = out[ 0 ] - 2.0 - > v = out[ 1 ] - 3.0 - - -{{alias}}.prototype.some( predicate[, thisArg] ) - Returns a boolean indicating whether at least one element passes a test. - - A predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether at least one element passes the test. - - Examples - -------- - > function predicate( v ) { return ( v > 2.0 ); }; - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var bool = arr.some( predicate ) - true - - -{{alias}}.prototype.sort( [compareFunction] ) - Sorts an array in-place. - - A comparison function determines the order of the array elements. The - function is provided two arguments: - - - a: first element for comparison. - - b: second element for comparison. - - The function should return a value less than zero if `a` comes before `b`, - a value greater than zero if `a` comes after `b`, and zero if `a` and `b` - are equivalent. - - Parameters - ---------- - compareFunction: Function (optional) - Comparison function. - - Returns - ------- - out: Float16Array - Modified array. - - Examples - -------- - > function compare( a, b ) { return a - b; }; - > var arr = new {{alias}}( [ 2.0, 3.0, 1.0 ] ) - - > arr.sort( compare ); - > var v = arr[ 0 ] - 1.0 - > v = arr[ 1 ] - 2.0 - > v = arr[ 2 ] - 3.0 - - -{{alias}}.prototype.subarray( [begin[, end]] ) - Creates a new typed array view over the same underlying `ArrayBuffer` and - with the same underlying data type as the host array. - - Parameters - ---------- - begin: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Float16Array - New typed array view. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ) - - > var out = arr.subarray( 1, 3 ) - - > var len = out.length - 2 - > var v = out[ 0 ] - 2.0 - > v = out[ 1 ] - 3.0 - - -{{alias}}.prototype.toLocaleString( [locales[, options]] ) - Serializes an array as a locale-specific string. - - Parameters - ---------- - locales: string|Array (optional) - Locale identifier(s). - - options: Object (optional) - An object containing serialization options. - - Returns - ------- - str: string - Local-specific string. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var str = arr.toLocaleString() - '1,2,3' - - -{{alias}}.prototype.toReversed() - Returns a new typed array containing the elements in reversed order. - - Returns - ------- - out: Float16Array - New typed array. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var out = arr.toReversed() - - > var v = out[ 0 ] - 3.0 - > v = out[ 1 ] - 2.0 - > v = out[ 2 ] - 1.0 - - -{{alias}}.prototype.toSorted( [compareFcn] ) - Returns a new typed array containing the elements in sorted order. - - A comparison function determines the order of the array elements. The - function is provided two arguments: - - - a: first element for comparison. - - b: second element for comparison. - - The function should return a value less than zero if `a` comes before `b`, - a value greater than zero if `a` comes after `b`, and zero if `a` and `b` - are equivalent. - - Parameters - ---------- - compareFcn: Function (optional) - Comparison function. - - Returns - ------- - out: Float16Array - New typed array. - - Examples - -------- - > function compare( a, b ) { return a - b; }; - > var arr = new {{alias}}( [ 2.0, 3.0, 1.0 ] ) - - > var out = arr.toSorted( compare ); - > var v = out[ 0 ] - 1.0 - > v = out[ 1 ] - 2.0 - > v = out[ 2 ] - 3.0 - - -{{alias}}.prototype.toString() - Serializes an array as a string. - - Returns - ------- - str: string - String serialization of the array. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var str = arr.toString() - '1,2,3' - - -{{alias}}.prototype.values() - Returns an iterator for iterating over each value in a typed array. - - Returns - ------- - iterator: Iterator - Iterator for iterating over array values. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0 ] ) - - > var it = arr.values(); - > var v = it.next().value - 1.0 - > v = it.next().value - 2.0 - > var bool = it.next().done - true - - -{{alias}}.prototype.with( index, value ) - Returns a new typed array with the element at a provided index replaced with - a provided value. - - Parameters - ---------- - index: integer - Element index. - - value: number - Element value. - - Returns - ------- - out: Float16Array - New typed array. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var out = arr.with( 1, 4.0 ) - - > var v = out[ 1 ] - 4.0 - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 033057e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,129 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2026 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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ArrayBuffer = require( '@stdlib/array-buffer' ); -import Float16Array = require( './index' ); - -/** -* Callback function. -* -* @param v - value -* @returns input value -*/ -function clbk( v: number ): number { - return v; -} - - -// TESTS // - -// The function returns a half-precision floating-point number array... -{ - new Float16Array(); // $ExpectType Float16Array - new Float16Array( 2 ); // $ExpectType Float16Array - new Float16Array( [ 1.0, -1.0 ] ); // $ExpectType Float16Array - - const buf = new ArrayBuffer( 16 ); - new Float16Array( buf ); // $ExpectType Float16Array - new Float16Array( buf, 8 ); // $ExpectType Float16Array - new Float16Array( buf, 8, 2 ); // $ExpectType Float16Array -} - -// The compiler throws an error if the function is provided a first argument that is not a number, typed array, array-like object, or array buffer... -{ - new Float16Array( true ); // $ExpectError - new Float16Array( false ); // $ExpectError - new Float16Array( null ); // $ExpectError - new Float16Array( 'abc' ); // $ExpectError - new Float16Array( {} ); // $ExpectError - new Float16Array( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument that is not a number... -{ - const buf = new ArrayBuffer( 16 ); - new Float16Array( buf, true ); // $ExpectError - new Float16Array( buf, false ); // $ExpectError - new Float16Array( buf, null ); // $ExpectError - new Float16Array( buf, 'abc' ); // $ExpectError - new Float16Array( buf, {} ); // $ExpectError - new Float16Array( buf, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument that is not a number... -{ - const buf = new ArrayBuffer( 16 ); - new Float16Array( buf, 8, true ); // $ExpectError - new Float16Array( buf, 8, false ); // $ExpectError - new Float16Array( buf, 8, null ); // $ExpectError - new Float16Array( buf, 8, 'abc' ); // $ExpectError - new Float16Array( buf, 8, {} ); // $ExpectError - new Float16Array( buf, 8, ( x: number ): number => x ); // $ExpectError -} - -// The `from` method returns a half-precision floating-point number array... -{ - Float16Array.from( [ 1.0, 1.0 ] ); // $ExpectType Float16Array - Float16Array.from( [ 1.0, 1.0 ], ( x: number ): number => x * x ); // $ExpectType Float16Array - Float16Array.from( [ 1.0 ], clbk, {} ); // $ExpectType Float16Array -} - -// The compiler throws an error if the `from` method is provided a first argument which is not array-like or iterable... -{ - Float16Array.from( true ); // $ExpectError - Float16Array.from( false ); // $ExpectError - Float16Array.from( 123 ); // $ExpectError - Float16Array.from( null ); // $ExpectError - Float16Array.from( {} ); // $ExpectError - - Float16Array.from( true, clbk ); // $ExpectError - Float16Array.from( false, clbk ); // $ExpectError - Float16Array.from( 123, clbk ); // $ExpectError - Float16Array.from( null, clbk ); // $ExpectError - Float16Array.from( {}, clbk ); // $ExpectError - - Float16Array.from( true, clbk, {} ); // $ExpectError - Float16Array.from( false, clbk, {} ); // $ExpectError - Float16Array.from( 123, clbk, {} ); // $ExpectError - Float16Array.from( null, clbk, {} ); // $ExpectError - Float16Array.from( {}, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the `from` method is provided a second argument which is not a function with a supported signature... -{ - Float16Array.from( [ 1.0, 1.0 ], true ); // $ExpectError - Float16Array.from( [ 1.0, 1.0 ], false ); // $ExpectError - Float16Array.from( [ 1.0, 1.0 ], 123 ); // $ExpectError - Float16Array.from( [ 1.0, 1.0 ], null ); // $ExpectError - Float16Array.from( [ 1.0, 1.0 ], {} ); // $ExpectError -} - -// The `of` method returns a half-precision floating-point number array... -{ - Float16Array.of( 1.0, 1.0, 1.0, 1.0 ); // $ExpectType Float16Array -} - -// The compiler throws an error if the `of` method is provided arguments that are not numbers... -{ - Float16Array.of( 'abc', 'def' ); // $ExpectError - Float16Array.of( true, false ); // $ExpectError - Float16Array.of( {}, [] ); // $ExpectError - Float16Array.of( null, null ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a5c84ca..0000000 --- a/examples/index.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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'; - -var Uint16Array = require( '@stdlib/array-uint16' ); -var logEach = require( '@stdlib/console-log-each' ); -var Float16Array = require( './../lib' ); - -// Create a half-precision floating-point number array by specifying a length: -var out = new Float16Array( 3 ); -logEach( '%s', out ); - -// Create a half-precision floating-point number array from an array of numbers: -var arr = [ 1.05, 2.05, 3.05 ]; -out = new Float16Array( arr ); -logEach( '%s', out ); - -// Create a half-precision floating-point number array from an array buffer: -arr = new Uint16Array( [ 1000, 2000, 3000, 4000 ] ); -out = new Float16Array( arr.buffer ); -logEach( '%s', out ); - -// Create a half-precision floating-point number array from an array buffer view: -arr = new Uint16Array( [ 1000, 2000, 3000, 4000 ] ); -out = new Float16Array( arr.buffer, 2, 2 ); -logEach( '%s', out ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 001159c..ed52b06 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { Iterator as Iter, IterableIterator, TypedIterator } from '@stdlib/types/iter'; import { ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..16ac68e --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-float16array-support@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.3-esm/index.mjs";import{isPrimitive as n}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.3-esm/index.mjs";import{primitives as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string-array@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.3-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.3-esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.3-esm/index.mjs";import{isPrimitive as h}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.3-esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.3-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-assert-is-nan@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.4-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.3-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@v0.2.4-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint16@v0.2.3-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-float16@v0.1.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float16-base-to-word@v0.1.1-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float16-base-from-word@v0.2.1-esm/index.mjs";import T from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-base-gcopy@v0.2.3-esm/index.mjs";function _(t){var r,n;for(r=[];!(n=t.next()).done;)r.push(b(m(n.value)));return r}var j=g.BYTES_PER_ELEMENT,x=r();function L(t){return"object"==typeof t&&null!==t&&"Float16Array"===t.constructor.name&&t.BYTES_PER_ELEMENT===j}function R(t){return t===A}function O(t,r){return function(){return t._get(r)}}function S(t,r){return function(n){t.set([n],r)}}function A(){var t,r,i,h,l,u;if(r=arguments.length,!(this instanceof A))return 0===r?new A:1===r?new A(arguments[0]):2===r?new A(arguments[0],arguments[1]):new A(arguments[0],arguments[1],arguments[2]);if(0===r)i=new g(0);else if(1===r)if(n(l=arguments[0]))i=new g(l);else if(e(l))L(l)?(i=new g(l.length),T.ndarray(l.length,new g(l.buffer,l.byteOffset,l.length),1,0,i,1,0)):i=function(t,r){var n,i;for(n=r.length,i=0;ii.byteLength-t)throw new RangeError(d("null2G",h*j));i=new g(i,t,h)}}for(y(this,"_buffer",i),y(this,"_length",i.length),u=0;u1){if(!s(i=arguments[1]))throw new TypeError(d("null2H",i));n>2&&(r=arguments[2])}if(e(t)){if(i){for(f=(o=new this(l=t.length))._buffer,u=0;u=this._length))return E(this._buffer[t])})),w(A.prototype,"buffer",(function(){return this._buffer.buffer})),w(A.prototype,"byteLength",(function(){return this._buffer.byteLength})),w(A.prototype,"byteOffset",(function(){return this._buffer.byteOffset})),y(A.prototype,"BYTES_PER_ELEMENT",A.BYTES_PER_ELEMENT),y(A.prototype,"copyWithin",(function(t,r){if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");return 2===arguments.length?this._buffer.copyWithin(t,r):this._buffer.copyWithin(t,r,arguments[2]),this})),y(A.prototype,"entries",(function(){var t,r,n,i,e,o;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");return t=this,i=this._buffer,n=this._length,o=-1,y(r={},"next",(function(){if(o+=1,e||o>=n)return{done:!0};return{value:[o,E(i[o])],done:!1}})),y(r,"return",(function(t){if(e=!0,arguments.length)return{value:t,done:!0};return{done:!0}})),p&&y(r,p,(function(){return t.entries()})),r})),y(A.prototype,"every",(function(t,r){var n,i;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!s(t))throw new TypeError(d("null3c",t));for(n=this._buffer,i=0;i1){if(!f(r))throw new TypeError(d("null7f",r));if(r<0&&(r+=e)<0&&(r=0),arguments.length>2){if(!f(n))throw new TypeError(d("null2z",n));n<0&&(n+=e)<0&&(n=0),n>e&&(n=e)}else n=e}else r=0,n=e;for(s=b(t),o=r;o=0;e--)if(i=E(n[e]),t.call(r,i,e,this))return i})),y(A.prototype,"findLastIndex",(function(t,r){var n,i,e;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!s(t))throw new TypeError(d("null3c",t));for(n=this._buffer,e=this._length-1;e>=0;e--)if(i=E(n[e]),t.call(r,i,e,this))return e;return-1})),y(A.prototype,"forEach",(function(t,r){var n,i;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!s(t))throw new TypeError(d("null3c",t));for(n=this._buffer,i=0;i=this._length))return E(this._buffer[t])})),y(A.prototype,"includes",(function(t,r){var n,i,e;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!h(t))throw new TypeError(d("null49",t));if(arguments.length>1){if(!f(r))throw new TypeError(d("null7f",r));r<0&&(r+=this._length)<0&&(r=0)}else r=0;for(n=this._buffer,e=b(t),i=r;i1){if(!f(r))throw new TypeError(d("null7f",r));r<0&&(r+=this._length)<0&&(r=0)}else r=0;for(n=this._buffer,e=b(t),i=r;i0){if(!l(t))throw new TypeError(d("null3F",t))}else t=",";for(r=this._buffer,n=[],i=0;i=n)return{done:!0};return{value:e,done:!1}})),y(r,"return",(function(t){if(i=!0,arguments.length)return{value:t,done:!0};return{done:!0}})),p&&y(r,p,(function(){return t.keys()})),r})),y(A.prototype,"lastIndexOf",(function(t,r){var n,i,e;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!h(t))throw new TypeError(d("null49",t));if(arguments.length>1){if(!f(r))throw new TypeError(d("null7f",r));r>=this._length?r=this._length-1:r<0&&(r+=this._length)}else r=this._length-1;for(n=this._buffer,e=b(t),i=r;i>=0;i--)if(e===n[i])return i;return-1})),w(A.prototype,"length",(function(){return this._length})),y(A.prototype,"map",(function(t,r){var n,i,e,o;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!s(t))throw new TypeError(d("null3c"),t);for(e=this._buffer,n=(i=new this.constructor(this._length))._buffer,o=0;o1)e=r,o=0;else{if(0===i)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");e=E(n[0]),o=1}for(;o1)e=r,o=i-1;else{if(0===i)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");e=E(n[i-1]),o=i-2}for(;o>=0;o--)e=t(e,E(n[o]),o,this);return e})),y(A.prototype,"reverse",(function(){var t,r,n,i,e,o;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");for(t=this._buffer,n=this._length,i=v(n/2),e=0;e1){if(!n(i=arguments[1]))throw new TypeError(d("null2L",i))}else i=0;if(i+(h=t.length)>this._length)throw new RangeError(d("null03"));if(L(t)?(r=t._buffer,f=!0):(r=t,f=!1),a=o.byteOffset+i*j,r.buffer===o.buffer&&r.byteOffseta){for(s=new g(r.length),l=0;ls&&(r=s)}}for(n=ti)return 1;return 0})),this;if(!s(t))throw new TypeError(d("null3c",t));return r.sort((function(r,n){return t(E(r),E(n))})),this})),y(A.prototype,"subarray",(function(t,r){var n,i,e;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(i=this._buffer,e=this._length,0===arguments.length)t=0,r=e;else{if(!f(t))throw new TypeError(d("null7e",t));if(t<0&&(t+=e)<0&&(t=0),1===arguments.length)r=e;else{if(!f(r))throw new TypeError(d("null7f",r));r<0?(r+=e)<0&&(r=0):r>e&&(r=e)}}return t>=e?(e=0,n=i.byteLength):t>=r?(e=0,n=i.byteOffset+t*j):(e=r-t,n=i.byteOffset+t*j),new this.constructor(i.buffer,n,e<0?0:e)})),y(A.prototype,"toLocaleString",(function(t,r){var n,e,o,s,f;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(0===arguments.length)e=[];else{if(!l(t)&&!i(t))throw new TypeError(d("invalid argument. First argument must be a string or an array of strings. Value: `%s`.",t));e=t}if(arguments.length<2)n={};else{if(!a(r))throw new TypeError(d("null2V",r));n=r}for(s=this._buffer,o=[],f=0;f=n)return{done:!0};return{value:E(e[o]),done:!1}})),y(t,"return",(function(t){if(i=!0,arguments.length)return{value:t,done:!0};return{done:!0}})),p&&y(t,p,(function(){return r.values()})),t})),y(A.prototype,"with",(function(t,r){var n,i;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!f(t))throw new TypeError(d("null7e",t));if(i=this._length,t<0&&(t+=i),t<0||t>=i)throw new RangeError(d("nullFP",t));if(!h(r))throw new TypeError(d("invalid argument. Second argument must be a floating-point number. Value: `%s`.",r));return(n=new this.constructor(this))[t]=r,n}));var P="function"==typeof Float16Array?Float16Array:void 0,F=t()?P:A;export{F as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..d0d8a32 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/polyfill/from_iterator.js","../lib/polyfill/index.js","../lib/polyfill/from_array.js","../lib/polyfill/from_iterator_map.js","../lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport f16 from '@stdlib/number-float64-base-to-float16';\nimport toWord from '@stdlib/number-float16-base-to-word';\n\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @returns {Array} output array\n*/\nfunction fromIterator( it ) {\n\tvar out;\n\tvar v;\n\n\tout = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tout.push( toWord( f16( v.value ) ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIterator;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this, stdlib/jsdoc-typedef-typos, max-lines */\n\n'use strict';\n\n// MODULES //\n\nimport hasIteratorSymbolSupport from '@stdlib/assert-has-iterator-symbol-support';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport { primitives as isStringArray } from '@stdlib/assert-is-string-array';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isFunction from '@stdlib/assert-is-function';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isObject from '@stdlib/assert-is-object';\nimport isnan from '@stdlib/math-base-assert-is-nan';\nimport ITERATOR_SYMBOL from '@stdlib/symbol-iterator';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadWriteAccessor from '@stdlib/utils-define-read-write-accessor';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport Uint16Array from '@stdlib/array-uint16';\nimport f16 from '@stdlib/number-float64-base-to-float16';\nimport toWord from '@stdlib/number-float16-base-to-word';\nimport fromWord from '@stdlib/number-float16-base-from-word';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport fromArray from './from_array.js';\nimport fromIterator from './from_iterator.js';\nimport fromIteratorMap from './from_iterator_map.js';\n\n\n// VARIABLES //\n\nvar BYTES_PER_ELEMENT = Uint16Array.BYTES_PER_ELEMENT;\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\n\n\n// FUNCTIONS //\n\n/**\n* Returns a boolean indicating if a value is a `Float16Array`.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `Float16Array`\n*/\nfunction isFloat16Array( value ) {\n\treturn (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\tvalue.constructor.name === 'Float16Array' &&\n\t\tvalue.BYTES_PER_ELEMENT === BYTES_PER_ELEMENT\n\t);\n}\n\n/**\n* Returns a boolean indicating if a value is a floating-point typed array constructor.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a floating-point typed array constructor\n*/\nfunction isFloatingPointArrayConstructor( value ) { // eslint-disable-line id-length\n\treturn ( value === Float16Array );\n}\n\n/**\n* Returns a getter.\n*\n* @private\n* @param {Float16Array} ctx - typed array instance\n* @param {NonNegativeInteger} idx - element index\n* @returns {Function} getter\n*/\nfunction getter( ctx, idx ) {\n\treturn get;\n\n\t/**\n\t* Returns an array element.\n\t*\n\t* @private\n\t* @returns {(number|void)} array element\n\t*/\n\tfunction get() {\n\t\treturn ctx._get( idx ); // eslint-disable-line no-underscore-dangle\n\t}\n}\n\n/**\n* Returns a setter.\n*\n* @private\n* @param {Float16Array} ctx - typed array instance\n* @param {NonNegativeInteger} idx - element index\n* @returns {Function} setter\n*/\nfunction setter( ctx, idx ) {\n\treturn set;\n\n\t/**\n\t* Sets an array element.\n\t*\n\t* @private\n\t* @param {number} value - value to set\n\t*/\n\tfunction set( value ) {\n\t\tctx.set( [ value ], idx );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* 16-bit floating-point number array constructor.\n*\n* @constructor\n* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable\n* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n* @param {NonNegativeInteger} [length] - view length\n* @throws {RangeError} ArrayBuffer byte length must be a multiple of `2`\n* @throws {TypeError} if provided only a single argument, must provide a valid argument\n* @throws {TypeError} byte offset must be a nonnegative integer\n* @throws {RangeError} byte offset must be a multiple of `2`\n* @throws {TypeError} view length must be a positive multiple of `2`\n* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n* @returns {Float16Array} half-precision floating-point number array\n*\n* @example\n* var arr = new Float16Array();\n* // returns \n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var arr = new Float16Array( 5 );\n* // returns \n*\n* var len = arr.length;\n* // returns 5\n*\n* @example\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 5\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float16Array( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 8\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float16Array( buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 4\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Float16Array( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nfunction Float16Array() {\n\tvar byteOffset;\n\tvar nargs;\n\tvar buf;\n\tvar len;\n\tvar arg;\n\tvar i;\n\n\tnargs = arguments.length;\n\tif ( !(this instanceof Float16Array) ) {\n\t\tif ( nargs === 0 ) {\n\t\t\treturn new Float16Array();\n\t\t}\n\t\tif ( nargs === 1 ) {\n\t\t\treturn new Float16Array( arguments[0] );\n\t\t}\n\t\tif ( nargs === 2 ) {\n\t\t\treturn new Float16Array( arguments[0], arguments[1] );\n\t\t}\n\t\treturn new Float16Array( arguments[0], arguments[1], arguments[2] );\n\t}\n\t// Create the underlying data buffer...\n\tif ( nargs === 0 ) {\n\t\tbuf = new Uint16Array( 0 ); // backward-compatibility\n\t} else if ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\t\tif ( isNonNegativeInteger( arg ) ) {\n\t\t\tbuf = new Uint16Array( arg );\n\t\t} else if ( isCollection( arg ) ) {\n\t\t\tif ( isFloat16Array( arg ) ) {\n\t\t\t\tbuf = new Uint16Array( arg.length );\n\t\t\t\tgcopy.ndarray( arg.length, new Uint16Array( arg.buffer, arg.byteOffset, arg.length ), 1, 0, buf, 1, 0 ); // eslint-disable-line max-len\n\t\t\t} else {\n\t\t\t\tbuf = fromArray( new Uint16Array( arg.length ), arg );\n\t\t\t}\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tif ( !isInteger( arg.byteLength/BYTES_PER_ELEMENT ) ) {\n\t\t\t\tthrow new RangeError( format( 'nullE9', BYTES_PER_ELEMENT, arg.byteLength ) );\n\t\t\t}\n\t\t\tbuf = new Uint16Array( arg );\n\t\t} else if ( isObject( arg ) ) {\n\t\t\tif ( HAS_ITERATOR_SYMBOL === false ) {\n\t\t\t\tthrow new TypeError( format( 'null29', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2A', arg ) );\n\t\t\t}\n\t\t\tbuf = arg[ ITERATOR_SYMBOL ]();\n\t\t\tif ( !isFunction( buf.next ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2A', arg ) );\n\t\t\t}\n\t\t\tbuf = new Uint16Array( fromIterator( buf ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( 'null2A', arg ) );\n\t\t}\n\t} else {\n\t\tbuf = arguments[ 0 ];\n\t\tif ( !isArrayBuffer( buf ) ) {\n\t\t\tthrow new TypeError( format( 'null2B', buf ) );\n\t\t}\n\t\tbyteOffset = arguments[ 1 ];\n\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\tthrow new TypeError( format( 'null2C', byteOffset ) );\n\t\t}\n\t\tif ( !isInteger( byteOffset/BYTES_PER_ELEMENT ) ) {\n\t\t\tthrow new RangeError( format( 'nullEA', BYTES_PER_ELEMENT, byteOffset ) );\n\t\t}\n\t\tif ( nargs === 2 ) {\n\t\t\tlen = buf.byteLength - byteOffset;\n\t\t\tif ( !isInteger( len/BYTES_PER_ELEMENT ) ) {\n\t\t\t\tthrow new RangeError( format( 'null2E', BYTES_PER_ELEMENT, len ) );\n\t\t\t}\n\t\t\tbuf = new Uint16Array( buf, byteOffset );\n\t\t} else {\n\t\t\tlen = arguments[ 2 ];\n\t\t\tif ( !isNonNegativeInteger( len ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2F', len ) );\n\t\t\t}\n\t\t\tif ( (len*BYTES_PER_ELEMENT) > (buf.byteLength-byteOffset) ) {\n\t\t\t\tthrow new RangeError( format( 'null2G', len*BYTES_PER_ELEMENT ) );\n\t\t\t}\n\t\t\tbuf = new Uint16Array( buf, byteOffset, len );\n\t\t}\n\t}\n\tsetReadOnly( this, '_buffer', buf );\n\tsetReadOnly( this, '_length', buf.length );\n\tfor ( i = 0; i < buf.length; i++ ) {\n\t\tsetReadWriteAccessor( this, i, getter( this, i ), setter( this, i ) );\n\t}\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each array element.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Float16Array\n* @readonly\n* @type {PositiveInteger}\n* @default 2\n*\n* @example\n* var nbytes = Float16Array.BYTES_PER_ELEMENT;\n* // returns 2\n*/\nsetReadOnly( Float16Array, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT );\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof Float16Array\n* @readonly\n* @type {string}\n* @default 'Float16Array'\n*\n* @example\n* var str = Float16Array.name;\n* // returns 'Float16Array'\n*/\nsetReadOnly( Float16Array, 'name', 'Float16Array' );\n\n/**\n* Creates a new 16-bit floating-point number array from an array-like object or an iterable.\n*\n* @name from\n* @memberof Float16Array\n* @type {Function}\n* @param {(Collection|Iterable)} src - array-like object or iterable\n* @param {Function} [clbk] - callback to invoke for each source element\n* @param {*} [thisArg] - context\n* @throws {TypeError} `this` context must be a constructor\n* @throws {TypeError} `this` must be a floating-point array\n* @throws {TypeError} first argument must be an array-like object or an iterable\n* @throws {TypeError} second argument must be a function\n* @returns {Float16Array} half-precision floating-point number array\n*\n* @example\n* var arr = Float16Array.from( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* function clbk( v ) {\n* return v * 2.0;\n* }\n*\n* var arr = Float16Array.from( [ 1.0, 2.0 ], clbk );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nsetReadOnly( Float16Array, 'from', function from( src ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar clbk;\n\tvar out;\n\tvar buf;\n\tvar tmp;\n\tvar len;\n\tvar i;\n\tif ( !isFunction( this ) ) {\n\t\tthrow new TypeError( format('null01') );\n\t}\n\tif ( !isFloatingPointArrayConstructor( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point array.' );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs > 1 ) {\n\t\tclbk = arguments[ 1 ];\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'null2H', clbk ) );\n\t\t}\n\t\tif ( nargs > 2 ) {\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( isCollection( src ) ) {\n\t\tif ( clbk ) {\n\t\t\tlen = src.length;\n\t\t\tout = new this( len );\n\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tbuf[ i ] = toWord( f16( clbk.call( thisArg, src[ i ], i ) ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\treturn new this( src );\n\t}\n\tif ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) { // eslint-disable-line max-len\n\t\tbuf = src[ ITERATOR_SYMBOL ]();\n\t\tif ( !isFunction( buf.next ) ) {\n\t\t\tthrow new TypeError( format( 'null2J', src ) );\n\t\t}\n\t\tif ( clbk ) {\n\t\t\ttmp = fromIteratorMap( buf, clbk, thisArg );\n\t\t} else {\n\t\t\ttmp = fromIterator( buf );\n\t\t}\n\t\tif ( tmp instanceof Error ) {\n\t\t\tthrow tmp;\n\t\t}\n\t\tlen = tmp.length;\n\t\tout = new this( len );\n\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tbuf[ i ] = tmp[ i ];\n\t\t}\n\t\treturn out;\n\t}\n\tthrow new TypeError( format( 'null2J', src ) );\n});\n\n/**\n* Creates a new 16-bit floating-point number array from a variable number of arguments.\n*\n* @name of\n* @memberof Float16Array\n* @type {Function}\n* @param {...*} element - array elements\n* @throws {TypeError} `this` context must be a constructor\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Float16Array} half-precision floating-point number array\n*\n* @example\n* var arr = Float16Array.of( 1.0, 1.0, 1.0, 1.0 );\n* // returns \n*\n* var x = arr[ 0 ];\n* // returns 1.0\n*\n* var len = arr.length;\n* // returns 4\n*/\nsetReadOnly( Float16Array, 'of', function of() {\n\tvar args;\n\tvar i;\n\tif ( !isFunction( this ) ) {\n\t\tthrow new TypeError( format('null01') );\n\t}\n\tif ( !isFloatingPointArrayConstructor( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\targs = [];\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\targs.push( arguments[ i ] );\n\t}\n\treturn new this( args );\n});\n\n/**\n* Returns an array element with support for both nonnegative and negative integer indices.\n*\n* @name at\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} must provide an integer\n* @returns {(number|void)} array element\n*\n* @example\n* var arr = new Float16Array( [ 10.0, 20.0, 30.0 ] );\n*\n* var v = arr.at( 0 );\n* // returns 10.0\n*\n* v = arr.at( -1 );\n* // returns 30.0\n*\n* v = arr.at( 100 );\n* // returns undefined\n*/\nsetReadOnly( Float16Array.prototype, 'at', function at( idx ) {\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'null8A', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += this._length;\n\t}\n\tif ( idx < 0 || idx >= this._length ) {\n\t\treturn;\n\t}\n\treturn fromWord( this._buffer[ idx ] );\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name buffer\n* @memberof Float16Array.prototype\n* @readonly\n* @type {ArrayBuffer}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var buf = arr.buffer;\n* // returns \n*/\nsetReadOnlyAccessor( Float16Array.prototype, 'buffer', function get() {\n\treturn this._buffer.buffer;\n});\n\n/**\n* Size (in bytes) of the array.\n*\n* @name byteLength\n* @memberof Float16Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var byteLength = arr.byteLength;\n* // returns 20\n*/\nsetReadOnlyAccessor( Float16Array.prototype, 'byteLength', function get() {\n\treturn this._buffer.byteLength;\n});\n\n/**\n* Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`.\n*\n* @name byteOffset\n* @memberof Float16Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var byteOffset = arr.byteOffset;\n* // returns 0\n*/\nsetReadOnlyAccessor( Float16Array.prototype, 'byteOffset', function get() {\n\treturn this._buffer.byteOffset;\n});\n\n/**\n* Size (in bytes) of each array element.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Float16Array.prototype\n* @readonly\n* @type {PositiveInteger}\n* @default 2\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var nbytes = arr.BYTES_PER_ELEMENT;\n* // returns 2\n*/\nsetReadOnly( Float16Array.prototype, 'BYTES_PER_ELEMENT', Float16Array.BYTES_PER_ELEMENT );\n\n/**\n* Copies a sequence of elements within the array to the position starting at `target`.\n*\n* @name copyWithin\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} target - index at which to start copying elements\n* @param {integer} start - source index at which to copy elements from\n* @param {integer} [end] - source index at which to stop copying elements from\n* @throws {TypeError} `this` must be a floating-point array\n* @returns {Float16Array} modified array\n*\n* @example\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0 ] );\n*\n* // Copy the first two elements to the last two elements:\n* arr.copyWithin( 2, 0, 2 );\n*\n* var v = arr[ 2 ];\n* // returns 1.0\n*\n* v = arr[ 3 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'copyWithin', function copyWithin( target, start ) {\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\t// FIXME: prefer a functional `copyWithin` implementation which addresses lack of universal browser support (e.g., IE11 and Safari) or ensure that typed arrays are polyfilled\n\tif ( arguments.length === 2 ) {\n\t\tthis._buffer.copyWithin( target, start );\n\t} else {\n\t\tthis._buffer.copyWithin( target, start, arguments[2] );\n\t}\n\treturn this;\n});\n\n/**\n* Returns an iterator for iterating over array key-value pairs.\n*\n* @name entries\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] );\n*\n* var it = arr.entries();\n*\n* var v = it.next().value;\n* // returns [ 0, 1.0 ]\n*\n* v = it.next().value;\n* // returns [ 1, 2.0 ]\n*\n* v = it.next().value;\n* // returns [ 2, 3.0 ]\n*\n* var bool = it.next().done;\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'entries', function entries() {\n\tvar self;\n\tvar iter;\n\tvar len;\n\tvar buf;\n\tvar FLG;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tself = this;\n\tbuf = this._buffer;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': [ i, fromWord( buf[ i ] ) ],\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.entries();\n\t}\n});\n\n/**\n* Tests whether all elements in an array pass a test implemented by a predicate function.\n*\n* @name every\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {boolean} boolean indicating whether all elements pass a test\n*\n* @example\n* function predicate( v ) {\n* return v === 0.0;\n* }\n*\n* var arr = new Float16Array( 3 );\n*\n* var bool = arr.every( predicate );\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'every', function every( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( !predicate.call( thisArg, fromWord( buf[ i ] ), i, this ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n});\n\n/**\n* Returns a modified typed array filled with a fill value.\n*\n* @name fill\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {number} value - fill value\n* @param {integer} [start=0] - starting index (inclusive)\n* @param {integer} [end] - ending index (exclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a floating-point number\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be an integer\n* @returns {Float16Array} modified array\n*\n* @example\n* var arr = new Float16Array( 3 );\n*\n* arr.fill( 1.0, 1 );\n*\n* var v = arr[ 0 ];\n* // returns 0.0\n*\n* v = arr[ 1 ];\n* // returns 1.0\n*\n* v = arr[ 2 ];\n* // returns 1.0\n*/\nsetReadOnly( Float16Array.prototype, 'fill', function fill( value, start, end ) {\n\tvar buf;\n\tvar len;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNumber( value ) ) {\n\t\tthrow new TypeError( format( 'null49', value ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( start ) ) {\n\t\t\tthrow new TypeError( format( 'null7f', start ) );\n\t\t}\n\t\tif ( start < 0 ) {\n\t\t\tstart += len;\n\t\t\tif ( start < 0 ) {\n\t\t\t\tstart = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length > 2 ) {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2z', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t} else {\n\t\t\tend = len;\n\t\t}\n\t} else {\n\t\tstart = 0;\n\t\tend = len;\n\t}\n\tv = toWord( value );\n\tfor ( i = start; i < end; i++ ) {\n\t\tbuf[ i ] = v;\n\t}\n\treturn this;\n});\n\n/**\n* Returns a new array containing the elements of an array which pass a test implemented by a predicate function.\n*\n* @name filter\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {Float16Array} floating-point number array\n*\n* @example\n* function predicate( v ) {\n* return ( v === 0.0 );\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] );\n*\n* var out = arr.filter( predicate );\n* // returns \n*\n* var len = out.length;\n* // returns 2\n*\n* var v = out[ 0 ];\n* // returns 0.0\n*\n* v = out[ 1 ];\n* // returns 0.0\n*/\nsetReadOnly( Float16Array.prototype, 'filter', function filter( predicate, thisArg ) {\n\tvar buf;\n\tvar out;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\tout.push( v );\n\t\t}\n\t}\n\treturn new this.constructor( out );\n});\n\n/**\n* Returns the first element in an array for which a predicate function returns a truthy value.\n*\n* @name find\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {(boolean|void)} array element or undefined\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] );\n*\n* var v = arr.find( predicate );\n* // returns 1.0\n*/\nsetReadOnly( Float16Array.prototype, 'find', function find( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn v;\n\t\t}\n\t}\n});\n\n/**\n* Returns the index of the first element in an array for which a predicate function returns a truthy value.\n*\n* @name findIndex\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {integer} index or -1\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var v = arr.findIndex( predicate );\n* // returns 1\n*/\nsetReadOnly( Float16Array.prototype, 'findIndex', function findIndex( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Returns the last element in an array for which a predicate function returns a truthy value.\n*\n* @name findLast\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {(boolean|void)} array element or undefined\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] );\n*\n* var v = arr.findLast( predicate );\n* // returns 1.0\n*/\nsetReadOnly( Float16Array.prototype, 'findLast', function findLast( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = this._length-1; i >= 0; i-- ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn v;\n\t\t}\n\t}\n});\n\n/**\n* Returns the index of the last element in an array for which a predicate function returns a truthy value.\n*\n* @name findLastIndex\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {integer} index or -1\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] );\n*\n* var v = arr.findLastIndex( predicate );\n* // returns 1\n*/\nsetReadOnly( Float16Array.prototype, 'findLastIndex', function findLastIndex( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = this._length-1; i >= 0; i-- ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Invokes a function once for each array element.\n*\n* @name forEach\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} fcn - function to invoke\n* @param {*} [thisArg] - function invocation context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n*\n* @example\n* function log( v, i ) {\n* console.log( '%s: %s', i, v.toString() );\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* arr.forEach( log );\n*/\nsetReadOnly( Float16Array.prototype, 'forEach', function forEach( fcn, thisArg ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( fcn ) ) {\n\t\tthrow new TypeError( format( 'null3c', fcn ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tfcn.call( thisArg, fromWord( buf[ i ] ), i, this );\n\t}\n});\n\n/**\n* Returns an array element.\n*\n* @private\n* @name _get\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {NonNegativeInteger} idx - element index\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} must provide a nonnegative integer\n* @returns {(number|void)} array element\n*/\nsetReadOnly( Float16Array.prototype, '_get', function get( idx ) {\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNonNegativeInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'null2K', idx ) );\n\t}\n\tif ( idx >= this._length ) {\n\t\treturn;\n\t}\n\treturn fromWord( this._buffer[ idx ] );\n});\n\n/**\n* Returns a boolean indicating whether an array includes a provided value.\n*\n* @name includes\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {number} searchElement - search element\n* @param {integer} [fromIndex=0] - starting index (inclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a floating-point number\n* @throws {TypeError} second argument must be an integer\n* @returns {boolean} boolean indicating whether an array includes a value\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] );\n*\n* var bool = arr.includes( 1.0 );\n* // returns true\n*\n* bool = arr.includes( 1.0, 2 );\n* // returns false\n*\n* bool = arr.includes( 5.0 );\n* // returns false\n*/\nsetReadOnly( Float16Array.prototype, 'includes', function includes( searchElement, fromIndex ) {\n\tvar buf;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNumber( searchElement ) ) {\n\t\tthrow new TypeError( format( 'null49', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'null7f', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\tfromIndex = 0;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfromIndex = 0;\n\t}\n\tbuf = this._buffer;\n\tv = toWord( searchElement );\n\tfor ( i = fromIndex; i < this._length; i++ ) {\n\t\tif ( v === buf[ i ] ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n});\n\n/**\n* Returns the first index at which a given element can be found.\n*\n* @name indexOf\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {float16} searchElement - element to find\n* @param {integer} [fromIndex=0] - starting index (inclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a floating-point number\n* @throws {TypeError} second argument must be an integer\n* @returns {integer} index or -1\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] );\n*\n* var idx = arr.indexOf( 2.0 );\n* // returns 2\n*\n* idx = arr.indexOf( 2.0, 3 );\n* // returns -1\n*\n* idx = arr.indexOf( 3.0, 3 );\n* // returns 3\n*/\nsetReadOnly( Float16Array.prototype, 'indexOf', function indexOf( searchElement, fromIndex ) {\n\tvar buf;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNumber( searchElement ) ) {\n\t\tthrow new TypeError( format( 'null49', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'null7f', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\tfromIndex = 0;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfromIndex = 0;\n\t}\n\tbuf = this._buffer;\n\tv = toWord( searchElement );\n\tfor ( i = fromIndex; i < this._length; i++ ) {\n\t\tif ( v === buf[ i ] ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Returns a new string by concatenating all array elements.\n*\n* @name join\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {string} [separator=','] - element separator\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a string\n* @returns {string} string representation\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var str = arr.join();\n* // returns '0,1,2'\n*\n* str = arr.join( '|' );\n* // returns '0|1|2'\n*/\nsetReadOnly( Float16Array.prototype, 'join', function join( separator ) {\n\tvar buf;\n\tvar out;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( arguments.length > 0 ) {\n\t\tif ( !isString( separator ) ) {\n\t\t\tthrow new TypeError( format( 'null3F', separator ) );\n\t\t}\n\t} else {\n\t\tseparator = ',';\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( fromWord( buf[ i ] ) );\n\t}\n\treturn out.join( separator );\n});\n\n/**\n* Returns an iterator for iterating over each index key in a typed array.\n*\n* @name keys\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new Float16Array( [ 1.0, 2.0 ] );\n*\n* var iter = arr.keys();\n*\n* var v = iter.next().value;\n* // returns 0\n*\n* v = iter.next().value;\n* // returns 1\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'keys', function keys() {\n\tvar self;\n\tvar iter;\n\tvar len;\n\tvar FLG;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tself = this;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': i,\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.keys();\n\t}\n});\n\n/**\n* Returns the last index at which a given element can be found.\n*\n* @name lastIndexOf\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {number} searchElement - element to find\n* @param {integer} [fromIndex] - starting index (inclusive)\n* @throws {TypeError} `this` must be a floating-point number\n* @throws {TypeError} first argument must be a numeric value\n* @throws {TypeError} second argument must be an integer\n* @returns {integer} index or -1\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 2.0 ] );\n*\n* var idx = arr.lastIndexOf( 2.0 );\n* // returns 4\n*\n* idx = arr.lastIndexOf( 2.0, 3 );\n* // returns 2\n*\n* idx = arr.lastIndexOf( 4.0, 3 );\n* // returns -1\n*\n* idx = arr.lastIndexOf( 1.0, -3 );\n* // returns 1\n*/\nsetReadOnly( Float16Array.prototype, 'lastIndexOf', function lastIndexOf( searchElement, fromIndex ) {\n\tvar buf;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNumber( searchElement ) ) {\n\t\tthrow new TypeError( format( 'null49', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'null7f', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex >= this._length ) {\n\t\t\tfromIndex = this._length - 1;\n\t\t} else if ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t}\n\t} else {\n\t\tfromIndex = this._length - 1;\n\t}\n\tbuf = this._buffer;\n\tv = toWord( searchElement );\n\tfor ( i = fromIndex; i >= 0; i-- ) {\n\t\tif ( v === buf[ i ] ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Number of array elements.\n*\n* @name length\n* @memberof Float16Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var len = arr.length;\n* // returns 10\n*/\nsetReadOnlyAccessor( Float16Array.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Returns a new array with each element being the result of a provided callback function.\n*\n* @name map\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} fcn - callback function\n* @param {*} [thisArg] - callback function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {Float16Array} new floating-point number array\n*\n* @example\n* function scale( v ) {\n* return v * 2.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var out = arr.map( scale );\n* // returns \n*\n* var z = out[ 0 ];\n* // returns 0.0\n*\n* z = out[ 1 ];\n* // returns 2.0\n*\n* z = out[ 2 ];\n* // returns 4.0\n*/\nsetReadOnly( Float16Array.prototype, 'map', function map( fcn, thisArg ) {\n\tvar outbuf;\n\tvar out;\n\tvar buf;\n\tvar i;\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( fcn ) ) {\n\t\tthrow new TypeError( format('null3c'), fcn );\n\t}\n\tbuf = this._buffer;\n\tout = new this.constructor( this._length );\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\toutbuf[ i ] = toWord( fcn.call( thisArg, fromWord( buf[ i ] ), i, this ) ); // eslint-disable-line max-len\n\t}\n\treturn out;\n});\n\n/**\n* Applies a provided callback function to each element of the array, in order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion.\n*\n* @name reduce\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} reducer - callback function\n* @param {*} [initialValue] - initial value\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {Error} if not provided an initial value, the array must have at least one element\n* @returns {*} accumulated result\n*\n* @example\n* function add( acc, v ) {\n* return acc + v;\n* }\n*\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] );\n*\n* var out = arr.reduce( add, 0 );\n* // returns 6.0\n*/\nsetReadOnly( Float16Array.prototype, 'reduce', function reduce( reducer, initialValue ) {\n\tvar buf;\n\tvar len;\n\tvar acc;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( reducer ) ) {\n\t\tthrow new TypeError( format( 'null3c', reducer ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tacc = initialValue;\n\t\ti = 0;\n\t} else {\n\t\tif ( len === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' );\n\t\t}\n\t\tacc = fromWord( buf[ 0 ] );\n\t\ti = 1;\n\t}\n\tfor ( ; i < len; i++ ) {\n\t\tacc = reducer( acc, fromWord( buf[ i ] ), i, this );\n\t}\n\treturn acc;\n});\n\n/**\n* Applies a provided callback function to each element of the array, in reverse order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion.\n*\n* @name reduceRight\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} reducer - callback function\n* @param {*} [initialValue] - initial value\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {Error} if not provided an initial value, the array must have at least one element\n* @returns {*} accumulated result\n*\n* @example\n* function add( acc, v ) {\n* return acc + v;\n* }\n*\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] );\n*\n* var out = arr.reduceRight( add, 0 );\n* // returns 6.0\n*/\nsetReadOnly( Float16Array.prototype, 'reduceRight', function reduceRight( reducer, initialValue ) {\n\tvar buf;\n\tvar len;\n\tvar acc;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( reducer ) ) {\n\t\tthrow new TypeError( format( 'null3c', reducer ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tacc = initialValue;\n\t\ti = len - 1;\n\t} else {\n\t\tif ( len === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' );\n\t\t}\n\t\tacc = fromWord( buf[ len-1 ] );\n\t\ti = len - 2;\n\t}\n\tfor ( ; i >= 0; i-- ) {\n\t\tacc = reducer( acc, fromWord( buf[ i ] ), i, this );\n\t}\n\treturn acc;\n});\n\n/**\n* Reverses an array in-place.\n*\n* @name reverse\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Float16Array} reversed array\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var out = arr.reverse();\n* // returns \n*\n* var v = out[ 0 ];\n* // returns 2.0\n*\n* v = out[ 1 ];\n* // returns 1.0\n*\n* v = out[ 2 ];\n* // returns 0.0\n*/\nsetReadOnly( Float16Array.prototype, 'reverse', function reverse() {\n\tvar buf;\n\tvar tmp;\n\tvar len;\n\tvar N;\n\tvar i;\n\tvar j;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tN = floor( len / 2 );\n\tfor ( i = 0; i < N; i++ ) {\n\t\tj = len - i - 1;\n\t\ttmp = buf[ i ];\n\t\tbuf[ i ] = buf[ j ];\n\t\tbuf[ j ] = tmp;\n\t}\n\treturn this;\n});\n\n/**\n* Sets one or more array elements.\n*\n* ## Notes\n*\n* - When provided a typed array, we must check whether the source array shares the same buffer as the target array and whether the underlying memory overlaps. In particular, we are concerned with the following scenario:\n*\n* ```text\n* buf: ---------------------\n* src: ---------------------\n* ```\n*\n* In the above, as we copy values from `src`, we will overwrite values in the `src` view, resulting in duplicated values copied into the end of `buf`, which is not intended. Hence, to avoid overwriting source values, we must **copy** source values to a temporary array.\n*\n* In the other overlapping scenario,\n*\n* ```text\n* buf: ---------------------\n* src: ---------------------\n* ```\n*\n* by the time we begin copying into the overlapping region, we are copying from the end of `src`, a non-overlapping region, which means we don't run the risk of copying copied values, rather than the original `src` values, as intended.\n*\n* @name set\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {(Collection|Float16Array)} value - value(s)\n* @param {NonNegativeInteger} [i=0] - element index at which to start writing values\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a collection\n* @throws {TypeError} index argument must be a nonnegative integer\n* @throws {RangeError} index argument is out-of-bounds\n* @throws {RangeError} target array lacks sufficient storage to accommodate source values\n* @returns {void}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var v = arr[ 0 ];\n* // returns 0.0\n*\n* arr.set( [ 1.0, 2.0 ], 0 );\n*\n* v = arr[ 0 ];\n* // returns 1.0\n*/\nsetReadOnly( Float16Array.prototype, 'set', function set( value ) {\n\tvar sbuf;\n\tvar idx;\n\tvar buf;\n\tvar tmp;\n\tvar flg;\n\tvar N;\n\tvar i;\n\tvar j;\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isCollection( value ) ) {\n\t\tthrow new TypeError( format( 'null2O', value ) );\n\t}\n\tbuf = this._buffer;\n\tif ( arguments.length > 1 ) {\n\t\tidx = arguments[ 1 ];\n\t\tif ( !isNonNegativeInteger( idx ) ) {\n\t\t\tthrow new TypeError( format( 'null2L', idx ) );\n\t\t}\n\t} else {\n\t\tidx = 0;\n\t}\n\tN = value.length;\n\tif ( idx+N > this._length ) {\n\t\tthrow new RangeError( format('null03') );\n\t}\n\tif ( isFloat16Array( value ) ) {\n\t\tsbuf = value._buffer; // eslint-disable-line no-underscore-dangle\n\t\tflg = true;\n\t} else {\n\t\tsbuf = value;\n\t\tflg = false;\n\t}\n\t// Check for overlapping memory...\n\tj = buf.byteOffset + (idx*BYTES_PER_ELEMENT);\n\tif (\n\t\tsbuf.buffer === buf.buffer &&\n\t\t(\n\t\t\tsbuf.byteOffset < j &&\n\t\t\tsbuf.byteOffset+sbuf.byteLength > j\n\t\t)\n\t) {\n\t\t// We need to copy source values...\n\t\ttmp = new Uint16Array( sbuf.length );\n\t\tfor ( i = 0; i < sbuf.length; i++ ) {\n\t\t\ttmp[ i ] = sbuf[ i ];\n\t\t}\n\t\tsbuf = tmp;\n\t}\n\tif ( flg ) {\n\t\tfor ( i = 0; i < N; idx++, i++ ) {\n\t\t\tbuf[ idx ] = sbuf[ i ];\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < N; idx++, i++ ) {\n\t\t\tbuf[ idx ] = toWord( sbuf[ i ] );\n\t\t}\n\t}\n});\n\n/**\n* Copies a portion of a typed array to a new typed array.\n*\n* @name slice\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} [begin] - start index (inclusive)\n* @param {integer} [end] - end index (exclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be integer\n* @throws {TypeError} second argument must be integer\n* @returns {Float16Array} floating-point number array\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] );\n*\n* var out = arr.slice();\n* // returns \n*\n* var len = out.length;\n* // returns 5\n*\n* var v = out[ 0 ];\n* // returns 0.0\n*\n* v = out[ len-1 ];\n* // returns 4.0\n*\n* out = arr.slice( 1, -2 );\n* // returns \n*\n* len = out.length;\n* // returns 2\n*\n* v = out[ 0 ];\n* // returns 1.0\n*\n* v = out[ len-1 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'slice', function slice( begin, end ) {\n\tvar outlen;\n\tvar outbuf;\n\tvar out;\n\tvar buf;\n\tvar len;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length === 0 ) {\n\t\tbegin = 0;\n\t\tend = len;\n\t} else {\n\t\tif ( !isInteger( begin ) ) {\n\t\t\tthrow new TypeError( format( 'null7e', begin ) );\n\t\t}\n\t\tif ( begin < 0 ) {\n\t\t\tbegin += len;\n\t\t\tif ( begin < 0 ) {\n\t\t\t\tbegin = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\tend = len;\n\t\t} else {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'null7f', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t} else if ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t}\n\t}\n\tif ( begin < end ) {\n\t\toutlen = end - begin;\n\t} else {\n\t\toutlen = 0;\n\t}\n\tout = new this.constructor( outlen );\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < outlen; i++ ) {\n\t\toutbuf[ i ] = buf[ i+begin ];\n\t}\n\treturn out;\n});\n\n/**\n* Tests whether at least one element in an array passes a test implemented by a predicate function.\n*\n* @name some\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {boolean} boolean indicating whether at least one element passes a test\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var bool = arr.some( predicate );\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'some', function some( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( predicate.call( thisArg, fromWord( buf[ i ] ), i, this ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n});\n\n/**\n* Sorts an array in-place.\n*\n* @name sort\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} [compareFcn] - comparison function\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {Float16Array} sorted array\n*\n* @example\n* function compare( a, b ) {\n* if ( a < b ) {\n* return -1;\n* }\n* if ( a > b ) {\n* return 1;\n* }\n* return 0;\n* }\n*\n* var arr = new Float16Array( [ 1.0, 0.0, 2.0 ] );\n*\n* arr.sort( compare );\n*\n* var v = arr[ 0 ];\n* // returns 0.0\n*\n* v = arr[ 1 ];\n* // returns 1.0\n*\n* v = arr[ 2 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'sort', function sort( compareFcn ) {\n\tvar buf;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tif ( arguments.length === 0 ) {\n\t\tbuf.sort( defaultCompare );\n\t\treturn this;\n\t}\n\tif ( !isFunction( compareFcn ) ) {\n\t\tthrow new TypeError( format( 'null3c', compareFcn ) );\n\t}\n\tbuf.sort( compare );\n\treturn this;\n\n\t/**\n\t* Default comparison function for float16 values.\n\t*\n\t* @private\n\t* @param {unsigned16} a - unsigned 16-bit integer for comparison\n\t* @param {unsigned16} b - unsigned 16-bit integer for comparison\n\t* @returns {number} comparison result\n\t*/\n\tfunction defaultCompare( a, b ) { // eslint-disable-line stdlib/no-unnecessary-nested-functions\n\t\tvar x = fromWord( a );\n\t\tvar y = fromWord( b );\n\n\t\t// Handle NaN...\n\t\tif ( isnan( x ) && isnan( y ) ) {\n\t\t\treturn 0;\n\t\t}\n\t\tif ( isnan( x ) ) {\n\t\t\treturn 1;\n\t\t}\n\t\tif ( isnan( y ) ) {\n\t\t\treturn -1;\n\t\t}\n\t\t// Normal comparison\n\t\tif ( x < y ) {\n\t\t\treturn -1;\n\t\t}\n\t\tif ( x > y ) {\n\t\t\treturn 1;\n\t\t}\n\t\treturn 0;\n\t}\n\n\t/**\n\t* Comparison function wrapper.\n\t*\n\t* @private\n\t* @param {unsigned16} a - unsigned 16-bit integer for comparison\n\t* @param {unsigned16} b - unsigned 16-bit integer for comparison\n\t* @returns {number} comparison result\n\t*/\n\tfunction compare( a, b ) {\n\t\treturn compareFcn( fromWord( a ), fromWord( b ) );\n\t}\n});\n\n/**\n* Creates a new typed array view over the same underlying `ArrayBuffer` and with the same underlying data type as the host array.\n*\n* @name subarray\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} [begin] - start index (inclusive)\n* @param {integer} [end] - end index (exclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be an integer\n* @throws {TypeError} second argument must be an integer\n* @returns {Float16Array} subarray\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] );\n*\n* var subarr = arr.subarray();\n* // returns \n*\n* var len = subarr.length;\n* // returns 5\n*\n* var bool = subarr[ 0 ];\n* // returns 0.0\n*\n* bool = subarr[ len-1 ];\n* // returns 4.0\n*\n* subarr = arr.subarray( 1, -2 );\n* // returns \n*\n* len = subarr.length;\n* // returns 2\n*\n* bool = subarr[ 0 ];\n* // returns 1.0\n*\n* bool = subarr[ len-1 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'subarray', function subarray( begin, end ) {\n\tvar offset;\n\tvar buf;\n\tvar len;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length === 0 ) {\n\t\tbegin = 0;\n\t\tend = len;\n\t} else {\n\t\tif ( !isInteger( begin ) ) {\n\t\t\tthrow new TypeError( format( 'null7e', begin ) );\n\t\t}\n\t\tif ( begin < 0 ) {\n\t\t\tbegin += len;\n\t\t\tif ( begin < 0 ) {\n\t\t\t\tbegin = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\tend = len;\n\t\t} else {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'null7f', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t} else if ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t}\n\t}\n\tif ( begin >= len ) {\n\t\tlen = 0;\n\t\toffset = buf.byteLength;\n\t} else if ( begin >= end ) {\n\t\tlen = 0;\n\t\toffset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT );\n\t} else {\n\t\tlen = end - begin;\n\t\toffset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT );\n\t}\n\treturn new this.constructor( buf.buffer, offset, ( len < 0 ) ? 0 : len );\n});\n\n/**\n* Serializes an array as a locale-specific string.\n*\n* @name toLocaleString\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {(string|Array)} [locales] - locale identifier(s)\n* @param {Object} [options] - configuration options\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a string or an array of strings\n* @throws {TypeError} options argument must be an object\n* @returns {string} string representation\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var str = arr.toLocaleString();\n* // returns '0,1,2'\n*/\nsetReadOnly( Float16Array.prototype, 'toLocaleString', function toLocaleString( locales, options ) {\n\tvar opts;\n\tvar loc;\n\tvar out;\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( arguments.length === 0 ) {\n\t\tloc = [];\n\t} else if ( isString( locales ) || isStringArray( locales ) ) {\n\t\tloc = locales;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a string or an array of strings. Value: `%s`.', locales ) );\n\t}\n\tif ( arguments.length < 2 ) {\n\t\topts = {};\n\t} else if ( isObject( options ) ) {\n\t\topts = options;\n\t} else {\n\t\tthrow new TypeError( format( 'null2V', options ) );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( fromWord( buf[ i ] ) );\n\t}\n\treturn out.toLocaleString( loc, opts );\n});\n\n/**\n* Returns a new typed array containing the elements in reversed order.\n*\n* @name toReversed\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Float16Array} reversed array\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var out = arr.toReversed();\n* // returns \n*\n* var v = out[ 0 ];\n* // returns 2.0\n*\n* v = out[ 1 ];\n* // returns 1.0\n*\n* v = out[ 2 ];\n* // returns 0.0\n*/\nsetReadOnly( Float16Array.prototype, 'toReversed', function toReversed() {\n\tvar outbuf;\n\tvar out;\n\tvar len;\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tlen = this._length;\n\tout = new this.constructor( len );\n\tbuf = this._buffer;\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < len; i++ ) {\n\t\toutbuf[ i ] = buf[ len - i - 1 ];\n\t}\n\treturn out;\n});\n\n/**\n* Returns a new typed array containing the elements in sorted order.\n*\n* @name toSorted\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} [compareFcn] - comparison function\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {Float16Array} sorted array\n*\n* @example\n* function compare( a, b ) {\n* if ( a > b ) {\n* return 1;\n* }\n* if ( a < b ) {\n* return -1;\n* }\n* return 0;\n* }\n*\n* var arr = new Float16Array( [ 2.0, 0.0, 1.0 ] );\n*\n* var out = arr.toSorted( compare );\n* // returns \n*\n* var v = out[ 0 ];\n* // returns 0.0\n*\n* v = out[ 1 ];\n* // returns 1.0\n*\n* v = out[ 2 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'toSorted', function toSorted( compareFcn ) {\n\tvar out;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tout = new this.constructor( this );\n\tif ( arguments.length === 0 ) {\n\t\treturn out.sort();\n\t}\n\treturn out.sort( compareFcn );\n});\n\n/**\n* Serializes an array as a string.\n*\n* @name toString\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {string} string representation\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var str = arr.toString();\n* // returns '0,1,2'\n*/\nsetReadOnly( Float16Array.prototype, 'toString', function toString() {\n\tvar out;\n\tvar buf;\n\tvar i;\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( fromWord( buf[ i ] ) );\n\t}\n\treturn out.join( ',' );\n});\n\n/**\n* Returns an iterator for iterating over each value in a typed array.\n*\n* @name values\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0 ] );\n*\n* var iter = arr.values();\n*\n* var v = iter.next().value;\n* // returns 0.0\n*\n* v = iter.next().value;\n* // returns 1.0\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'values', function values() {\n\tvar iter;\n\tvar self;\n\tvar len;\n\tvar FLG;\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tself = this;\n\tbuf = this._buffer;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': fromWord( buf[ i ] ),\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.values();\n\t}\n});\n\n/**\n* Returns a new typed array with the element at a provided index replaced with a provided value.\n*\n* @name with\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} index - element index\n* @param {number} value - new value\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be an integer\n* @throws {RangeError} index argument is out-of-bounds\n* @throws {TypeError} second argument must be a floating-point number\n* @returns {Float16Array} new typed array\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var out = arr.with( 0, 3.0 );\n* // returns \n*\n* var v = out[ 0 ];\n* // returns 3.0\n*/\nsetReadOnly( Float16Array.prototype, 'with', function copyWith( index, value ) {\n\tvar out;\n\tvar len;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isInteger( index ) ) {\n\t\tthrow new TypeError( format( 'null7e', index ) );\n\t}\n\tlen = this._length;\n\tif ( index < 0 ) {\n\t\tindex += len;\n\t}\n\tif ( index < 0 || index >= len ) {\n\t\tthrow new RangeError( format( 'nullFP', index ) );\n\t}\n\tif ( !isNumber( value ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a floating-point number. Value: `%s`.', value ) );\n\t}\n\tout = new this.constructor( this );\n\tout[ index ] = value;\n\treturn out;\n});\n\n\n// EXPORTS //\n\nexport default Float16Array;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport f16 from '@stdlib/number-float64-base-to-float16';\nimport toWord from '@stdlib/number-float16-base-to-word';\n\n\n// MAIN //\n\n/**\n* Fills an output array with unsigned 16-bit integers corresponding to the IEEE 754 binary representation of respective half-precision floating-point numbers.\n*\n* @private\n* @param {Uint16Array} buf - output array\n* @param {Array} arr - input array\n* @returns {Uint16Array} output array\n*/\nfunction fromArray( buf, arr ) {\n\tvar len;\n\tvar i;\n\n\tlen = arr.length;\n\tfor ( i = 0; i < len; i++ ) {\n\t\tbuf[ i ] = toWord( f16( arr[ i ] ) );\n\t}\n\treturn buf;\n}\n\n\n// EXPORTS //\n\nexport default fromArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport f16 from '@stdlib/number-float64-base-to-float16';\nimport toWord from '@stdlib/number-float16-base-to-word';\n\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @param {Function} clbk - callback to invoke for each iterated value\n* @param {*} thisArg - invocation context\n* @returns {Array} output array\n*/\nfunction fromIteratorMap( it, clbk, thisArg ) {\n\tvar out;\n\tvar v;\n\tvar i;\n\n\tout = [];\n\ti = -1;\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\ti += 1;\n\t\tout.push( toWord( f16( clbk.call( thisArg, v.value, i ) ) ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIteratorMap;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Float16Array === 'function' ) ? Float16Array : void 0; // eslint-disable-line no-undef, stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* 16-bit floating-point number array constructor.\n*\n* @module @stdlib/array-float16\n*\n* @example\n* import Float16Array from '@stdlib/array-float16';\n*\n* var arr = new Float16Array();\n* // returns \n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* import Float16Array from '@stdlib/array-float16';\n*\n* var arr = new Float16Array( 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import Float16Array from '@stdlib/array-float16';\n*\n* var arr = new Float16Array( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n* import Float16Array from '@stdlib/array-float16';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float16Array( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 8\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n* import Float16Array from '@stdlib/array-float16';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float16Array( buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 4\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n* import Float16Array from '@stdlib/array-float16';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Float16Array( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\n\n// MODULES //\n\nimport hasFloat16ArraySupport from '@stdlib/assert-has-float16array-support';\nimport polyfill from './polyfill';\nimport builtin from './main.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasFloat16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n"],"names":["fromIterator","it","out","v","next","done","push","toWord","f16","value","BYTES_PER_ELEMENT","Uint16Array","HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","isFloat16Array","constructor","name","isFloatingPointArrayConstructor","Float16Array","getter","ctx","idx","_get","setter","set","byteOffset","nargs","buf","len","arg","i","arguments","length","this","isNonNegativeInteger","isCollection","gcopy","ndarray","buffer","arr","fromArray","isArrayBuffer","isInteger","byteLength","RangeError","format","isObject","TypeError","isFunction","ITERATOR_SYMBOL","setReadOnly","setReadWriteAccessor","src","thisArg","clbk","tmp","_buffer","call","fromIteratorMap","Error","args","prototype","_length","fromWord","setReadOnlyAccessor","target","start","copyWithin","self","iter","FLG","entries","predicate","end","isNumber","fcn","searchElement","fromIndex","separator","isString","join","keys","outbuf","reducer","initialValue","acc","N","j","floor","sbuf","flg","begin","outlen","compareFcn","sort","a","b","x","y","isnan","offset","locales","options","opts","loc","isStringArray","toLocaleString","values","index","ctor","ctor$1","hasFloat16ArraySupport","builtin","polyfill"],"mappings":"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"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 662979c..0000000 --- a/lib/index.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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'; - -/** -* 16-bit floating-point number array constructor. -* -* @module @stdlib/array-float16 -* -* @example -* var Float16Array = require( '@stdlib/array-float16' ); -* -* var arr = new Float16Array(); -* // returns -* -* var len = arr.length; -* // returns 0 -* -* @example -* var Float16Array = require( '@stdlib/array-float16' ); -* -* var arr = new Float16Array( 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var Float16Array = require( '@stdlib/array-float16' ); -* -* var arr = new Float16Array( [ 1.0, 2.0 ] ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var Float16Array = require( '@stdlib/array-float16' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float16Array( buf ); -* // returns -* -* var len = arr.length; -* // returns 8 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var Float16Array = require( '@stdlib/array-float16' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float16Array( buf, 8 ); -* // returns -* -* var len = arr.length; -* // returns 4 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var Float16Array = require( '@stdlib/array-float16' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = new Float16Array( buf, 8, 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -*/ - -// MODULES // - -var hasFloat16ArraySupport = require( '@stdlib/assert-has-float16array-support' ); -var polyfill = require( './polyfill' ); -var builtin = require( './main.js' ); - - -// MAIN // - -var ctor; -if ( hasFloat16ArraySupport() ) { - ctor = builtin; -} else { - ctor = polyfill; -} - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 90c9924..0000000 --- a/lib/main.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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'; - -// MAIN // - -var ctor = ( typeof Float16Array === 'function' ) ? Float16Array : void 0; // eslint-disable-line no-undef, stdlib/require-globals - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/polyfill/from_array.js b/lib/polyfill/from_array.js deleted file mode 100644 index b5894dc..0000000 --- a/lib/polyfill/from_array.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 f16 = require( '@stdlib/number-float64-base-to-float16' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); - - -// MAIN // - -/** -* Fills an output array with unsigned 16-bit integers corresponding to the IEEE 754 binary representation of respective half-precision floating-point numbers. -* -* @private -* @param {Uint16Array} buf - output array -* @param {Array} arr - input array -* @returns {Uint16Array} output array -*/ -function fromArray( buf, arr ) { - var len; - var i; - - len = arr.length; - for ( i = 0; i < len; i++ ) { - buf[ i ] = toWord( f16( arr[ i ] ) ); - } - return buf; -} - - -// EXPORTS // - -module.exports = fromArray; diff --git a/lib/polyfill/from_iterator.js b/lib/polyfill/from_iterator.js deleted file mode 100644 index 37a2c7c..0000000 --- a/lib/polyfill/from_iterator.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 f16 = require( '@stdlib/number-float64-base-to-float16' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); - - -// MAIN // - -/** -* Returns an array of iterated values. -* -* @private -* @param {Object} it - iterator -* @returns {Array} output array -*/ -function fromIterator( it ) { - var out; - var v; - - out = []; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - out.push( toWord( f16( v.value ) ) ); - } - return out; -} - - -// EXPORTS // - -module.exports = fromIterator; diff --git a/lib/polyfill/from_iterator_map.js b/lib/polyfill/from_iterator_map.js deleted file mode 100644 index 265e59d..0000000 --- a/lib/polyfill/from_iterator_map.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 f16 = require( '@stdlib/number-float64-base-to-float16' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); - - -// MAIN // - -/** -* Returns an array of iterated values. -* -* @private -* @param {Object} it - iterator -* @param {Function} clbk - callback to invoke for each iterated value -* @param {*} thisArg - invocation context -* @returns {Array} output array -*/ -function fromIteratorMap( it, clbk, thisArg ) { - var out; - var v; - var i; - - out = []; - i = -1; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - i += 1; - out.push( toWord( f16( clbk.call( thisArg, v.value, i ) ) ) ); - } - return out; -} - - -// EXPORTS // - -module.exports = fromIteratorMap; diff --git a/lib/polyfill/index.js b/lib/polyfill/index.js deleted file mode 100644 index 063db06..0000000 --- a/lib/polyfill/index.js +++ /dev/null @@ -1,2410 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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. -*/ - -/* eslint-disable no-restricted-syntax, no-invalid-this, stdlib/jsdoc-typedef-typos, max-lines */ - -'use strict'; - -// MODULES // - -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isObject = require( '@stdlib/assert-is-object' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var f16 = require( '@stdlib/number-float64-base-to-float16' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var fromWord = require( '@stdlib/number-float16-base-from-word' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var fromArray = require( './from_array.js' ); -var fromIterator = require( './from_iterator.js' ); -var fromIteratorMap = require( './from_iterator_map.js' ); - - -// VARIABLES // - -var BYTES_PER_ELEMENT = Uint16Array.BYTES_PER_ELEMENT; -var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport(); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating if a value is a `Float16Array`. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating if a value is a `Float16Array` -*/ -function isFloat16Array( value ) { - return ( - typeof value === 'object' && - value !== null && - value.constructor.name === 'Float16Array' && - value.BYTES_PER_ELEMENT === BYTES_PER_ELEMENT - ); -} - -/** -* Returns a boolean indicating if a value is a floating-point typed array constructor. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating if a value is a floating-point typed array constructor -*/ -function isFloatingPointArrayConstructor( value ) { // eslint-disable-line id-length - return ( value === Float16Array ); -} - -/** -* Returns a getter. -* -* @private -* @param {Float16Array} ctx - typed array instance -* @param {NonNegativeInteger} idx - element index -* @returns {Function} getter -*/ -function getter( ctx, idx ) { - return get; - - /** - * Returns an array element. - * - * @private - * @returns {(number|void)} array element - */ - function get() { - return ctx._get( idx ); // eslint-disable-line no-underscore-dangle - } -} - -/** -* Returns a setter. -* -* @private -* @param {Float16Array} ctx - typed array instance -* @param {NonNegativeInteger} idx - element index -* @returns {Function} setter -*/ -function setter( ctx, idx ) { - return set; - - /** - * Sets an array element. - * - * @private - * @param {number} value - value to set - */ - function set( value ) { - ctx.set( [ value ], idx ); - } -} - - -// MAIN // - -/** -* 16-bit floating-point number array constructor. -* -* @constructor -* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable -* @param {NonNegativeInteger} [byteOffset=0] - byte offset -* @param {NonNegativeInteger} [length] - view length -* @throws {RangeError} ArrayBuffer byte length must be a multiple of `2` -* @throws {TypeError} if provided only a single argument, must provide a valid argument -* @throws {TypeError} byte offset must be a nonnegative integer -* @throws {RangeError} byte offset must be a multiple of `2` -* @throws {TypeError} view length must be a positive multiple of `2` -* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements -* @returns {Float16Array} half-precision floating-point number array -* -* @example -* var arr = new Float16Array(); -* // returns -* -* var len = arr.length; -* // returns 0 -* -* @example -* var arr = new Float16Array( 5 ); -* // returns -* -* var len = arr.length; -* // returns 5 -* -* @example -* var arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns -* -* var len = arr.length; -* // returns 5 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float16Array( buf ); -* // returns -* -* var len = arr.length; -* // returns 8 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float16Array( buf, 8 ); -* // returns -* -* var len = arr.length; -* // returns 4 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = new Float16Array( buf, 8, 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -*/ -function Float16Array() { - var byteOffset; - var nargs; - var buf; - var len; - var arg; - var i; - - nargs = arguments.length; - if ( !(this instanceof Float16Array) ) { - if ( nargs === 0 ) { - return new Float16Array(); - } - if ( nargs === 1 ) { - return new Float16Array( arguments[0] ); - } - if ( nargs === 2 ) { - return new Float16Array( arguments[0], arguments[1] ); - } - return new Float16Array( arguments[0], arguments[1], arguments[2] ); - } - // Create the underlying data buffer... - if ( nargs === 0 ) { - buf = new Uint16Array( 0 ); // backward-compatibility - } else if ( nargs === 1 ) { - arg = arguments[ 0 ]; - if ( isNonNegativeInteger( arg ) ) { - buf = new Uint16Array( arg ); - } else if ( isCollection( arg ) ) { - if ( isFloat16Array( arg ) ) { - buf = new Uint16Array( arg.length ); - gcopy.ndarray( arg.length, new Uint16Array( arg.buffer, arg.byteOffset, arg.length ), 1, 0, buf, 1, 0 ); // eslint-disable-line max-len - } else { - buf = fromArray( new Uint16Array( arg.length ), arg ); - } - } else if ( isArrayBuffer( arg ) ) { - if ( !isInteger( arg.byteLength/BYTES_PER_ELEMENT ) ) { - throw new RangeError( format( 'nullE9', BYTES_PER_ELEMENT, arg.byteLength ) ); - } - buf = new Uint16Array( arg ); - } else if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'null29', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'null2A', arg ) ); - } - buf = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( buf.next ) ) { - throw new TypeError( format( 'null2A', arg ) ); - } - buf = new Uint16Array( fromIterator( buf ) ); - } else { - throw new TypeError( format( 'null2A', arg ) ); - } - } else { - buf = arguments[ 0 ]; - if ( !isArrayBuffer( buf ) ) { - throw new TypeError( format( 'null2B', buf ) ); - } - byteOffset = arguments[ 1 ]; - if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'null2C', byteOffset ) ); - } - if ( !isInteger( byteOffset/BYTES_PER_ELEMENT ) ) { - throw new RangeError( format( 'nullEA', BYTES_PER_ELEMENT, byteOffset ) ); - } - if ( nargs === 2 ) { - len = buf.byteLength - byteOffset; - if ( !isInteger( len/BYTES_PER_ELEMENT ) ) { - throw new RangeError( format( 'null2E', BYTES_PER_ELEMENT, len ) ); - } - buf = new Uint16Array( buf, byteOffset ); - } else { - len = arguments[ 2 ]; - if ( !isNonNegativeInteger( len ) ) { - throw new TypeError( format( 'null2F', len ) ); - } - if ( (len*BYTES_PER_ELEMENT) > (buf.byteLength-byteOffset) ) { - throw new RangeError( format( 'null2G', len*BYTES_PER_ELEMENT ) ); - } - buf = new Uint16Array( buf, byteOffset, len ); - } - } - setReadOnly( this, '_buffer', buf ); - setReadOnly( this, '_length', buf.length ); - for ( i = 0; i < buf.length; i++ ) { - setReadWriteAccessor( this, i, getter( this, i ), setter( this, i ) ); - } - return this; -} - -/** -* Size (in bytes) of each array element. -* -* @name BYTES_PER_ELEMENT -* @memberof Float16Array -* @readonly -* @type {PositiveInteger} -* @default 2 -* -* @example -* var nbytes = Float16Array.BYTES_PER_ELEMENT; -* // returns 2 -*/ -setReadOnly( Float16Array, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT ); - -/** -* Constructor name. -* -* @name name -* @memberof Float16Array -* @readonly -* @type {string} -* @default 'Float16Array' -* -* @example -* var str = Float16Array.name; -* // returns 'Float16Array' -*/ -setReadOnly( Float16Array, 'name', 'Float16Array' ); - -/** -* Creates a new 16-bit floating-point number array from an array-like object or an iterable. -* -* @name from -* @memberof Float16Array -* @type {Function} -* @param {(Collection|Iterable)} src - array-like object or iterable -* @param {Function} [clbk] - callback to invoke for each source element -* @param {*} [thisArg] - context -* @throws {TypeError} `this` context must be a constructor -* @throws {TypeError} `this` must be a floating-point array -* @throws {TypeError} first argument must be an array-like object or an iterable -* @throws {TypeError} second argument must be a function -* @returns {Float16Array} half-precision floating-point number array -* -* @example -* var arr = Float16Array.from( [ 1.0, 2.0 ] ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* function clbk( v ) { -* return v * 2.0; -* } -* -* var arr = Float16Array.from( [ 1.0, 2.0 ], clbk ); -* // returns -* -* var len = arr.length; -* // returns 2 -*/ -setReadOnly( Float16Array, 'from', function from( src ) { - var thisArg; - var nargs; - var clbk; - var out; - var buf; - var tmp; - var len; - var i; - if ( !isFunction( this ) ) { - throw new TypeError( format('null01') ); - } - if ( !isFloatingPointArrayConstructor( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point array.' ); - } - nargs = arguments.length; - if ( nargs > 1 ) { - clbk = arguments[ 1 ]; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'null2H', clbk ) ); - } - if ( nargs > 2 ) { - thisArg = arguments[ 2 ]; - } - } - if ( isCollection( src ) ) { - if ( clbk ) { - len = src.length; - out = new this( len ); - buf = out._buffer; // eslint-disable-line no-underscore-dangle - for ( i = 0; i < len; i++ ) { - buf[ i ] = toWord( f16( clbk.call( thisArg, src[ i ], i ) ) ); - } - return out; - } - return new this( src ); - } - if ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) { // eslint-disable-line max-len - buf = src[ ITERATOR_SYMBOL ](); - if ( !isFunction( buf.next ) ) { - throw new TypeError( format( 'null2J', src ) ); - } - if ( clbk ) { - tmp = fromIteratorMap( buf, clbk, thisArg ); - } else { - tmp = fromIterator( buf ); - } - if ( tmp instanceof Error ) { - throw tmp; - } - len = tmp.length; - out = new this( len ); - buf = out._buffer; // eslint-disable-line no-underscore-dangle - for ( i = 0; i < len; i++ ) { - buf[ i ] = tmp[ i ]; - } - return out; - } - throw new TypeError( format( 'null2J', src ) ); -}); - -/** -* Creates a new 16-bit floating-point number array from a variable number of arguments. -* -* @name of -* @memberof Float16Array -* @type {Function} -* @param {...*} element - array elements -* @throws {TypeError} `this` context must be a constructor -* @throws {TypeError} `this` must be a floating-point number array -* @returns {Float16Array} half-precision floating-point number array -* -* @example -* var arr = Float16Array.of( 1.0, 1.0, 1.0, 1.0 ); -* // returns -* -* var x = arr[ 0 ]; -* // returns 1.0 -* -* var len = arr.length; -* // returns 4 -*/ -setReadOnly( Float16Array, 'of', function of() { - var args; - var i; - if ( !isFunction( this ) ) { - throw new TypeError( format('null01') ); - } - if ( !isFloatingPointArrayConstructor( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - args = []; - for ( i = 0; i < arguments.length; i++ ) { - args.push( arguments[ i ] ); - } - return new this( args ); -}); - -/** -* Returns an array element with support for both nonnegative and negative integer indices. -* -* @name at -* @memberof Float16Array.prototype -* @type {Function} -* @param {integer} idx - element index -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} must provide an integer -* @returns {(number|void)} array element -* -* @example -* var arr = new Float16Array( [ 10.0, 20.0, 30.0 ] ); -* -* var v = arr.at( 0 ); -* // returns 10.0 -* -* v = arr.at( -1 ); -* // returns 30.0 -* -* v = arr.at( 100 ); -* // returns undefined -*/ -setReadOnly( Float16Array.prototype, 'at', function at( idx ) { - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isInteger( idx ) ) { - throw new TypeError( format( 'null8A', idx ) ); - } - if ( idx < 0 ) { - idx += this._length; - } - if ( idx < 0 || idx >= this._length ) { - return; - } - return fromWord( this._buffer[ idx ] ); -}); - -/** -* Pointer to the underlying data buffer. -* -* @name buffer -* @memberof Float16Array.prototype -* @readonly -* @type {ArrayBuffer} -* -* @example -* var arr = new Float16Array( 10 ); -* -* var buf = arr.buffer; -* // returns -*/ -setReadOnlyAccessor( Float16Array.prototype, 'buffer', function get() { - return this._buffer.buffer; -}); - -/** -* Size (in bytes) of the array. -* -* @name byteLength -* @memberof Float16Array.prototype -* @readonly -* @type {NonNegativeInteger} -* -* @example -* var arr = new Float16Array( 10 ); -* -* var byteLength = arr.byteLength; -* // returns 20 -*/ -setReadOnlyAccessor( Float16Array.prototype, 'byteLength', function get() { - return this._buffer.byteLength; -}); - -/** -* Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`. -* -* @name byteOffset -* @memberof Float16Array.prototype -* @readonly -* @type {NonNegativeInteger} -* -* @example -* var arr = new Float16Array( 10 ); -* -* var byteOffset = arr.byteOffset; -* // returns 0 -*/ -setReadOnlyAccessor( Float16Array.prototype, 'byteOffset', function get() { - return this._buffer.byteOffset; -}); - -/** -* Size (in bytes) of each array element. -* -* @name BYTES_PER_ELEMENT -* @memberof Float16Array.prototype -* @readonly -* @type {PositiveInteger} -* @default 2 -* -* @example -* var arr = new Float16Array( 10 ); -* -* var nbytes = arr.BYTES_PER_ELEMENT; -* // returns 2 -*/ -setReadOnly( Float16Array.prototype, 'BYTES_PER_ELEMENT', Float16Array.BYTES_PER_ELEMENT ); - -/** -* Copies a sequence of elements within the array to the position starting at `target`. -* -* @name copyWithin -* @memberof Float16Array.prototype -* @type {Function} -* @param {integer} target - index at which to start copying elements -* @param {integer} start - source index at which to copy elements from -* @param {integer} [end] - source index at which to stop copying elements from -* @throws {TypeError} `this` must be a floating-point array -* @returns {Float16Array} modified array -* -* @example -* var arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0 ] ); -* -* // Copy the first two elements to the last two elements: -* arr.copyWithin( 2, 0, 2 ); -* -* var v = arr[ 2 ]; -* // returns 1.0 -* -* v = arr[ 3 ]; -* // returns 2.0 -*/ -setReadOnly( Float16Array.prototype, 'copyWithin', function copyWithin( target, start ) { - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - // FIXME: prefer a functional `copyWithin` implementation which addresses lack of universal browser support (e.g., IE11 and Safari) or ensure that typed arrays are polyfilled - if ( arguments.length === 2 ) { - this._buffer.copyWithin( target, start ); - } else { - this._buffer.copyWithin( target, start, arguments[2] ); - } - return this; -}); - -/** -* Returns an iterator for iterating over array key-value pairs. -* -* @name entries -* @memberof Float16Array.prototype -* @type {Function} -* @throws {TypeError} `this` must be a floating-point number array -* @returns {Iterator} iterator -* -* @example -* var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); -* -* var it = arr.entries(); -* -* var v = it.next().value; -* // returns [ 0, 1.0 ] -* -* v = it.next().value; -* // returns [ 1, 2.0 ] -* -* v = it.next().value; -* // returns [ 2, 3.0 ] -* -* var bool = it.next().done; -* // returns true -*/ -setReadOnly( Float16Array.prototype, 'entries', function entries() { - var self; - var iter; - var len; - var buf; - var FLG; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - self = this; - buf = this._buffer; - len = this._length; - - // Initialize an iteration index: - i = -1; - - // Create an iterator protocol-compliant object: - iter = {}; - setReadOnly( iter, 'next', next ); - setReadOnly( iter, 'return', end ); - - if ( ITERATOR_SYMBOL ) { - setReadOnly( iter, ITERATOR_SYMBOL, factory ); - } - return iter; - - /** - * Returns an iterator protocol-compliant object containing the next iterated value. - * - * @private - * @returns {Object} iterator protocol-compliant object - */ - function next() { - i += 1; - if ( FLG || i >= len ) { - return { - 'done': true - }; - } - return { - 'value': [ i, fromWord( buf[ i ] ) ], - 'done': false - }; - } - - /** - * Finishes an iterator. - * - * @private - * @param {*} [value] - value to return - * @returns {Object} iterator protocol-compliant object - */ - function end( value ) { - FLG = true; - if ( arguments.length ) { - return { - 'value': value, - 'done': true - }; - } - return { - 'done': true - }; - } - - /** - * Returns a new iterator. - * - * @private - * @returns {Iterator} iterator - */ - function factory() { - return self.entries(); - } -}); - -/** -* Tests whether all elements in an array pass a test implemented by a predicate function. -* -* @name every -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - predicate function execution context -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a function -* @returns {boolean} boolean indicating whether all elements pass a test -* -* @example -* function predicate( v ) { -* return v === 0.0; -* } -* -* var arr = new Float16Array( 3 ); -* -* var bool = arr.every( predicate ); -* // returns true -*/ -setReadOnly( Float16Array.prototype, 'every', function every( predicate, thisArg ) { - var buf; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'null3c', predicate ) ); - } - buf = this._buffer; - for ( i = 0; i < this._length; i++ ) { - if ( !predicate.call( thisArg, fromWord( buf[ i ] ), i, this ) ) { - return false; - } - } - return true; -}); - -/** -* Returns a modified typed array filled with a fill value. -* -* @name fill -* @memberof Float16Array.prototype -* @type {Function} -* @param {number} value - fill value -* @param {integer} [start=0] - starting index (inclusive) -* @param {integer} [end] - ending index (exclusive) -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a floating-point number -* @throws {TypeError} second argument must be an integer -* @throws {TypeError} third argument must be an integer -* @returns {Float16Array} modified array -* -* @example -* var arr = new Float16Array( 3 ); -* -* arr.fill( 1.0, 1 ); -* -* var v = arr[ 0 ]; -* // returns 0.0 -* -* v = arr[ 1 ]; -* // returns 1.0 -* -* v = arr[ 2 ]; -* // returns 1.0 -*/ -setReadOnly( Float16Array.prototype, 'fill', function fill( value, start, end ) { - var buf; - var len; - var i; - var v; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isNumber( value ) ) { - throw new TypeError( format( 'null49', value ) ); - } - buf = this._buffer; - len = this._length; - if ( arguments.length > 1 ) { - if ( !isInteger( start ) ) { - throw new TypeError( format( 'null7f', start ) ); - } - if ( start < 0 ) { - start += len; - if ( start < 0 ) { - start = 0; - } - } - if ( arguments.length > 2 ) { - if ( !isInteger( end ) ) { - throw new TypeError( format( 'null2z', end ) ); - } - if ( end < 0 ) { - end += len; - if ( end < 0 ) { - end = 0; - } - } - if ( end > len ) { - end = len; - } - } else { - end = len; - } - } else { - start = 0; - end = len; - } - v = toWord( value ); - for ( i = start; i < end; i++ ) { - buf[ i ] = v; - } - return this; -}); - -/** -* Returns a new array containing the elements of an array which pass a test implemented by a predicate function. -* -* @name filter -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} predicate - test function -* @param {*} [thisArg] - predicate function execution context -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a function -* @returns {Float16Array} floating-point number array -* -* @example -* function predicate( v ) { -* return ( v === 0.0 ); -* } -* -* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] ); -* -* var out = arr.filter( predicate ); -* // returns -* -* var len = out.length; -* // returns 2 -* -* var v = out[ 0 ]; -* // returns 0.0 -* -* v = out[ 1 ]; -* // returns 0.0 -*/ -setReadOnly( Float16Array.prototype, 'filter', function filter( predicate, thisArg ) { - var buf; - var out; - var i; - var v; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'null3c', predicate ) ); - } - buf = this._buffer; - out = []; - for ( i = 0; i < this._length; i++ ) { - v = fromWord( buf[ i ] ); - if ( predicate.call( thisArg, v, i, this ) ) { - out.push( v ); - } - } - return new this.constructor( out ); -}); - -/** -* Returns the first element in an array for which a predicate function returns a truthy value. -* -* @name find -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - predicate function execution context -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a function -* @returns {(boolean|void)} array element or undefined -* -* @example -* function predicate( v ) { -* return v > 0.0; -* } -* -* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] ); -* -* var v = arr.find( predicate ); -* // returns 1.0 -*/ -setReadOnly( Float16Array.prototype, 'find', function find( predicate, thisArg ) { - var buf; - var v; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'null3c', predicate ) ); - } - buf = this._buffer; - for ( i = 0; i < this._length; i++ ) { - v = fromWord( buf[ i ] ); - if ( predicate.call( thisArg, v, i, this ) ) { - return v; - } - } -}); - -/** -* Returns the index of the first element in an array for which a predicate function returns a truthy value. -* -* @name findIndex -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - predicate function execution context -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a function -* @returns {integer} index or -1 -* -* @example -* function predicate( v ) { -* return v > 0.0; -* } -* -* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] ); -* -* var v = arr.findIndex( predicate ); -* // returns 1 -*/ -setReadOnly( Float16Array.prototype, 'findIndex', function findIndex( predicate, thisArg ) { - var buf; - var v; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'null3c', predicate ) ); - } - buf = this._buffer; - for ( i = 0; i < this._length; i++ ) { - v = fromWord( buf[ i ] ); - if ( predicate.call( thisArg, v, i, this ) ) { - return i; - } - } - return -1; -}); - -/** -* Returns the last element in an array for which a predicate function returns a truthy value. -* -* @name findLast -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - predicate function execution context -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a function -* @returns {(boolean|void)} array element or undefined -* -* @example -* function predicate( v ) { -* return v > 0.0; -* } -* -* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] ); -* -* var v = arr.findLast( predicate ); -* // returns 1.0 -*/ -setReadOnly( Float16Array.prototype, 'findLast', function findLast( predicate, thisArg ) { - var buf; - var v; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'null3c', predicate ) ); - } - buf = this._buffer; - for ( i = this._length-1; i >= 0; i-- ) { - v = fromWord( buf[ i ] ); - if ( predicate.call( thisArg, v, i, this ) ) { - return v; - } - } -}); - -/** -* Returns the index of the last element in an array for which a predicate function returns a truthy value. -* -* @name findLastIndex -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - predicate function execution context -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a function -* @returns {integer} index or -1 -* -* @example -* function predicate( v ) { -* return v > 0.0; -* } -* -* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] ); -* -* var v = arr.findLastIndex( predicate ); -* // returns 1 -*/ -setReadOnly( Float16Array.prototype, 'findLastIndex', function findLastIndex( predicate, thisArg ) { - var buf; - var v; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'null3c', predicate ) ); - } - buf = this._buffer; - for ( i = this._length-1; i >= 0; i-- ) { - v = fromWord( buf[ i ] ); - if ( predicate.call( thisArg, v, i, this ) ) { - return i; - } - } - return -1; -}); - -/** -* Invokes a function once for each array element. -* -* @name forEach -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} fcn - function to invoke -* @param {*} [thisArg] - function invocation context -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a function -* -* @example -* function log( v, i ) { -* console.log( '%s: %s', i, v.toString() ); -* } -* -* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] ); -* -* arr.forEach( log ); -*/ -setReadOnly( Float16Array.prototype, 'forEach', function forEach( fcn, thisArg ) { - var buf; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'null3c', fcn ) ); - } - buf = this._buffer; - for ( i = 0; i < this._length; i++ ) { - fcn.call( thisArg, fromWord( buf[ i ] ), i, this ); - } -}); - -/** -* Returns an array element. -* -* @private -* @name _get -* @memberof Float16Array.prototype -* @type {Function} -* @param {NonNegativeInteger} idx - element index -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} must provide a nonnegative integer -* @returns {(number|void)} array element -*/ -setReadOnly( Float16Array.prototype, '_get', function get( idx ) { - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isNonNegativeInteger( idx ) ) { - throw new TypeError( format( 'null2K', idx ) ); - } - if ( idx >= this._length ) { - return; - } - return fromWord( this._buffer[ idx ] ); -}); - -/** -* Returns a boolean indicating whether an array includes a provided value. -* -* @name includes -* @memberof Float16Array.prototype -* @type {Function} -* @param {number} searchElement - search element -* @param {integer} [fromIndex=0] - starting index (inclusive) -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a floating-point number -* @throws {TypeError} second argument must be an integer -* @returns {boolean} boolean indicating whether an array includes a value -* -* @example -* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] ); -* -* var bool = arr.includes( 1.0 ); -* // returns true -* -* bool = arr.includes( 1.0, 2 ); -* // returns false -* -* bool = arr.includes( 5.0 ); -* // returns false -*/ -setReadOnly( Float16Array.prototype, 'includes', function includes( searchElement, fromIndex ) { - var buf; - var i; - var v; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isNumber( searchElement ) ) { - throw new TypeError( format( 'null49', searchElement ) ); - } - if ( arguments.length > 1 ) { - if ( !isInteger( fromIndex ) ) { - throw new TypeError( format( 'null7f', fromIndex ) ); - } - if ( fromIndex < 0 ) { - fromIndex += this._length; - if ( fromIndex < 0 ) { - fromIndex = 0; - } - } - } else { - fromIndex = 0; - } - buf = this._buffer; - v = toWord( searchElement ); - for ( i = fromIndex; i < this._length; i++ ) { - if ( v === buf[ i ] ) { - return true; - } - } - return false; -}); - -/** -* Returns the first index at which a given element can be found. -* -* @name indexOf -* @memberof Float16Array.prototype -* @type {Function} -* @param {float16} searchElement - element to find -* @param {integer} [fromIndex=0] - starting index (inclusive) -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a floating-point number -* @throws {TypeError} second argument must be an integer -* @returns {integer} index or -1 -* -* @example -* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] ); -* -* var idx = arr.indexOf( 2.0 ); -* // returns 2 -* -* idx = arr.indexOf( 2.0, 3 ); -* // returns -1 -* -* idx = arr.indexOf( 3.0, 3 ); -* // returns 3 -*/ -setReadOnly( Float16Array.prototype, 'indexOf', function indexOf( searchElement, fromIndex ) { - var buf; - var i; - var v; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isNumber( searchElement ) ) { - throw new TypeError( format( 'null49', searchElement ) ); - } - if ( arguments.length > 1 ) { - if ( !isInteger( fromIndex ) ) { - throw new TypeError( format( 'null7f', fromIndex ) ); - } - if ( fromIndex < 0 ) { - fromIndex += this._length; - if ( fromIndex < 0 ) { - fromIndex = 0; - } - } - } else { - fromIndex = 0; - } - buf = this._buffer; - v = toWord( searchElement ); - for ( i = fromIndex; i < this._length; i++ ) { - if ( v === buf[ i ] ) { - return i; - } - } - return -1; -}); - -/** -* Returns a new string by concatenating all array elements. -* -* @name join -* @memberof Float16Array.prototype -* @type {Function} -* @param {string} [separator=','] - element separator -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a string -* @returns {string} string representation -* -* @example -* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] ); -* -* var str = arr.join(); -* // returns '0,1,2' -* -* str = arr.join( '|' ); -* // returns '0|1|2' -*/ -setReadOnly( Float16Array.prototype, 'join', function join( separator ) { - var buf; - var out; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( arguments.length > 0 ) { - if ( !isString( separator ) ) { - throw new TypeError( format( 'null3F', separator ) ); - } - } else { - separator = ','; - } - buf = this._buffer; - out = []; - for ( i = 0; i < this._length; i++ ) { - out.push( fromWord( buf[ i ] ) ); - } - return out.join( separator ); -}); - -/** -* Returns an iterator for iterating over each index key in a typed array. -* -* @name keys -* @memberof Float16Array.prototype -* @type {Function} -* @throws {TypeError} `this` must be a floating-point number array -* @returns {Iterator} iterator -* -* @example -* var arr = new Float16Array( [ 1.0, 2.0 ] ); -* -* var iter = arr.keys(); -* -* var v = iter.next().value; -* // returns 0 -* -* v = iter.next().value; -* // returns 1 -* -* var bool = iter.next().done; -* // returns true -*/ -setReadOnly( Float16Array.prototype, 'keys', function keys() { - var self; - var iter; - var len; - var FLG; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - self = this; - len = this._length; - - // Initialize an iteration index: - i = -1; - - // Create an iterator protocol-compliant object: - iter = {}; - setReadOnly( iter, 'next', next ); - setReadOnly( iter, 'return', end ); - - if ( ITERATOR_SYMBOL ) { - setReadOnly( iter, ITERATOR_SYMBOL, factory ); - } - return iter; - - /** - * Returns an iterator protocol-compliant object containing the next iterated value. - * - * @private - * @returns {Object} iterator protocol-compliant object - */ - function next() { - i += 1; - if ( FLG || i >= len ) { - return { - 'done': true - }; - } - return { - 'value': i, - 'done': false - }; - } - - /** - * Finishes an iterator. - * - * @private - * @param {*} [value] - value to return - * @returns {Object} iterator protocol-compliant object - */ - function end( value ) { - FLG = true; - if ( arguments.length ) { - return { - 'value': value, - 'done': true - }; - } - return { - 'done': true - }; - } - - /** - * Returns a new iterator. - * - * @private - * @returns {Iterator} iterator - */ - function factory() { - return self.keys(); - } -}); - -/** -* Returns the last index at which a given element can be found. -* -* @name lastIndexOf -* @memberof Float16Array.prototype -* @type {Function} -* @param {number} searchElement - element to find -* @param {integer} [fromIndex] - starting index (inclusive) -* @throws {TypeError} `this` must be a floating-point number -* @throws {TypeError} first argument must be a numeric value -* @throws {TypeError} second argument must be an integer -* @returns {integer} index or -1 -* -* @example -* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 2.0 ] ); -* -* var idx = arr.lastIndexOf( 2.0 ); -* // returns 4 -* -* idx = arr.lastIndexOf( 2.0, 3 ); -* // returns 2 -* -* idx = arr.lastIndexOf( 4.0, 3 ); -* // returns -1 -* -* idx = arr.lastIndexOf( 1.0, -3 ); -* // returns 1 -*/ -setReadOnly( Float16Array.prototype, 'lastIndexOf', function lastIndexOf( searchElement, fromIndex ) { - var buf; - var i; - var v; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isNumber( searchElement ) ) { - throw new TypeError( format( 'null49', searchElement ) ); - } - if ( arguments.length > 1 ) { - if ( !isInteger( fromIndex ) ) { - throw new TypeError( format( 'null7f', fromIndex ) ); - } - if ( fromIndex >= this._length ) { - fromIndex = this._length - 1; - } else if ( fromIndex < 0 ) { - fromIndex += this._length; - } - } else { - fromIndex = this._length - 1; - } - buf = this._buffer; - v = toWord( searchElement ); - for ( i = fromIndex; i >= 0; i-- ) { - if ( v === buf[ i ] ) { - return i; - } - } - return -1; -}); - -/** -* Number of array elements. -* -* @name length -* @memberof Float16Array.prototype -* @readonly -* @type {NonNegativeInteger} -* -* @example -* var arr = new Float16Array( 10 ); -* -* var len = arr.length; -* // returns 10 -*/ -setReadOnlyAccessor( Float16Array.prototype, 'length', function get() { - return this._length; -}); - -/** -* Returns a new array with each element being the result of a provided callback function. -* -* @name map -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} fcn - callback function -* @param {*} [thisArg] - callback function execution context -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a function -* @returns {Float16Array} new floating-point number array -* -* @example -* function scale( v ) { -* return v * 2.0; -* } -* -* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] ); -* -* var out = arr.map( scale ); -* // returns -* -* var z = out[ 0 ]; -* // returns 0.0 -* -* z = out[ 1 ]; -* // returns 2.0 -* -* z = out[ 2 ]; -* // returns 4.0 -*/ -setReadOnly( Float16Array.prototype, 'map', function map( fcn, thisArg ) { - var outbuf; - var out; - var buf; - var i; - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( format('null3c'), fcn ); - } - buf = this._buffer; - out = new this.constructor( this._length ); - outbuf = out._buffer; // eslint-disable-line no-underscore-dangle - for ( i = 0; i < this._length; i++ ) { - outbuf[ i ] = toWord( fcn.call( thisArg, fromWord( buf[ i ] ), i, this ) ); // eslint-disable-line max-len - } - return out; -}); - -/** -* Applies a provided callback function to each element of the array, in order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion. -* -* @name reduce -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} reducer - callback function -* @param {*} [initialValue] - initial value -* @throws {TypeError} `this` must be a floating-point number array -* @throws {Error} if not provided an initial value, the array must have at least one element -* @returns {*} accumulated result -* -* @example -* function add( acc, v ) { -* return acc + v; -* } -* -* var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); -* -* var out = arr.reduce( add, 0 ); -* // returns 6.0 -*/ -setReadOnly( Float16Array.prototype, 'reduce', function reduce( reducer, initialValue ) { - var buf; - var len; - var acc; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isFunction( reducer ) ) { - throw new TypeError( format( 'null3c', reducer ) ); - } - buf = this._buffer; - len = this._length; - if ( arguments.length > 1 ) { - acc = initialValue; - i = 0; - } else { - if ( len === 0 ) { - throw new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' ); - } - acc = fromWord( buf[ 0 ] ); - i = 1; - } - for ( ; i < len; i++ ) { - acc = reducer( acc, fromWord( buf[ i ] ), i, this ); - } - return acc; -}); - -/** -* Applies a provided callback function to each element of the array, in reverse order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion. -* -* @name reduceRight -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} reducer - callback function -* @param {*} [initialValue] - initial value -* @throws {TypeError} `this` must be a floating-point number array -* @throws {Error} if not provided an initial value, the array must have at least one element -* @returns {*} accumulated result -* -* @example -* function add( acc, v ) { -* return acc + v; -* } -* -* var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); -* -* var out = arr.reduceRight( add, 0 ); -* // returns 6.0 -*/ -setReadOnly( Float16Array.prototype, 'reduceRight', function reduceRight( reducer, initialValue ) { - var buf; - var len; - var acc; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isFunction( reducer ) ) { - throw new TypeError( format( 'null3c', reducer ) ); - } - buf = this._buffer; - len = this._length; - if ( arguments.length > 1 ) { - acc = initialValue; - i = len - 1; - } else { - if ( len === 0 ) { - throw new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' ); - } - acc = fromWord( buf[ len-1 ] ); - i = len - 2; - } - for ( ; i >= 0; i-- ) { - acc = reducer( acc, fromWord( buf[ i ] ), i, this ); - } - return acc; -}); - -/** -* Reverses an array in-place. -* -* @name reverse -* @memberof Float16Array.prototype -* @type {Function} -* @throws {TypeError} `this` must be a floating-point number array -* @returns {Float16Array} reversed array -* -* @example -* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] ); -* -* var out = arr.reverse(); -* // returns -* -* var v = out[ 0 ]; -* // returns 2.0 -* -* v = out[ 1 ]; -* // returns 1.0 -* -* v = out[ 2 ]; -* // returns 0.0 -*/ -setReadOnly( Float16Array.prototype, 'reverse', function reverse() { - var buf; - var tmp; - var len; - var N; - var i; - var j; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number 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 one or more array elements. -* -* ## Notes -* -* - When provided a typed array, we must check whether the source array shares the same buffer as the target array and whether the underlying memory overlaps. In particular, we are concerned with the following scenario: -* -* ```text -* buf: --------------------- -* src: --------------------- -* ``` -* -* In the above, as we copy values from `src`, we will overwrite values in the `src` view, resulting in duplicated values copied into the end of `buf`, which is not intended. Hence, to avoid overwriting source values, we must **copy** source values to a temporary array. -* -* In the other overlapping scenario, -* -* ```text -* buf: --------------------- -* src: --------------------- -* ``` -* -* by the time we begin copying into the overlapping region, we are copying from the end of `src`, a non-overlapping region, which means we don't run the risk of copying copied values, rather than the original `src` values, as intended. -* -* @name set -* @memberof Float16Array.prototype -* @type {Function} -* @param {(Collection|Float16Array)} value - value(s) -* @param {NonNegativeInteger} [i=0] - element index at which to start writing values -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a collection -* @throws {TypeError} index argument must be a nonnegative integer -* @throws {RangeError} index argument is out-of-bounds -* @throws {RangeError} target array lacks sufficient storage to accommodate source values -* @returns {void} -* -* @example -* var arr = new Float16Array( 10 ); -* -* var v = arr[ 0 ]; -* // returns 0.0 -* -* arr.set( [ 1.0, 2.0 ], 0 ); -* -* v = arr[ 0 ]; -* // returns 1.0 -*/ -setReadOnly( Float16Array.prototype, 'set', function set( value ) { - var sbuf; - var idx; - var buf; - var tmp; - var flg; - var N; - var i; - var j; - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isCollection( value ) ) { - throw new TypeError( format( 'null2O', value ) ); - } - buf = this._buffer; - if ( arguments.length > 1 ) { - idx = arguments[ 1 ]; - if ( !isNonNegativeInteger( idx ) ) { - throw new TypeError( format( 'null2L', idx ) ); - } - } else { - idx = 0; - } - N = value.length; - if ( idx+N > this._length ) { - throw new RangeError( format('null03') ); - } - if ( isFloat16Array( value ) ) { - sbuf = value._buffer; // eslint-disable-line no-underscore-dangle - flg = true; - } else { - sbuf = value; - flg = false; - } - // Check for overlapping memory... - j = buf.byteOffset + (idx*BYTES_PER_ELEMENT); - if ( - sbuf.buffer === buf.buffer && - ( - sbuf.byteOffset < j && - sbuf.byteOffset+sbuf.byteLength > j - ) - ) { - // We need to copy source values... - tmp = new Uint16Array( sbuf.length ); - for ( i = 0; i < sbuf.length; i++ ) { - tmp[ i ] = sbuf[ i ]; - } - sbuf = tmp; - } - if ( flg ) { - for ( i = 0; i < N; idx++, i++ ) { - buf[ idx ] = sbuf[ i ]; - } - } else { - for ( i = 0; i < N; idx++, i++ ) { - buf[ idx ] = toWord( sbuf[ i ] ); - } - } -}); - -/** -* Copies a portion of a typed array to a new typed array. -* -* @name slice -* @memberof Float16Array.prototype -* @type {Function} -* @param {integer} [begin] - start index (inclusive) -* @param {integer} [end] - end index (exclusive) -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be integer -* @throws {TypeError} second argument must be integer -* @returns {Float16Array} floating-point number array -* -* @example -* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] ); -* -* var out = arr.slice(); -* // returns -* -* var len = out.length; -* // returns 5 -* -* var v = out[ 0 ]; -* // returns 0.0 -* -* v = out[ len-1 ]; -* // returns 4.0 -* -* out = arr.slice( 1, -2 ); -* // returns -* -* len = out.length; -* // returns 2 -* -* v = out[ 0 ]; -* // returns 1.0 -* -* v = out[ len-1 ]; -* // returns 2.0 -*/ -setReadOnly( Float16Array.prototype, 'slice', function slice( begin, end ) { - var outlen; - var outbuf; - var out; - var buf; - var len; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - buf = this._buffer; - len = this._length; - if ( arguments.length === 0 ) { - begin = 0; - end = len; - } else { - if ( !isInteger( begin ) ) { - throw new TypeError( format( 'null7e', begin ) ); - } - if ( begin < 0 ) { - begin += len; - if ( begin < 0 ) { - begin = 0; - } - } - if ( arguments.length === 1 ) { - end = len; - } else { - if ( !isInteger( end ) ) { - throw new TypeError( format( 'null7f', end ) ); - } - if ( end < 0 ) { - end += len; - if ( end < 0 ) { - end = 0; - } - } else if ( end > len ) { - end = len; - } - } - } - if ( begin < end ) { - outlen = end - begin; - } else { - outlen = 0; - } - out = new this.constructor( outlen ); - outbuf = out._buffer; // eslint-disable-line no-underscore-dangle - for ( i = 0; i < outlen; i++ ) { - outbuf[ i ] = buf[ i+begin ]; - } - return out; -}); - -/** -* Tests whether at least one element in an array passes a test implemented by a predicate function. -* -* @name some -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - predicate function execution context -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a function -* @returns {boolean} boolean indicating whether at least one element passes a test -* -* @example -* function predicate( v ) { -* return v > 0.0; -* } -* -* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] ); -* -* var bool = arr.some( predicate ); -* // returns true -*/ -setReadOnly( Float16Array.prototype, 'some', function some( predicate, thisArg ) { - var buf; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'null3c', predicate ) ); - } - buf = this._buffer; - for ( i = 0; i < this._length; i++ ) { - if ( predicate.call( thisArg, fromWord( buf[ i ] ), i, this ) ) { - return true; - } - } - return false; -}); - -/** -* Sorts an array in-place. -* -* @name sort -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} [compareFcn] - comparison function -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a function -* @returns {Float16Array} sorted array -* -* @example -* function compare( a, b ) { -* if ( a < b ) { -* return -1; -* } -* if ( a > b ) { -* return 1; -* } -* return 0; -* } -* -* var arr = new Float16Array( [ 1.0, 0.0, 2.0 ] ); -* -* arr.sort( compare ); -* -* var v = arr[ 0 ]; -* // returns 0.0 -* -* v = arr[ 1 ]; -* // returns 1.0 -* -* v = arr[ 2 ]; -* // returns 2.0 -*/ -setReadOnly( Float16Array.prototype, 'sort', function sort( compareFcn ) { - var buf; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - buf = this._buffer; - if ( arguments.length === 0 ) { - buf.sort( defaultCompare ); - return this; - } - if ( !isFunction( compareFcn ) ) { - throw new TypeError( format( 'null3c', compareFcn ) ); - } - buf.sort( compare ); - return this; - - /** - * Default comparison function for float16 values. - * - * @private - * @param {unsigned16} a - unsigned 16-bit integer for comparison - * @param {unsigned16} b - unsigned 16-bit integer for comparison - * @returns {number} comparison result - */ - function defaultCompare( a, b ) { // eslint-disable-line stdlib/no-unnecessary-nested-functions - var x = fromWord( a ); - var y = fromWord( b ); - - // Handle NaN... - if ( isnan( x ) && isnan( y ) ) { - return 0; - } - if ( isnan( x ) ) { - return 1; - } - if ( isnan( y ) ) { - return -1; - } - // Normal comparison - if ( x < y ) { - return -1; - } - if ( x > y ) { - return 1; - } - return 0; - } - - /** - * Comparison function wrapper. - * - * @private - * @param {unsigned16} a - unsigned 16-bit integer for comparison - * @param {unsigned16} b - unsigned 16-bit integer for comparison - * @returns {number} comparison result - */ - function compare( a, b ) { - return compareFcn( fromWord( a ), fromWord( b ) ); - } -}); - -/** -* Creates a new typed array view over the same underlying `ArrayBuffer` and with the same underlying data type as the host array. -* -* @name subarray -* @memberof Float16Array.prototype -* @type {Function} -* @param {integer} [begin] - start index (inclusive) -* @param {integer} [end] - end index (exclusive) -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be an integer -* @throws {TypeError} second argument must be an integer -* @returns {Float16Array} subarray -* -* @example -* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] ); -* -* var subarr = arr.subarray(); -* // returns -* -* var len = subarr.length; -* // returns 5 -* -* var bool = subarr[ 0 ]; -* // returns 0.0 -* -* bool = subarr[ len-1 ]; -* // returns 4.0 -* -* subarr = arr.subarray( 1, -2 ); -* // returns -* -* len = subarr.length; -* // returns 2 -* -* bool = subarr[ 0 ]; -* // returns 1.0 -* -* bool = subarr[ len-1 ]; -* // returns 2.0 -*/ -setReadOnly( Float16Array.prototype, 'subarray', function subarray( begin, end ) { - var offset; - var buf; - var len; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - buf = this._buffer; - len = this._length; - if ( arguments.length === 0 ) { - begin = 0; - end = len; - } else { - if ( !isInteger( begin ) ) { - throw new TypeError( format( 'null7e', begin ) ); - } - if ( begin < 0 ) { - begin += len; - if ( begin < 0 ) { - begin = 0; - } - } - if ( arguments.length === 1 ) { - end = len; - } else { - if ( !isInteger( end ) ) { - throw new TypeError( format( 'null7f', end ) ); - } - if ( end < 0 ) { - end += len; - if ( end < 0 ) { - end = 0; - } - } else if ( end > len ) { - end = len; - } - } - } - if ( begin >= len ) { - len = 0; - offset = buf.byteLength; - } else if ( begin >= end ) { - len = 0; - offset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT ); - } else { - len = end - begin; - offset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT ); - } - return new this.constructor( buf.buffer, offset, ( len < 0 ) ? 0 : len ); -}); - -/** -* Serializes an array as a locale-specific string. -* -* @name toLocaleString -* @memberof Float16Array.prototype -* @type {Function} -* @param {(string|Array)} [locales] - locale identifier(s) -* @param {Object} [options] - configuration options -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a string or an array of strings -* @throws {TypeError} options argument must be an object -* @returns {string} string representation -* -* @example -* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] ); -* -* var str = arr.toLocaleString(); -* // returns '0,1,2' -*/ -setReadOnly( Float16Array.prototype, 'toLocaleString', function toLocaleString( locales, options ) { - var opts; - var loc; - var out; - var buf; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( arguments.length === 0 ) { - loc = []; - } else if ( isString( locales ) || isStringArray( locales ) ) { - loc = locales; - } else { - throw new TypeError( format( 'invalid argument. First argument must be a string or an array of strings. Value: `%s`.', locales ) ); - } - if ( arguments.length < 2 ) { - opts = {}; - } else if ( isObject( options ) ) { - opts = options; - } else { - throw new TypeError( format( 'null2V', options ) ); - } - buf = this._buffer; - out = []; - for ( i = 0; i < this._length; i++ ) { - out.push( fromWord( buf[ i ] ) ); - } - return out.toLocaleString( loc, opts ); -}); - -/** -* Returns a new typed array containing the elements in reversed order. -* -* @name toReversed -* @memberof Float16Array.prototype -* @type {Function} -* @throws {TypeError} `this` must be a floating-point number array -* @returns {Float16Array} reversed array -* -* @example -* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] ); -* -* var out = arr.toReversed(); -* // returns -* -* var v = out[ 0 ]; -* // returns 2.0 -* -* v = out[ 1 ]; -* // returns 1.0 -* -* v = out[ 2 ]; -* // returns 0.0 -*/ -setReadOnly( Float16Array.prototype, 'toReversed', function toReversed() { - var outbuf; - var out; - var len; - var buf; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number 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; -}); - -/** -* Returns a new typed array containing the elements in sorted order. -* -* @name toSorted -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} [compareFcn] - comparison function -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a function -* @returns {Float16Array} sorted array -* -* @example -* function compare( a, b ) { -* if ( a > b ) { -* return 1; -* } -* if ( a < b ) { -* return -1; -* } -* return 0; -* } -* -* var arr = new Float16Array( [ 2.0, 0.0, 1.0 ] ); -* -* var out = arr.toSorted( compare ); -* // returns -* -* var v = out[ 0 ]; -* // returns 0.0 -* -* v = out[ 1 ]; -* // returns 1.0 -* -* v = out[ 2 ]; -* // returns 2.0 -*/ -setReadOnly( Float16Array.prototype, 'toSorted', function toSorted( compareFcn ) { - var out; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - out = new this.constructor( this ); - if ( arguments.length === 0 ) { - return out.sort(); - } - return out.sort( compareFcn ); -}); - -/** -* Serializes an array as a string. -* -* @name toString -* @memberof Float16Array.prototype -* @type {Function} -* @throws {TypeError} `this` must be a floating-point number array -* @returns {string} string representation -* -* @example -* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] ); -* -* var str = arr.toString(); -* // returns '0,1,2' -*/ -setReadOnly( Float16Array.prototype, 'toString', function toString() { - var out; - var buf; - var i; - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - buf = this._buffer; - out = []; - for ( i = 0; i < this._length; i++ ) { - out.push( fromWord( buf[ i ] ) ); - } - return out.join( ',' ); -}); - -/** -* Returns an iterator for iterating over each value in a typed array. -* -* @name values -* @memberof Float16Array.prototype -* @type {Function} -* @throws {TypeError} `this` must be a floating-point number array -* @returns {Iterator} iterator -* -* @example -* var arr = new Float16Array( [ 0.0, 1.0 ] ); -* -* var iter = arr.values(); -* -* var v = iter.next().value; -* // returns 0.0 -* -* v = iter.next().value; -* // returns 1.0 -* -* var bool = iter.next().done; -* // returns true -*/ -setReadOnly( Float16Array.prototype, 'values', function values() { - var iter; - var self; - var len; - var FLG; - var buf; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - self = this; - buf = this._buffer; - len = this._length; - - // Initialize an iteration index: - i = -1; - - // Create an iterator protocol-compliant object: - iter = {}; - setReadOnly( iter, 'next', next ); - setReadOnly( iter, 'return', end ); - - if ( ITERATOR_SYMBOL ) { - setReadOnly( iter, ITERATOR_SYMBOL, factory ); - } - return iter; - - /** - * Returns an iterator protocol-compliant object containing the next iterated value. - * - * @private - * @returns {Object} iterator protocol-compliant object - */ - function next() { - i += 1; - if ( FLG || i >= len ) { - return { - 'done': true - }; - } - return { - 'value': fromWord( buf[ i ] ), - 'done': false - }; - } - - /** - * Finishes an iterator. - * - * @private - * @param {*} [value] - value to return - * @returns {Object} iterator protocol-compliant object - */ - function end( value ) { - FLG = true; - if ( arguments.length ) { - return { - 'value': value, - 'done': true - }; - } - return { - 'done': true - }; - } - - /** - * Returns a new iterator. - * - * @private - * @returns {Iterator} iterator - */ - function factory() { - return self.values(); - } -}); - -/** -* Returns a new typed array with the element at a provided index replaced with a provided value. -* -* @name with -* @memberof Float16Array.prototype -* @type {Function} -* @param {integer} index - element index -* @param {number} value - new value -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be an integer -* @throws {RangeError} index argument is out-of-bounds -* @throws {TypeError} second argument must be a floating-point number -* @returns {Float16Array} new typed array -* -* @example -* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] ); -* -* var out = arr.with( 0, 3.0 ); -* // returns -* -* var v = out[ 0 ]; -* // returns 3.0 -*/ -setReadOnly( Float16Array.prototype, 'with', function copyWith( index, value ) { - var out; - var len; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isInteger( index ) ) { - throw new TypeError( format( 'null7e', index ) ); - } - len = this._length; - if ( index < 0 ) { - index += len; - } - if ( index < 0 || index >= len ) { - throw new RangeError( format( 'nullFP', index ) ); - } - if ( !isNumber( value ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a floating-point number. Value: `%s`.', value ) ); - } - out = new this.constructor( this ); - out[ index ] = value; - return out; -}); - - -// EXPORTS // - -module.exports = Float16Array; diff --git a/package.json b/package.json index 0ed7acd..953c789 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.0", "description": "Float16Array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,65 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-uint16": "^0.2.3", - "@stdlib/assert-has-float16array-support": "^0.1.1", - "@stdlib/assert-has-iterator-symbol-support": "^0.2.3", - "@stdlib/assert-is-arraybuffer": "^0.2.3", - "@stdlib/assert-is-collection": "^0.2.3", - "@stdlib/assert-is-function": "^0.2.3", - "@stdlib/assert-is-integer": "^0.2.3", - "@stdlib/assert-is-nonnegative-integer": "^0.2.3", - "@stdlib/assert-is-number": "^0.2.3", - "@stdlib/assert-is-object": "^0.2.3", - "@stdlib/assert-is-string": "^0.2.3", - "@stdlib/assert-is-string-array": "^0.2.3", - "@stdlib/blas-base-gcopy": "^0.2.3", - "@stdlib/math-base-assert-is-nan": "^0.2.3", - "@stdlib/math-base-special-floor": "^0.2.4", - "@stdlib/number-float16-base-from-word": "^0.2.1", - "@stdlib/number-float16-base-to-word": "^0.1.1", - "@stdlib/number-float64-base-to-float16": "^0.1.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/symbol-iterator": "^0.2.3", - "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.4", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", - "@stdlib/utils-define-read-write-accessor": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.2.3", - "@stdlib/assert-has-own-property": "^0.2.3", - "@stdlib/assert-instance-of": "^0.3.1", - "@stdlib/assert-is-array": "^0.2.3", - "@stdlib/assert-is-boolean": "^0.2.3", - "@stdlib/assert-is-iterator-like": "^0.2.3", - "@stdlib/console-log-each": "^0.2.4", - "@stdlib/math-base-special-pow": "^0.3.1", - "@stdlib/random-array-uniform": "^0.2.2", - "@stdlib/utils-identity-function": "^0.2.3", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..41ab3bb --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 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 main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/polyfill/test.at.js b/test/polyfill/test.at.js deleted file mode 100644 index 2cd65c2..0000000 --- a/test/polyfill/test.at.js +++ /dev/null @@ -1,144 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `at` method for returning an array element', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'at' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.at ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.at.call( value, 0 ); - }; - } -}); - -tape( 'the method throws an error if provided an index argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - 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.at( value ); - }; - } -}); - -tape( 'the method returns `undefined` if provided an index which exceeds array dimensions', function test( t ) { - var arr; - var v; - var i; - - arr = new Float16Array( 10 ); - for ( i = -arr.length; i < arr.length; i++ ) { - if ( i < 0 ) { - v = arr.at( i-arr.length ); - t.strictEqual( v, void 0, 'returns expected value for index '+(i-arr.length) ); - } else { - v = arr.at( arr.length+i ); - t.strictEqual( v, void 0, 'returns expected value for index '+(arr.length+i) ); - } - } - t.end(); -}); - -tape( 'the method returns an array element', function test( t ) { - var arr; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( i+0.05 ); - } - - arr = new Float16Array( arr ); - - for ( i = -arr.length; i < arr.length; i++ ) { - v = arr.at( i ); - if ( i < 0 ) { - t.strictEqual( v, float64ToFloat16( arr.length + i + 0.05 ), 'returns expected value for index '+i ); - } else { - t.strictEqual( v, float64ToFloat16( i + 0.05 ), 'returns expected value for index '+i ); - } - } - t.end(); -}); diff --git a/test/polyfill/test.copy_within.js b/test/polyfill/test.copy_within.js deleted file mode 100644 index 0a8eb57..0000000 --- a/test/polyfill/test.copy_within.js +++ /dev/null @@ -1,281 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 Uint16Array = require( '@stdlib/array-uint16' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `copyWithin` method for copying a sequence of array elements within a floating-point number array', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'copyWithin' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within an array', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( 0, 3 ); - buf = new Uint16Array( arr.buffer ); - - // Overwritten: - t.strictEqual( buf[ 0 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 4.05 ), 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 2 ], toWord( 2.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (negative target)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( -arr.length, 3 ); - buf = new Uint16Array( arr.buffer ); - - // Overwritten: - t.strictEqual( buf[ 0 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 4.05 ), 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 2 ], toWord( 2.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (negative start)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( 0, -2 ); - buf = new Uint16Array( arr.buffer ); - - // Overwritten: - t.strictEqual( buf[ 0 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 4.05 ), 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 2 ], toWord( 2.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (end=length)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( 0, 3, arr.length ); - buf = new Uint16Array( arr.buffer ); - - // Overwritten: - t.strictEqual( buf[ 0 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 4.05 ), 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 2 ], toWord( 2.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (non-inclusive end)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( 2, 0, 2 ); - buf = new Uint16Array( arr.buffer ); - - // Remain the same: - t.strictEqual( buf[ 0 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - - // Overwritten: - t.strictEqual( buf[ 2 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 1.05 ), 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (negative end)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( 2, 0, -3 ); - buf = new Uint16Array( arr.buffer ); - - // Remain the same: - t.strictEqual( buf[ 0 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - - // Overwritten: - t.strictEqual( buf[ 2 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 1.05 ), 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (target >= length)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( arr.length, 3 ); - buf = new Uint16Array( arr.buffer ); - - // Remain the same: - t.strictEqual( buf[ 0 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 2 ], toWord( 2.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (target > start)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( 2, 0 ); - buf = new Uint16Array( arr.buffer ); - - // Remain the same: - t.strictEqual( buf[ 0 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - - // Overwritten: - t.strictEqual( buf[ 2 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 4 ], toWord( 2.05 ), 'returns expected value' ); - - t.end(); -}); diff --git a/test/polyfill/test.entries.js b/test/polyfill/test.entries.js deleted file mode 100644 index 4cea4d1..0000000 --- a/test/polyfill/test.entries.js +++ /dev/null @@ -1,238 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 proxyquire = require( 'proxyquire' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isNumber = require( '@stdlib/assert-is-number' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `entries` method for returning an iterator for iterating over array key-value pairs', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'entries' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.entries ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.entries.call( value ); - }; - } -}); - -tape( 'the method returns an iterator protocol-compliant object', function test( t ) { - var buf; - var arr; - var it; - var v; - var i; - - buf = [ 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( buf ); - - it = arr.entries(); - t.strictEqual( it.next.length, 0, 'has zero arity' ); - - for ( i = 0; i < arr.length; i++ ) { - v = it.next(); - t.strictEqual( isArray( v.value ), true, 'returns expected value' ); - t.strictEqual( v.value[ 0 ], i, 'returns expected value' ); - t.strictEqual( isNumber( v.value[ 1 ] ), true, 'returns expected value' ); - t.strictEqual( v.value[ 1 ], float64ToFloat16( buf[ i ] ), 'returns expected value' ); - t.strictEqual( typeof v.done, 'boolean', 'returns expected value' ); - } - t.end(); -}); - -tape( 'the method returns an iterator which has a `return` method for closing an iterator (no argument)', function test( t ) { - var buf; - var arr; - var it; - var v; - - buf = [ 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( buf ); - - it = arr.entries(); - - v = it.next(); - t.strictEqual( v.value[ 1 ], float64ToFloat16( buf[ 0 ] ), 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value[ 1 ], float64ToFloat16( buf[ 1 ] ), 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.return(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method returns an iterator which has a `return` method for closing an iterator (argument)', function test( t ) { - var buf; - var arr; - var it; - var v; - - buf = [ 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( buf ); - - it = arr.entries(); - - v = it.next(); - t.strictEqual( v.value[ 1 ], float64ToFloat16( buf[ 0 ] ), 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value[ 1 ], float64ToFloat16( buf[ 1 ] ), 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.return( 'finished' ); - t.strictEqual( v.value, 'finished', 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'if an environment supports `Symbol.iterator`, the method returns an iterable', function test( t ) { - var Float16Array; - var arr; - var buf; - var it1; - var it2; - var v1; - var v2; - var i; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - buf = [ 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( buf ); - - it1 = arr.entries(); - t.strictEqual( typeof it1[ '__ITERATOR_SYMBOL__' ], 'function', 'has method' ); - t.strictEqual( it1[ '__ITERATOR_SYMBOL__' ].length, 0, 'has zero arity' ); - - it2 = it1[ '__ITERATOR_SYMBOL__' ](); - t.strictEqual( typeof it2, 'object', 'returns expected value' ); - t.strictEqual( typeof it2.next, 'function', 'has `next` method' ); - t.strictEqual( typeof it2.return, 'function', 'has `return` method' ); - - for ( i = 0; i < arr.length; i++ ) { - v1 = it1.next().value; - v2 = it2.next().value; - t.strictEqual( v1[ 0 ], v2[ 0 ], 'returns expected value' ); - t.strictEqual( v1[ 1 ], v2[ 1 ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'if an environment does not support `Symbol.iterator`, the method does not return an "iterable"', function test( t ) { - var Float16Array; - var arr; - var buf; - var it; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/symbol-iterator': false - }); - - buf = [ 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( buf ); - - it = arr.entries(); - t.strictEqual( it[ ITERATOR_SYMBOL ], void 0, 'does not have property' ); - - t.end(); -}); diff --git a/test/polyfill/test.every.js b/test/polyfill/test.every.js deleted file mode 100644 index 384adc4..0000000 --- a/test/polyfill/test.every.js +++ /dev/null @@ -1,174 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `every` method for returning boolean indicating whether all elements pass a test', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'every' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.every ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.every.call( value, predicate ); - }; - } - - function predicate( v ) { - return v === 0.0; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.every( value ); - }; - } -}); - -tape( 'the method returns `true` if operating on an empty floating-point number array', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( 0 ); - bool = arr.every( predicate ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns `true` if all elements pass a test', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 1.05, 1.05, 1.05 ] ); - bool = arr.every( predicate ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v === float64ToFloat16( 1.05 ); - } -}); - -tape( 'the method returns `false` if one or more elements fail a test', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 1.05, 0.05, 1.05 ] ); - bool = arr.every( predicate ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v === float64ToFloat16( 1.05 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var bool; - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ 1.05, 1.05, 1.05, 1.05 ] ); - bool = arr.every( predicate, ctx ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v === float64ToFloat16( 1.05 ); - } -}); diff --git a/test/polyfill/test.fill.js b/test/polyfill/test.fill.js deleted file mode 100644 index 197e33f..0000000 --- a/test/polyfill/test.fill.js +++ /dev/null @@ -1,305 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 Uint16Array = require( '@stdlib/array-uint16' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `fill` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'fill' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.fill ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.fill.call( value, 1.0 ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a floating-point number', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 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.fill( value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - 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.fill( 1.0, value ); - }; - } -}); - -tape( 'the method throws an error if provided a third argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - 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.fill( 1.0, 0, value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.fill( 1.05 ); - - t.strictEqual( out instanceof Float16Array, true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 10 ); - out = arr.fill( 1.05 ); - - t.strictEqual( out, arr, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'if called with one argument, the method sets each array element to the provided value', function test( t ) { - var arr; - var buf; - var i; - - arr = new Float16Array( 3 ); - arr.fill( 1.05 ); - - buf = new Uint16Array( arr.buffer ); - - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( buf[ i ], toWord( 1.05 ), 'returns expected value' ); - } - - t.end(); -}); - -tape( 'if called with two arguments, the method sets each array element to the provided value starting from a start index (inclusive)', function test( t ) { - var arr; - var buf; - - arr = new Float16Array( 3 ); - buf = new Uint16Array( arr.buffer ); - - arr.fill( 1.05, 1 ); - - t.strictEqual( buf[ 0 ], toWord( 0.0 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 2 ], toWord( 1.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'if called with three arguments, the method sets each array element to the provided value starting from a start index (inclusive) until a specified end index (exclusive)', function test( t ) { - var arr; - var buf; - - arr = new Float16Array( 3 ); - buf = new Uint16Array( arr.buffer ); - - arr.fill( 1.05, 0, 2 ); - - t.strictEqual( buf[ 0 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 2 ], toWord( 0.0 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method supports negative indices', function test( t ) { - var arr; - var buf; - - arr = new Float16Array( 3 ); - buf = new Uint16Array( arr.buffer ); - - arr.fill( 1.05, -3, -1 ); - - t.strictEqual( buf[ 0 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 2 ], toWord( 0.0 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'if a provided start index resolves to a negative index, the method fills an array starting from the first element', function test( t ) { - var arr; - var buf; - var i; - - arr = new Float16Array( 3 ); - buf = new Uint16Array( arr.buffer ); - - arr.fill( 1.05, -10 ); - - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( buf[ i ], toWord( 1.05 ), 'returns expected value' ); - } - - t.end(); -}); - -tape( 'if a provided end index resolves to an index exceeding the last array element index, the method fills an array until the last element (inclusive)', function test( t ) { - var arr; - var buf; - var i; - - arr = new Float16Array( 3 ); - buf = new Uint16Array( arr.buffer ); - - arr.fill( 1.05, 1, 10 ); - - t.strictEqual( buf[ 0 ], toWord( 0.0 ), 'returns expected value' ); - for ( i = 1; i < arr.length; i++ ) { - t.strictEqual( buf[ i ], toWord( 1.05 ), 'returns expected value' ); - } - - t.end(); -}); - -tape( 'if a provided start index resolves to an index which is greater than or equal to a resolved end index, the method does not fill an array', function test( t ) { - var arr; - var buf; - - arr = new Float16Array( 3 ); - buf = new Uint16Array( arr.buffer ); - - arr.fill( 1.0, 2, 1 ); - - t.strictEqual( buf[ 0 ], toWord( 0.0 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 0.0 ), 'returns expected value' ); - t.strictEqual( buf[ 2 ], toWord( 0.0 ), 'returns expected value' ); - - t.end(); -}); diff --git a/test/polyfill/test.filter.js b/test/polyfill/test.filter.js deleted file mode 100644 index c5be66b..0000000 --- a/test/polyfill/test.filter.js +++ /dev/null @@ -1,226 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 instanceOf = require( '@stdlib/assert-instance-of' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `filter` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'filter' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.filter ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.filter.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( v === 1.0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.filter( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.filter( predicate ); - - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v === 1.0 ); - } -}); - -tape( 'the method returns a new floating-point number array containing only those elements which satisfy a test condition', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 1.05, 2.05 ] ); - expected = new Uint16Array( [ toWord( 1.05 ), toWord( 1.05 ) ] ); - actual = arr.filter( predicate ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v === float64ToFloat16( 1.05 ) ); - } -}); - -tape( 'the method copies all elements to a new array if all elements satisfy a test condition', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ) - ]); - actual = arr.filter( predicate ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.notEqual( actual, arr, 'returns a new instance' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v > 1.0 ); - } -}); - -tape( 'the method returns an empty array if no elements satisfy a test condition', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array( [] ); - actual = arr.filter( predicate ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.notEqual( actual, arr, 'returns a new instance' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 1.0 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var expected; - var actual; - var arr; - var buf; - var ctx; - - arr = new Float16Array( [ 1.05, 2.05, 1.05, 1.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 1.05 ), - toWord( 1.05 ) - ]); - ctx = { - 'count': 0 - }; - actual = arr.filter( predicate, ctx ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v === float64ToFloat16( 1.05 ) ); - } -}); diff --git a/test/polyfill/test.find.js b/test/polyfill/test.find.js deleted file mode 100644 index 64dffd0..0000000 --- a/test/polyfill/test.find.js +++ /dev/null @@ -1,174 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `find` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'find' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.find ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.find.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( v === 1.0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.find( value ); - }; - } -}); - -tape( 'the method returns `undefined` if operating on an empty floating-point number array', function test( t ) { - var arr; - var v; - - arr = new Float16Array( 0 ); - v = arr.find( predicate ); - - t.strictEqual( v, void 0, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns the first element which passes a test', function test( t ) { - var arr; - var v; - - arr = new Float16Array( [ 1.05, -2.05, 3.05, -4.05 ] ); - v = arr.find( predicate ); - - t.strictEqual( v, float64ToFloat16( -2.05 ), 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method returns `undefined` if all elements fail a test', function test( t ) { - var arr; - var v; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - v = arr.find( predicate ); - - t.strictEqual( v, void 0, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - var v; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ -1.05, -2.05, 3.05, 4.05, 5.05 ] ); - v = arr.find( predicate, ctx ); - - t.strictEqual( v, float64ToFloat16( 3.05 ), 'returns expected value' ); - t.strictEqual( ctx.count, 3, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v > 0.0 ); - } -}); diff --git a/test/polyfill/test.find_index.js b/test/polyfill/test.find_index.js deleted file mode 100644 index e1516da..0000000 --- a/test/polyfill/test.find_index.js +++ /dev/null @@ -1,173 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `findIndex` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'findIndex' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.findIndex ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.findIndex.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( v === 1.0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.findIndex( value ); - }; - } -}); - -tape( 'the method returns `-1` if operating on an empty floating-point number array', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( 0 ); - idx = arr.findIndex( predicate ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns the index of the first element which passes a test', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( [ 1.05, -2.05, 3.05, -4.05 ] ); - idx = arr.findIndex( predicate ); - - t.strictEqual( idx, 1, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0); - } -}); - -tape( 'the method returns `-1` if all elements fail a test', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - idx = arr.findIndex( predicate ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - var idx; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ -1.05, -2.05, 3.05, 4.05, 5.05 ] ); - idx = arr.findIndex( predicate, ctx ); - - t.strictEqual( idx, 2, 'returns expected value' ); - t.strictEqual( ctx.count, 3, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v > 0.0 ); - } -}); diff --git a/test/polyfill/test.find_last.js b/test/polyfill/test.find_last.js deleted file mode 100644 index 091e5a7..0000000 --- a/test/polyfill/test.find_last.js +++ /dev/null @@ -1,174 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `findLast` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'findLast' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.findLast ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.findLast.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( v === 0.0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.findLast( value ); - }; - } -}); - -tape( 'the method returns `undefined` if operating on an empty floating-point number array', function test( t ) { - var arr; - var v; - - arr = new Float16Array( 0 ); - v = arr.findLast( predicate ); - - t.strictEqual( v, void 0, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns the last element which passes a test', function test( t ) { - var arr; - var v; - - arr = new Float16Array( [ 1.05, -2.05, 3.05, -4.05 ] ); - v = arr.findLast( predicate ); - - t.strictEqual( v, float64ToFloat16( -4.05 ), 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method returns `undefined` if all elements fail a test', function test( t ) { - var arr; - var v; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - v = arr.findLast( predicate ); - - t.strictEqual( v, void 0, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - var v; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ -1.05, -2.05, 3.05, 4.05, 5.05 ] ); - v = arr.findLast( predicate, ctx ); - - t.strictEqual( v, float64ToFloat16( 5.05 ), 'returns expected value' ); - t.strictEqual( ctx.count, 1, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v > 0.0 ); - } -}); diff --git a/test/polyfill/test.find_last_index.js b/test/polyfill/test.find_last_index.js deleted file mode 100644 index 1b7b8df..0000000 --- a/test/polyfill/test.find_last_index.js +++ /dev/null @@ -1,173 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `findLastIndex` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'findLastIndex' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.findLastIndex ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.findLastIndex.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( v === 1.0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.findLastIndex( value ); - }; - } -}); - -tape( 'the method returns `-1` if operating on an empty floating-point number array', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( 0 ); - idx = arr.findLastIndex( predicate ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns the index of the last element which passes a test', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( [ 1.05, -2.05, 3.05, -4.05 ] ); - idx = arr.findLastIndex( predicate ); - - t.strictEqual( idx, 3, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method returns `-1` if all elements fail a test', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - idx = arr.findLastIndex( predicate ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - var idx; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ -1.05, -2.05, 3.05, 4.05, 5.05 ] ); - idx = arr.findLastIndex( predicate, ctx ); - - t.strictEqual( idx, 4, 'returns expected value' ); - t.strictEqual( ctx.count, 1, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v > 0.0 ); - } -}); diff --git a/test/polyfill/test.for_each.js b/test/polyfill/test.for_each.js deleted file mode 100644 index 98e75c2..0000000 --- a/test/polyfill/test.for_each.js +++ /dev/null @@ -1,196 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `forEach` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'forEach' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.forEach ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.forEach.call( value, fcn ); - }; - } - - function fcn( v ) { - if ( !isNumber( v ) ) { - t.fail( 'should be a number' ); - } - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.forEach( value ); - }; - } -}); - -tape( 'the method should not invoke a provided callback function if operating on an empty floating-point array', function test( t ) { - var arr; - - arr = new Float16Array( 0 ); - arr.forEach( fcn ); - - t.end(); - - function fcn() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns `undefined`', function test( t ) { - var arr; - var out; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - out = arr.forEach( fcn ); - - t.strictEqual( out, void 0, 'returns expected value' ); - t.end(); - - function fcn( v ) { - if ( !isNumber( v ) ) { - t.fail( 'should be a number' ); - } - } -}); - -tape( 'the method invokes a provided function for each element in an array', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var arr; - - indices = []; - values = []; - arrays = []; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - arr.forEach( fcn ); - - expected = [ - float64ToFloat16( 1.05 ), - float64ToFloat16( 2.05 ), - float64ToFloat16( 3.05 ), - float64ToFloat16( 4.05 ) - ]; - - t.deepEqual( values, expected, 'returns expected value' ); - t.deepEqual( indices, [ 0, 1, 2, 3 ], 'returns expected value' ); - t.strictEqual( arrays[ 0 ], arr, 'returns expected value' ); - t.strictEqual( arrays[ 1 ], arr, 'returns expected value' ); - t.strictEqual( arrays[ 2 ], arr, 'returns expected value' ); - t.strictEqual( arrays[ 3 ], arr, 'returns expected value' ); - - t.end(); - - function fcn( v, i, arr ) { - values.push( v ); - indices.push( i ); - arrays.push( arr ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - arr.forEach( fcn, ctx ); - - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function fcn() { - this.count += 1; // eslint-disable-line no-invalid-this - } -}); diff --git a/test/polyfill/test.from.js b/test/polyfill/test.from.js deleted file mode 100644 index d9cfc1a..0000000 --- a/test/polyfill/test.from.js +++ /dev/null @@ -1,654 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 proxyquire = require( 'proxyquire' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is a `from` method for creating a 16-bit floating-point number array from an array-like object or an iterable', function test( t ) { - var arr; - - t.strictEqual( hasOwnProp( Float16Array, 'from' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.from ), true, 'has method' ); - - arr = Float16Array.from( [] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a constructor', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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 Float16Array.from.call( value, [] ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array constructor', function test( t ) { - var values; - var i; - - values = [ - {}, - null, - 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 Float16Array.from.call( value, [] ); - }; - } -}); - -tape( 'the method throws an error if not provided an iterable or array-like object', function test( t ) { - var values; - var i; - - 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 Float16Array.from( value ); - }; - } -}); - -tape( 'the method throws an error if not provided an iterable or array-like object (callback)', function test( t ) { - var values; - var i; - - 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 Float16Array.from( value, clbk ); - }; - } - - function clbk() { - return 1.0; - } -}); - -tape( 'the method throws an error if not provided an iterable or array-like object (callback, thisArg)', function test( t ) { - var values; - var i; - - 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 Float16Array.from( value, clbk, {} ); - }; - } - - function clbk() { - return 1.0; - } -}); - -tape( 'the method throws an error if provided a second argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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 Float16Array.from( [], value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not a function (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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 Float16Array.from( [], value, {} ); - }; - } -}); - -tape( 'the method returns a floating-point number array', function test( t ) { - var arr; - var v; - - // Generic array: - arr = Float16Array.from( [] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Float16Array.from( [ 1.0, 2.0, 3.0, 4.0 ] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - // Generic array containing non-numeric values: - arr = Float16Array.from( [ 'beep' ] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - arr = Float16Array.from( [ null, 4 ] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - arr = Float16Array.from( [ true, {}, '' ] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 3, 'returns expected value' ); - - // Typed array: - arr = Float16Array.from( new Uint16Array( 0 ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Float16Array.from( new Uint16Array( [ 1, 1 ] ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // Floating-point number typed array: - arr = Float16Array.from( new Float16Array( 0 ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Float16Array.from( new Float16Array( [ 1.0, 2.0 ] ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method returns a floating-point number array (iterable)', function test( t ) { - var Float16Array; - var iter; - var arr; - var v; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - iter = { - 'next': next, - 'i': 0, - 'N': 4 - }; - arr = Float16Array.from( createIterable( iter ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, iter.N, 'returns expected value' ); - - t.end(); - - function hasSupport() { - return true; - } - - function createIterable( iterator ) { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return iterator; - } - } - - function next() { - iter.i += 1; - if ( iter.i <= iter.N ) { - return { - 'value': 1.0 - }; - } - return { - 'done': true - }; - } -}); - -tape( 'the method supports providing a "map" function which is invoked for each source element', function test( t ) { - var arr; - var v; - - // Generic array: - arr = Float16Array.from( [], clbk1 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Float16Array.from( [ 1.0, 2.0, 3.0, 4.0 ], clbk1 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - // Generic array containing non-numeric values: - arr = Float16Array.from( [ 'beep' ], clbk2 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - arr = Float16Array.from( [ null ], clbk2 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - arr = Float16Array.from( [ [], {} ], clbk1 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - arr = Float16Array.from( [ 4, 5 ], clbk1 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // Typed array: - arr = Float16Array.from( new Uint16Array( 0 ), clbk1 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Float16Array.from( new Uint16Array( [ 1, 1 ] ), clbk1 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // Floating-point number typed array: - arr = Float16Array.from( new Float16Array( 0 ), clbk2 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Float16Array.from( new Float16Array( [ true, true ] ), clbk2 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - t.end(); - - function clbk1( v ) { - return v; - } - - function clbk2() { - return true; - } -}); - -tape( 'the method supports providing a "map" function which is invoked for each iterated value', function test( t ) { - var Float16Array; - var iter; - var arr; - var v; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - iter = { - 'next': next, - 'i': 0, - 'N': 4 - }; - arr = Float16Array.from( createIterable( iter ), clbk ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, iter.N, 'returns expected value' ); - - t.end(); - - function hasSupport() { - return true; - } - - function createIterable( iterator ) { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return iterator; - } - } - - function next() { - iter.i += 1; - if ( iter.i <= iter.N ) { - return { - 'value': 1.0 - }; - } - return { - 'done': true - }; - } - - function clbk( v ) { - return !v; - } -}); - -tape( 'the method supports providing a `this` context for a provided map function', function test( t ) { - var arr; - var ctx; - - ctx = { - 'count': 0 - }; - arr = Float16Array.from( [ 1.0, 2.0, 3.0, 4.0 ], clbk1, ctx ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function clbk1( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v; - } -}); - -tape( 'the method supports providing a `this` context for a provided map function (iterable)', function test( t ) { - var Float16Array; - var iter; - var ctx; - var arr; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - iter = { - 'next': next, - 'i': 0, - 'N': 4 - }; - ctx = { - 'count': 0 - }; - - arr = Float16Array.from( createIterable( iter ), clbk, ctx ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function hasSupport() { - return true; - } - - function createIterable( iterator ) { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return iterator; - } - } - - function next() { - iter.i += 1; - if ( iter.i <= iter.N ) { - return { - 'value': 1.0 - }; - } - return { - 'done': true - }; - } - - function clbk( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v; - } -}); - -tape( 'the method throws an error if provided a non-iterable object (non-ES2015+)', function test( t ) { - var Float16Array; - var values; - var i; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - {}, - { - '0': 1, - '1': 2, - '2': 3 - } - ]; - 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 Float16Array.from( value ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the method throws an error if provided a non-iterable object (ES2015+)', function test( t ) { - var Float16Array; - var values; - var i; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - values = [ - {}, - { - '0': 1, - '1': 2, - '2': 3 - }, - { - '__SYMBOL_ITERATOR__': null - }, - { - '__SYMBOL_ITERATOR__': 'beep' - }, - { - '__SYMBOL_ITERATOR__': nonIterable1 - }, - { - '__SYMBOL_ITERATOR__': nonIterable2 - } - ]; - 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 Float16Array.from( value ); - }; - } - - function hasSupport() { - return true; - } - - function nonIterable1() { - return null; - } - - function nonIterable2() { - return {}; - } -}); diff --git a/test/polyfill/test.includes.js b/test/polyfill/test.includes.js deleted file mode 100644 index 8bb9850..0000000 --- a/test/polyfill/test.includes.js +++ /dev/null @@ -1,222 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `includes` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'includes' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.includes ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.includes.call( value, true ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a numeric value', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 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.includes( value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - 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.includes( true, value ); - }; - } -}); - -tape( 'the method returns `false` if operating on an empty floating-point number array', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( 0 ); - bool = arr.includes( 1.0 ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `false` if a floating-point number is not found', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( 10 ); - bool = arr.includes( 1.0 ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `true` if an array contains a specified floating-point number', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05] ); - bool = arr.includes( float64ToFloat16( 1.05 ) ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `false` if provided a second argument which exceeds the input array length', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( 10 ); - bool = arr.includes( 0.0, 20 ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 1.05, 1.05, 1.05 ] ); - - bool = arr.includes( float64ToFloat16( 1.05 ), 0 ); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = arr.includes( float64ToFloat16( 2.05 ), 1 ); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = arr.includes( float64ToFloat16( 2.05 ), 3 ); - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index (negative)', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 1.05, 1.05, 1.05 ] ); - - bool = arr.includes( float64ToFloat16( 1.05 ), -5 ); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = arr.includes( float64ToFloat16( 2.05 ), -2 ); - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'when provided a starting index which resolves to an index which is less than zero, the method searches from the first array element', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 1.05, 1.05, 1.05 ] ); - - bool = arr.includes( float64ToFloat16( 1.05 ), -10 ); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = arr.includes( float64ToFloat16( 2.05 ), -10 ); - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); -}); diff --git a/test/polyfill/test.index_of.js b/test/polyfill/test.index_of.js deleted file mode 100644 index b432c6d..0000000 --- a/test/polyfill/test.index_of.js +++ /dev/null @@ -1,222 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `indexOf` method for returning the index of an array element', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'indexOf' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.indexOf ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.indexOf.call( value, 1.0 ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a numeric value', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 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.indexOf( value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - 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.indexOf( 1.0, value ); - }; - } -}); - -tape( 'the method returns `-1` if operating on an empty floating-point number array', function test( t ) { - var arr; - var idx; - - arr = new Float16Array(); - idx = arr.indexOf( 1.0 ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `-1` if a numeric value is not found', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( 10 ); - idx = arr.indexOf( 1.0 ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns the index of the first match if a numeric value is found', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - idx = arr.indexOf( float64ToFloat16( 2.05 ) ); - - t.strictEqual( idx, 1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `-1` if provided a second argument which exceeds the input array length', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( 10 ); - idx = arr.indexOf( 1.0, 20 ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 2.05, 5.05 ] ); - - idx = arr.indexOf( float64ToFloat16( 2.05 ), 0 ); - t.strictEqual( idx, 1, 'returns expected value' ); - - idx = arr.indexOf( float64ToFloat16( 2.05 ), 2 ); - t.strictEqual( idx, 3, 'returns expected value' ); - - idx = arr.indexOf( float64ToFloat16( 2.05 ), 4 ); - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index (negative)', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 2.05, 5.05 ] ); - - idx = arr.indexOf( float64ToFloat16( 2.05 ), -5 ); - t.strictEqual( idx, 1, 'returns expected value' ); - - idx = arr.indexOf( float64ToFloat16( 2.05 ), -1 ); - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'when provided a starting index which resolves to an index which is less than zero, the method searches from the first array element', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 2.05, 5.05 ] ); - - idx = arr.indexOf( float64ToFloat16( 2.05 ), -10 ); - t.strictEqual( idx, 1, 'returns expected value' ); - - idx = arr.indexOf( float64ToFloat16( 1.05 ), -10 ); - t.strictEqual( idx, 0, 'returns expected value' ); - t.end(); -}); diff --git a/test/polyfill/test.join.js b/test/polyfill/test.join.js deleted file mode 100644 index 007f1cb..0000000 --- a/test/polyfill/test.join.js +++ /dev/null @@ -1,173 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `join` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'join' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.join ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.join.call( value ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `separator` argument which is not a string', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - 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.join( value ); - }; - } -}); - -tape( 'the method returns an empty string if invoked on an empty array', function test( t ) { - var str; - var arr; - - arr = new Float16Array( 0 ); - str = arr.join(); - - t.strictEqual( str, '', 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a string representation of a floating-point number array with elements separated by a separator', function test( t ) { - var expected; - var str; - var arr; - var i; - - arr = new Float16Array( [ 0.05, 1.05, 2.05, 3.05, 4.05 ] ); - - expected = float64ToFloat16( 0.05 ); - for ( i = 1; i < arr.length; i++ ) { - expected += '@' + float64ToFloat16( i + 0.05 ); - } - - str = arr.join( '@' ); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a string representation of a floating-point number array with elements separated by a separator (single element)', function test( t ) { - var expected; - var str; - var arr; - - arr = new Float16Array( [ 1.05 ] ); - expected = '' + float64ToFloat16( 1.05 ); - - str = arr.join(); - - t.strictEqual( str, expected, 'returns expected value' ); - - arr = new Float16Array( [ 1.05 ] ); - expected = '' + float64ToFloat16( 1.05 ); - - str = arr.join( '@' ); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if the method is invoked without a separator argument, the method returns a string representation of a floating-point number array with elements separated by a comma', function test( t ) { - var expected; - var str; - var arr; - var i; - - arr = new Float16Array( [ 0.05, 1.05, 2.05, 3.05, 4.05 ] ); - - expected = float64ToFloat16( 0.05 ); - for ( i = 1; i < arr.length; i++ ) { - expected += ',' + float64ToFloat16( i + 0.05 ); - } - - str = arr.join(); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); diff --git a/test/polyfill/test.js b/test/polyfill/test.js deleted file mode 100644 index 6e254ad..0000000 --- a/test/polyfill/test.js +++ /dev/null @@ -1,740 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 proxyquire = require( 'proxyquire' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var arr = new Float16Array( 0 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var ctor; - var arr; - - ctor = Float16Array; - - arr = ctor( 0 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (no argument)', function test( t ) { - var arr = new Float16Array(); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (no argument, no new)', function test( t ) { - var ctor; - var arr; - - ctor = Float16Array; - - arr = ctor(); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (length)', function test( t ) { - var arr = new Float16Array( 10 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (length, no new)', function test( t ) { - var ctor; - var arr; - - ctor = Float16Array; - - arr = ctor( 10 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (array)', function test( t ) { - var arr = new Float16Array( [] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (array, no new)', function test( t ) { - var ctor; - var arr; - - ctor = Float16Array; - - arr = ctor( [] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (typed array)', function test( t ) { - var arr = new Float16Array( new Uint16Array( 0 ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (typed array, no new)', function test( t ) { - var ctor; - var arr; - - ctor = Float16Array; - - arr = ctor( new Uint16Array( 0 ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (iterable)', function test( t ) { - var Float16Array; - var arr; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - arr = new Float16Array( createIterable() ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); - - function hasSupport() { - return true; - } - - function createIterable() { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return { - 'next': next - }; - } - - function next() { - return { - 'done': true - }; - } - } -}); - -tape( 'the constructor returns a 16-bit floating-point number array (iterable, no new)', function test( t ) { - var ctor; - var arr; - - ctor = proxyquire( './../../lib/polyfill', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - arr = ctor( createIterable() ); - t.strictEqual( arr instanceof ctor, true, 'returns expected value' ); - - t.end(); - - function hasSupport() { - return true; - } - - function createIterable() { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return { - 'next': next - }; - } - - function next() { - return { - 'done': true - }; - } - } -}); - -tape( 'the constructor returns a 16-bit floating-point number array (ArrayBuffer)', function test( t ) { - var arr = new Float16Array( new ArrayBuffer( 0 ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (ArrayBuffer, no new)', function test( t ) { - var ctor; - var arr; - - ctor = Float16Array; - - arr = ctor( new ArrayBuffer( 0 ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (ArrayBuffer, byte offset)', function test( t ) { - var arr = new Float16Array( new ArrayBuffer( 8 ), 8 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (ArrayBuffer, byte offset, no new)', function test( t ) { - var ctor; - var arr; - - ctor = Float16Array; - - arr = ctor( new ArrayBuffer( 8 ), 8 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (ArrayBuffer, byte offset, length)', function test( t ) { - var arr = new Float16Array( new ArrayBuffer( 8 ), 8, 0 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (ArrayBuffer, byte offset, length, no new)', function test( t ) { - var ctor; - var arr; - - ctor = Float16Array; - - arr = ctor( new ArrayBuffer( 8 ), 8, 0 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'attached to the constructor is a property returning the number of bytes per array element', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Float16Array.BYTES_PER_ELEMENT, 2, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the constructor is a property returning the constructor name', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array, 'name' ), true, 'has property' ); - t.strictEqual( Float16Array.name, 'Float16Array', 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance having a `BYTES_PER_ELEMENT` property returning the number of bytes per array element', function test( t ) { - var arr; - - t.strictEqual( hasOwnProp( Float16Array.prototype, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Float16Array.prototype.BYTES_PER_ELEMENT, 2, 'returns expected value' ); - - arr = new Float16Array( 0 ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance having a `buffer` property for returning the underlying memory (i.e., ArrayBuffer)', function test( t ) { - var arr; - var buf; - - arr = new Float16Array( 0 ); - buf = arr.buffer; - t.strictEqual( isArrayBuffer( buf ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance having a `byteLength` property for returning the number of bytes belonging to the array view', function test( t ) { - var arr; - var v; - - arr = new Float16Array( 0 ); - v = arr.byteLength; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( new ArrayBuffer( 64 ), 8 ); - v = arr.byteLength; - t.strictEqual( v, 56, 'returns expected value' ); - - arr = new Float16Array( new ArrayBuffer( 64 ), 64 ); - v = arr.byteLength; - t.strictEqual( v, 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance having a `byteOffset` property for returning the byte offset pointing to the first array element in the underlying memory', function test( t ) { - var arr; - var v; - - arr = new Float16Array( 0 ); - v = arr.byteOffset; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( new ArrayBuffer( 64 ), 32 ); - v = arr.byteOffset; - t.strictEqual( v, 32, 'returns expected value' ); - - arr = new Float16Array( new ArrayBuffer( 64 ), 64 ); - v = arr.byteOffset; - t.strictEqual( v, 64, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance having a `length` property for returning the number of array elements', function test( t ) { - var arr; - var v; - - // No arguments: - arr = new Float16Array(); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - // Explicit array length: - arr = new Float16Array( 0 ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( 10 ); - v = arr.length; - t.strictEqual( v, 10, 'returns expected value' ); - - // Generic array: - arr = new Float16Array( [] ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - // Typed array: - arr = new Float16Array( new Uint16Array( 0 ) ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( new Uint16Array( [ 1.0, 1.0 ] ) ); - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // Float16 typed array: - arr = new Float16Array( new Float16Array( 0 ) ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( new Float16Array( [ 1.0, 2.0 ] ) ); - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // ArrayBuffer: - arr = new Float16Array( new ArrayBuffer( 64 ), 32 ); - v = arr.length; - t.strictEqual( v, 16, 'returns expected value' ); - - arr = new Float16Array( new ArrayBuffer( 64 ), 64 ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( new ArrayBuffer( 64 ), 32, 2 ); - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance having a `length` property for returning the number of array elements (iterable)', function test( t ) { - var Float16Array; - var iter; - var arr; - var v; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - iter = { - 'next': next, - 'i': 0, - 'N': 4 - }; - arr = new Float16Array( createIterable( iter ) ); - v = arr.length; - t.strictEqual( v, iter.N, 'returns expected value' ); - - t.end(); - - function hasSupport() { - return true; - } - - function createIterable( iterator ) { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return iterator; - } - } - - function next() { - iter.i += 1; - if ( iter.i <= iter.N ) { - return { - 'value': 1.0 - }; - } - return { - 'done': true - }; - } -}); - -tape( 'the constructor throws an error if provided an ArrayBuffer which is not a multiple of 2', function test( t ) { - var values; - var i; - - values = [ - 1, - 3, - 5, - 7, - 9, - 11, - 101, - 1001 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided an ArrayBuffer having a byte length equal to '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Float16Array( new ArrayBuffer( value ) ); - }; - } -}); - -tape( 'the constructor throws an error if provided a non-iterable object (non-ES2015+)', function test( t ) { - var Float16Array; - var values; - var i; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - {}, - { - '0': 1, - '1': 2, - '2': 3 - } - ]; - 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 new Float16Array( value ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the constructor throws an error if provided a non-iterable object (ES2015+)', function test( t ) { - var Float16Array; - var values; - var i; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - values = [ - {}, - { - '0': 1, - '1': 2, - '2': 3 - }, - { - '__SYMBOL_ITERATOR__': null - }, - { - '__SYMBOL_ITERATOR__': 'beep' - }, - { - '__SYMBOL_ITERATOR__': nonIterable1 - }, - { - '__SYMBOL_ITERATOR__': nonIterable2 - } - ]; - 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 new Float16Array( value ); - }; - } - - function hasSupport() { - return true; - } - - function nonIterable1() { - return null; - } - - function nonIterable2() { - return {}; - } -}); - -tape( 'the constructor throws an error if not provided a length, iterable, array-like object, or ArrayBuffer', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - 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 new Float16Array( value ); - }; - } -}); - -tape( 'the constructor throws an error if provided more than one argument and the first argument is not an ArrayBuffer', function test( t ) { - var values; - var i; - - 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 new Float16Array( value, 0 ); - }; - } -}); - -tape( 'the constructor throws an error if provided a byte offset argument which is not a nonnegative integer', function test( t ) { - var values; - var i; - - values = [ - '5', - -1, - 3.14, - 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 new Float16Array( new ArrayBuffer( 64 ), value ); - }; - } -}); - -tape( 'the constructor throws an error if provided a byte offset argument which is not a multiple of 2', function test( t ) { - var values; - var i; - - values = [ - 1, - 3, - 5, - 7, - 9, - 11, - 101, - 1001 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Float16Array( new ArrayBuffer( 1e3 ), value ); - }; - } -}); - -tape( 'the constructor throws an error if provided a byte offset argument such that the view byte length is not a multiple of 8', function test( t ) { - var values; - var i; - - values = [ - 2, - 4, - 6, - 8, - 10, - 12, - 14, - 16, - 18, - 20 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Float16Array( new ArrayBuffer( 101 ), value ); - }; - } -}); - -tape( 'the constructor throws an error if provided a length argument which is not a nonnegative integer (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - -1, - 3.14, - 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 new Float16Array( new ArrayBuffer( 64 ), 0, value ); - }; - } -}); - -tape( 'the constructor throws an error if provided insufficient memory to accommodate byte offset and length arguments', function test( t ) { - var values; - var i; - - values = [ - 8, - 16, - 24, - 32 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Float16Array( new ArrayBuffer( 100 ), value, 1e3 ); - }; - } -}); diff --git a/test/polyfill/test.keys.js b/test/polyfill/test.keys.js deleted file mode 100644 index 59c6210..0000000 --- a/test/polyfill/test.keys.js +++ /dev/null @@ -1,261 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 proxyquire = require( 'proxyquire' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `keys` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'keys' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.keys ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.keys.call( value ); - }; - } -}); - -tape( 'the method returns an iterator protocol-compliant object', function test( t ) { - var expected; - var arr; - var it; - var i; - var r; - var e; - - arr = new Float16Array( [ 1.05, 2.05 ] ); - expected = [ - { - 'value': 0, - 'done': false - }, - { - 'value': 1, - 'done': false - }, - { - 'done': true - } - ]; - it = arr.keys(); - - t.strictEqual( typeof it, 'object', 'returns expected value' ); - t.strictEqual( typeof it.next, 'function', 'has next method' ); - - for ( i = 0; i < expected.length; i++ ) { - r = it.next(); - e = expected[ i ]; - if ( e.value === void 0 ) { - t.deepEqual( r, e, 'returns expected value' ); - } else { - t.strictEqual( r.value, e.value, 'returns expected value' ); - t.strictEqual( r.done, e.done, 'returns expected value' ); - } - } - - t.end(); -}); - -tape( 'the method returns an iterator which does not iterate over empty arrays', function test( t ) { - var expected; - var arr; - var it; - var i; - var v; - - arr = new Float16Array( [] ); - expected = [ - { - 'done': true - }, - { - 'done': true - }, - { - 'done': true - } - ]; - it = arr.keys(); - - t.strictEqual( typeof it, 'object', 'returns expected value' ); - t.strictEqual( typeof it.next, 'function', 'has next method' ); - - for ( i = 0; i < expected.length; i++ ) { - v = it.next(); - t.deepEqual( v, expected[ i ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (no argument)', function test( t ) { - var arr; - var it; - var v; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - it = arr.keys(); - - v = it.next(); - t.strictEqual( v.value, 0, 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, 1, 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.return(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (argument)', function test( t ) { - var arr; - var it; - var v; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - it = arr.keys(); - - v = it.next(); - t.strictEqual( v.value, 0, 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, 1, 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.return( 'beep' ); - t.strictEqual( v.value, 'beep', 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'if an environment supports `Symbol.iterator`, the method returns an iterable', function test( t ) { - var Float16Array; - var arr; - var buf; - var it1; - var it2; - var v1; - var v2; - var i; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - buf = [ 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( buf ); - - it1 = arr.keys(); - t.strictEqual( typeof it1[ '__ITERATOR_SYMBOL__' ], 'function', 'has method' ); - t.strictEqual( it1[ '__ITERATOR_SYMBOL__' ].length, 0, 'has zero arity' ); - - it2 = it1[ '__ITERATOR_SYMBOL__' ](); - t.strictEqual( typeof it2, 'object', 'returns expected value' ); - t.strictEqual( typeof it2.next, 'function', 'has `next` method' ); - t.strictEqual( typeof it2.return, 'function', 'has `return` method' ); - - for ( i = 0; i < arr.length; i++ ) { - v1 = it1.next().value; - v2 = it2.next().value; - t.strictEqual( v1, v2, 'returns expected value' ); - } - t.end(); -}); - -tape( 'if an environment does not support `Symbol.iterator`, the method does not return an "iterable"', function test( t ) { - var Float16Array; - var arr; - var buf; - var it; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/symbol-iterator': false - }); - - buf = [ 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( buf ); - - it = arr.keys(); - t.strictEqual( it[ ITERATOR_SYMBOL ], void 0, 'does not have property' ); - - t.end(); -}); diff --git a/test/polyfill/test.last_index_of.js b/test/polyfill/test.last_index_of.js deleted file mode 100644 index 6a2fe99..0000000 --- a/test/polyfill/test.last_index_of.js +++ /dev/null @@ -1,211 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `lastIndexOf` method for returning the index of an array element', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'lastIndexOf' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.lastIndexOf ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.lastIndexOf.call( value, true ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a numeric value', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 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.lastIndexOf( value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - 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.lastIndexOf( true, value ); - }; - } -}); - -tape( 'the method returns `-1` if operating on an empty floating-point number array', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( 0 ); - idx = arr.lastIndexOf( 0.0 ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `-1` if a numeric value is not found', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( 10 ); - idx = arr.lastIndexOf( 1.0 ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns the index of the first match when searching from the end of the array if a search element is found', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 1.05, 2.05 ] ); - idx = arr.lastIndexOf( float64ToFloat16( 1.05 ) ); - - t.strictEqual( idx, 2, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 2.05, 1.05, 1.05 ] ); - - idx = arr.lastIndexOf( float64ToFloat16( 1.05 ), 4 ); - t.strictEqual( idx, 4, 'returns expected value' ); - - idx = arr.lastIndexOf( float64ToFloat16( 2.05 ), 2 ); - t.strictEqual( idx, 2, 'returns expected value' ); - - idx = arr.lastIndexOf( float64ToFloat16( 2.05 ), 0 ); - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index (negative)', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 2.05, 1.05, 1.05 ] ); - - idx = arr.lastIndexOf( float64ToFloat16( 1.05 ), -3 ); - t.strictEqual( idx, 0, 'returns expected value' ); - - idx = arr.lastIndexOf( float64ToFloat16( 2.05 ), -1 ); - t.strictEqual( idx, 2, 'returns expected value' ); - t.end(); -}); - -tape( 'when the method is provided a starting index which resolves to an index which exceeds the maximum array index, the method searches from the last array element', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 2.05, 1.05, 1.05 ] ); - - idx = arr.lastIndexOf( float64ToFloat16( 1.05 ), 10 ); - t.strictEqual( idx, 4, 'returns expected value' ); - - idx = arr.lastIndexOf( float64ToFloat16( 2.05 ), 10 ); - t.strictEqual( idx, 2, 'returns expected value' ); - t.end(); -}); diff --git a/test/polyfill/test.map.js b/test/polyfill/test.map.js deleted file mode 100644 index 233d1d8..0000000 --- a/test/polyfill/test.map.js +++ /dev/null @@ -1,178 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 identity = require( '@stdlib/utils-identity-function' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `map` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'map' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.map ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.map.call( value, identity ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.map( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.map( identity ); - - t.strictEqual( instanceOf( out, Float16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - t.notEqual( out, arr, 'returns a new instance' ); - t.end(); -}); - -tape( 'the method returns a new floating-point number array containing elements which are the result of a provided callback function', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( -1.05 ), - toWord( -2.05 ), - toWord( -3.05 ), - toWord( -4.05 ) - ]); - actual = arr.map( invert ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.notEqual( actual, arr, 'returns a new instance' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); - - function invert( v ) { - return -v; - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var expected; - var actual; - var arr; - var buf; - var ctx; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( -1.05 ), - toWord( -2.05 ), - toWord( -3.05 ), - toWord( -4.05 ) - ]); - ctx = { - 'count': 0 - }; - actual = arr.map( invert, ctx ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.strictEqual( ctx.count, 6, 'returns expected value' ); - t.end(); - - function invert( v, i ) { - this.count += i; // eslint-disable-line no-invalid-this - return -v; - } -}); diff --git a/test/polyfill/test.of.js b/test/polyfill/test.of.js deleted file mode 100644 index 5031bb5..0000000 --- a/test/polyfill/test.of.js +++ /dev/null @@ -1,130 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `of` method for creating a 16-bit floating-point number array from a variable number of arguments', function test( t ) { - var arr; - - t.strictEqual( hasOwnProp( Float16Array, 'of' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.of ), true, 'has method' ); - - arr = Float16Array.of(); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a constructor', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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 Float16Array.of.call( value, true, true ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point array constructor', function test( t ) { - var values; - var i; - - values = [ - {}, - null, - 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 Float16Array.of.call( value, true, true ); - }; - } -}); - -tape( 'the method returns a floating-point number array', function test( t ) { - var arr; - var v; - - // No arguments: - arr = Float16Array.of(); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - // Numeric arguments: - arr = Float16Array.of( 1.0, 2.0, 3.0, 4.0 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - // Non-numeric arguments: - arr = Float16Array.of( 1, {}, 0, null, 'beep' ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 5, 'returns expected value' ); - - // Mixed arguments: - arr = Float16Array.of( true, 1, false, 0 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - t.end(); -}); diff --git a/test/polyfill/test.reduce.js b/test/polyfill/test.reduce.js deleted file mode 100644 index 7d9cbc0..0000000 --- a/test/polyfill/test.reduce.js +++ /dev/null @@ -1,189 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `reduce` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'reduce' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.reduce ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.reduce.call( value, reducer ); - }; - } - - function reducer( acc, value ) { - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.reduce( value ); - }; - } -}); - -tape( 'the method throws an error if not provided an initial value when operating on an empty floating-point number array', function test( t ) { - var arr; - - arr = new Float16Array( 0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - arr.reduce( reducer ); - } - - function reducer( acc, value ) { - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method uses the first element of the array as the initial value when an initial value is not provided', function test( t ) { - var valueArray; - var accArray; - var expected; - var actual; - var arr; - var ind; - - arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - accArray = [ 1.0, 3.0 ]; - valueArray = [ 2.0, 3.0 ]; - expected = float64ToFloat16( 6.0 ); - actual = arr.reduce( reducer ); - - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); - - function reducer( acc, value, index ) { - ind = index-1; - t.strictEqual( acc, float64ToFloat16( accArray[ ind ] ), 'returns expected value' ); - t.strictEqual( value, float64ToFloat16( valueArray[ ind ] ), 'returns expected value' ); - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method supports providing an initial value as the second argument', function test( t ) { - var valueArray; - var accArray; - var expected; - var actual; - var arr; - - arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - accArray = [ 2.0, 3.0, 5.0 ]; - valueArray = [ 1.0, 2.0, 3.0 ]; - expected = 8.0; - actual = arr.reduce( reducer, 2.0 ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value, index ) { - t.strictEqual( acc, float64ToFloat16( accArray[ index ] ), 'returns expected value' ); - t.strictEqual( value, float64ToFloat16( valueArray[ index ] ), 'returns expected value' ); - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method returns the accumulated result', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = float64ToFloat16( 10.20 ); - actual = arr.reduce( reducer ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value ) { - return float64ToFloat16( acc + value ); - } -}); diff --git a/test/polyfill/test.reduce_right.js b/test/polyfill/test.reduce_right.js deleted file mode 100644 index 0d27e43..0000000 --- a/test/polyfill/test.reduce_right.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `reduceRight` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'reduceRight' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.reduceRight ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.reduceRight.call( value, reducer ); - }; - } - - function reducer( acc, value ) { - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.reduceRight( value ); - }; - } -}); - -tape( 'the method throws an error if not provided an initial value when operating on an empty floating-point number array', function test( t ) { - var arr; - - arr = new Float16Array( 0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - arr.reduceRight( reducer ); - } - - function reducer( acc, value ) { - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method uses the last element of the array as the initial value when an initial value is not provided', function test( t ) { - var valueArray; - var accArray; - var expected; - var actual; - var arr; - var len; - - arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - len = arr.length; - accArray = [ 3.0, 5.0 ]; - valueArray = [ 2.0, 1.0 ]; - expected = float64ToFloat16( 6.0 ); - actual = arr.reduceRight( reducer ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value, index ) { - var ind = (len-index-2); - t.strictEqual( acc, float64ToFloat16( accArray[ ind ] ), 'returns expected value' ); - t.strictEqual( value, float64ToFloat16( valueArray[ ind ] ), 'returns expected value' ); - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method supports providing an initial value as the second argument', function test( t ) { - var valueArray; - var accArray; - var expected; - var actual; - var arr; - var len; - - arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - len = arr.length; - accArray = [ 2.0, 5.0, 7.0 ]; - valueArray = [ 3.0, 2.0, 1.0 ]; - expected = 8.0; - actual = arr.reduceRight( reducer, 2.0 ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value, index ) { - var ind = (len-index-1); - t.strictEqual( acc, float64ToFloat16( accArray[ ind ] ), 'returns expected value' ); - t.strictEqual( value, float64ToFloat16( valueArray[ ind ] ), 'returns expected value' ); - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method returns the accumulated result', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = float64ToFloat16( 10.20 ); - actual = arr.reduceRight( reducer ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value ) { - return float64ToFloat16( acc + value ); - } -}); diff --git a/test/polyfill/test.reverse.js b/test/polyfill/test.reverse.js deleted file mode 100644 index 080a4c3..0000000 --- a/test/polyfill/test.reverse.js +++ /dev/null @@ -1,122 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 instanceOf = require( '@stdlib/assert-instance-of' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, '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( Float16Array.prototype, 'reverse' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.reverse ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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 floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - 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 floating-point number array in-place', function test( t ) { - var expected; - var arr; - var buf; - var out; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05, 5.05 ] ); - expected = new Uint16Array([ - toWord( 5.05 ), - toWord( 4.05 ), - toWord( 3.05 ), - toWord( 2.05 ), - toWord( 1.05 ) - ]); - out = arr.reverse(); - buf = new Uint16Array( arr.buffer ); - - t.strictEqual( instanceOf( arr, Float16Array ), true, 'returns expected value' ); - t.strictEqual( out, arr, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 10 ); - out = arr.reverse(); - - t.strictEqual( out.length, 10, 'returns expected value' ); - t.end(); -}); diff --git a/test/polyfill/test.set.js b/test/polyfill/test.set.js deleted file mode 100644 index d5e0ebb..0000000 --- a/test/polyfill/test.set.js +++ /dev/null @@ -1,259 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `set` method for setting one or more array elements', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.set ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.set.call( value, 0 ); - }; - } -}); - -tape( 'the method throws an error if provided an index argument which is not a nonnegative integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - -5, - 3.14, - 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.set( [ 1.0 ], value ); - }; - } -}); - -tape( 'the method throws an error if provided an index argument which is out-of-bounds', function test( t ) { - var values; - var arr1; - var arr2; - var i; - - arr1 = new Float16Array( 10 ); - arr2 = []; - for ( i = 0; i < arr1.length; i++ ) { - arr2.push( 1.0 ); - } - - values = [ - 1, - 2, - 3, - 4, - 5 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr1.set( arr2, value ); - }; - } -}); - -tape( 'the method sets one or more array elements', function test( t ) { - var arr; - var v; - var i; - - arr = new Float16Array( 10 ); - - v = arr[ 0 ]; - t.strictEqual( v, 0.0, 'returns expected value' ); - - // No index argument: - arr.set( [ 1.0 ] ); - - v = arr[ 0 ]; - t.strictEqual( v, 1.0, 'returns expected value' ); - - arr.set( [ 0.0 ] ); - - // Index argument: - for ( i = 0; i < arr.length; i++ ) { - v = arr[ i ]; - t.strictEqual( v, 0.0, 'returns expected value' ); - - arr.set( [ 1.05 ], i ); - - v = arr[ i ]; - t.strictEqual( v, float64ToFloat16( 1.05 ), 'returns expected value' ); - } - - // Multiple values, no index argument: - arr.set( [ 1.05, 2.05 ] ); - - v = arr[ 0 ]; - t.strictEqual( v, float64ToFloat16( 1.05 ), 'returns expected value' ); - - v = arr[ 1 ]; - t.strictEqual( v, float64ToFloat16( 2.05 ), 'returns expected value' ); - - // Multiple values, index argument: - arr.set( [ 1.05, 2.05 ], 2 ); - - v = arr[ 2 ]; - t.strictEqual( v, float64ToFloat16( 1.05 ), 'returns expected value' ); - - v = arr[ 3 ]; - t.strictEqual( v, float64ToFloat16( 2.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method sets an array element (floating-point number array; shared buffer)', function test( t ) { - var byteOffset; - var arr; - var src; - var buf; - var ab; - var v; - var i; - - byteOffset = 112; - - ab = new ArrayBuffer( 240 ); - arr = new Float16Array( ab, byteOffset, 10 ); - - // Overlapping (requires copy), multiple values, no index argument: - buf = [ 1.05, 2.05 ]; - src = new Float16Array( ab, byteOffset-(1*arr.BYTES_PER_ELEMENT), 2 ); - for ( i = 0; i < buf.length; i++ ) { - src[ i ] = buf[ i ]; - } - arr.set( src ); - - v = arr[ 0 ]; - t.strictEqual( v, float64ToFloat16( buf[ 0 ] ), 'returns expected value' ); - - v = arr[ 1 ]; - t.strictEqual( v, float64ToFloat16( buf[ 1 ] ), 'returns expected value' ); - - // Overlapping (requires copy), multiple values, index argument: - buf = [ -1.05, -2.05 ]; - src = new Float16Array( ab, byteOffset+(1*arr.BYTES_PER_ELEMENT), 2 ); - for ( i = 0; i < buf.length; i++ ) { - src[ i ] = buf[ i ]; - } - arr.set( src, 2 ); - - v = arr[ 2 ]; - t.strictEqual( v, float64ToFloat16( buf[ 0 ] ), 'returns expected value' ); - - v = arr[ 3 ]; - t.strictEqual( v, float64ToFloat16( buf[ 1 ] ), 'returns expected value' ); - - // Overlapping (no copy), multiple values, no index argument: - buf = [ 3.05, 4.05 ]; - src = new Float16Array( ab, byteOffset+(1*arr.BYTES_PER_ELEMENT), 2 ); - for ( i = 0; i < buf.length; i++ ) { - src[ i ] = buf[ i ]; - } - arr.set( src ); - - v = arr[ 0 ]; - t.strictEqual( v, float64ToFloat16( buf[ 0 ] ), 'returns expected value' ); - - v = arr[ 1 ]; - t.strictEqual( v, float64ToFloat16( buf[ 1 ] ), 'returns expected value' ); - - // Overlapping (no copy), multiple values, index argument: - buf = [ -3.05, -4.05 ]; - src = new Float16Array( ab, byteOffset+(3*arr.BYTES_PER_ELEMENT), 2 ); - for ( i = 0; i < buf.length; i++ ) { - src[ i ] = buf[ i ]; - } - arr.set( src, 2 ); - - v = arr[ 2 ]; - t.strictEqual( v, float64ToFloat16( buf[ 0 ] ), 'returns expected value' ); - - v = arr[ 3 ]; - t.strictEqual( v, float64ToFloat16( buf[ 1 ] ), 'returns expected value' ); - - t.end(); -}); diff --git a/test/polyfill/test.slice.js b/test/polyfill/test.slice.js deleted file mode 100644 index f6743cb..0000000 --- a/test/polyfill/test.slice.js +++ /dev/null @@ -1,311 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 instanceOf = require( '@stdlib/assert-instance-of' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `slice` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'slice' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.slice ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.slice.call( value ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.slice( value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.slice( 0, value ); - }; - } -}); - -tape( 'the method returns an empty typed array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.slice(); - - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'if called without arguments, the method returns a typed array containing the same elements as the original array', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ) - ]); - actual = arr.slice(); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.notEqual( actual, arr, 'returns a new instance' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if called with one argument, the method returns a typed array containing elements starting from a specified beginning index (inclusive)', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ) - ]); - actual = arr.slice( 1 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if provided two arguments, the method returns a typed array containing elements starting from a specified beginning index (inclusive) and ending at a specified stop index (exclusive)', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ) - ]); - actual = arr.slice( 1, 3 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ) - ]); - actual = arr.slice( 1, 30 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method resolves negative indices relative to the last element', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ) - ]); - actual = arr.slice( -3, -1 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ) - ]); - actual = arr.slice( -30, -2 ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty typed array if a resolved beginning index exceeds a resolved ending index', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array( [] ); - actual = arr.slice( 2, 0 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty typed array if a resolved beginning index exceeds the maximum array index', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array( [] ); - actual = arr.slice( 5 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty typed array if a resolved ending index is less than or equal to zero', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); - expected = new Uint16Array( [] ); - actual = arr.slice( 2, -8 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - - actual = arr.slice( 1, 0 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); diff --git a/test/polyfill/test.some.js b/test/polyfill/test.some.js deleted file mode 100644 index dfa9cda..0000000 --- a/test/polyfill/test.some.js +++ /dev/null @@ -1,196 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `some` method for returning boolean indicating whether at least one element passes a test', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'some' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.some ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.some.call( value, predicate ); - }; - } - - function predicate( v ) { - return v === 1.0; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.some( value ); - }; - } -}); - -tape( 'the method returns `false` if operating on an empty floating-point number array', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( 0 ); - bool = arr.some( predicate ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns `true` if at least one element passes a test', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - bool = arr.some( predicate ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v === float64ToFloat16( 1.05 ); - } -}); - -tape( 'the method returns `false` if all elements fail a test', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - bool = arr.some( predicate ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v === float64ToFloat16( 5.05 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var bool; - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - bool = arr.some( predicate, ctx ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v === float64ToFloat16( 4.05 ); - } -}); - -tape( 'the method stops executing upon encountering the first element which passes a test', function test( t ) { - var bool; - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - bool = arr.some( predicate, ctx ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.strictEqual( ctx.count, 1, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v === float64ToFloat16( 1.05 ); - } -}); diff --git a/test/polyfill/test.sort.js b/test/polyfill/test.sort.js deleted file mode 100644 index 1ebbfd6..0000000 --- a/test/polyfill/test.sort.js +++ /dev/null @@ -1,189 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 instanceOf = require( '@stdlib/assert-instance-of' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Comparison function. -* -* @private -* @param {boolean} a - first value for comparison -* @param {boolean} b - second value for comparison -* @returns {number} comparison result -*/ -function compareFcn( a, b ) { - if ( a < b ) { - return -1; - } - if ( a > b ) { - return 1; - } - return 0; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `sort` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'sort' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.sort ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.sort.call( value, compareFcn ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.sort( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.sort( compareFcn ); - - t.strictEqual( out.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the method sorts elements of a floating-point number array in-place', function test( t ) { - var expected; - var arr; - var out; - var buf; - - arr = new Float16Array( [ 4.05, 3.05, 1.05, 5.05, 2.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ), - toWord( 5.05 ) - ]); - out = arr.sort( compareFcn ); - buf = new Uint16Array( out.buffer ); - - t.strictEqual( instanceOf( arr, Float16Array ), true, 'returns expected value' ); - t.strictEqual( out, arr, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - - arr = new Float16Array( [ 2.05, 1.05, -1.05, 0.05, -2.05 ] ); - expected = new Uint16Array([ - toWord( -2.05 ), - toWord( -1.05 ), - toWord( 0.05 ), - toWord( 1.05 ), - toWord( 2.05 ) - ]); - out = arr.sort( compareFcn ); - buf = new Uint16Array( out.buffer ); - - t.strictEqual( instanceOf( arr, Float16Array ), true, 'returns expected value' ); - t.strictEqual( out, arr, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Float16Array( [ 4.05, 3.05, 1.05, 5.05, 2.05 ] ); - out = arr.sort( compareFcn ); - - t.strictEqual( out.length, arr.length, 'returns expected value' ); - t.end(); -}); diff --git a/test/polyfill/test.subarray.js b/test/polyfill/test.subarray.js deleted file mode 100644 index c6d42d1..0000000 --- a/test/polyfill/test.subarray.js +++ /dev/null @@ -1,308 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 instanceOf = require( '@stdlib/assert-instance-of' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `subarray` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'subarray' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.subarray ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.subarray.call( value ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.subarray( value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.subarray( 0, value ); - }; - } -}); - -tape( 'the method returns empty array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.subarray(); - - t.strictEqual( out.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'if called without arguments, the method returns a view containing the same elements as the original array', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ) - ]); - actual = arr.subarray(); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if called with one argument, the method returns a view containing elements starting from a specified beginning index (inclusive)', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ) - ]); - actual = arr.subarray( 1 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if provided two arguments, the method returns a view containing elements starting from a specified beginning index (inclusive) and ending at a specified stop index (exclusive)', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ) - ]); - actual = arr.subarray( 1, 3 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method resolves negative indices relative to the last element', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ) - ]); - actual = arr.subarray( -3, -1 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 2.05 ) - ]); - actual = arr.subarray( -30, -2 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty view if a resolved beginning index exceeds a resolved ending index', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array( [] ); - actual = arr.subarray( 2, 0 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty view if a resolved beginning index exceeds the maximum array index', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array( [] ); - actual = arr.subarray( 5 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty view if a resolved ending index is less than or equal to zero', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array( [] ); - actual = arr.subarray( 2, -8 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - - actual = arr.subarray( 1, 0 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); diff --git a/test/polyfill/test.to_locale_string.js b/test/polyfill/test.to_locale_string.js deleted file mode 100644 index 96fb9b0..0000000 --- a/test/polyfill/test.to_locale_string.js +++ /dev/null @@ -1,187 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `toLocaleString` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'toLocaleString' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.toLocaleString ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.toLocaleString.call( value ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a string or an array of strings', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 0 ); - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - {}, - [ 1, 2, 3 ], - 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.toLocaleString( value ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a string or an array of strings (options)', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 0 ); - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - {}, - [ 1, 2, 3 ], - 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.toLocaleString( value, {} ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an object', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array(); - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - 'beep', - [], - 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.toLocaleString( 'en-GB', value ); - }; - } -}); - -tape( 'the method returns an empty string if invoked on an empty array', function test( t ) { - var str; - var arr; - - arr = new Float16Array( 0 ); - str = arr.toLocaleString(); - - t.strictEqual( str, '', 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a string representation of a floating-point number array', function test( t ) { - var expected; - var str; - var arr; - - arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - expected = '1,2,3'; - - str = arr.toLocaleString(); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); diff --git a/test/polyfill/test.to_reversed.js b/test/polyfill/test.to_reversed.js deleted file mode 100644 index a3f8da5..0000000 --- a/test/polyfill/test.to_reversed.js +++ /dev/null @@ -1,121 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 instanceOf = require( '@stdlib/assert-instance-of' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, '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( Float16Array.prototype, 'toReversed' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.toReversed ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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 floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - 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 buf; - var out; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05, 5.05 ] ); - expected = new Uint16Array([ - toWord( 5.05 ), - toWord( 4.05 ), - toWord( 3.05 ), - toWord( 2.05 ), - toWord( 1.05 ) - ]); - out = arr.toReversed(); - buf = new Uint16Array( out.buffer ); - - t.strictEqual( instanceOf( out, Float16Array ), true, 'returns expected value' ); - t.notEqual( out, arr, 'returns a new instance' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 10 ); - out = arr.toReversed(); - - t.strictEqual( out.length, 10, 'returns expected value' ); - t.end(); -}); diff --git a/test/polyfill/test.to_sorted.js b/test/polyfill/test.to_sorted.js deleted file mode 100644 index e011bef..0000000 --- a/test/polyfill/test.to_sorted.js +++ /dev/null @@ -1,172 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 instanceOf = require( '@stdlib/assert-instance-of' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Comparison function. -* -* @private -* @param {boolean} a - first value for comparison -* @param {boolean} b - second value for comparison -* @returns {number} comparison result -*/ -function compareFcn( a, b ) { - if ( a < b ) { - return -1; - } - if ( a > b ) { - return 1; - } - return 0; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `toSorted` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'toSorted' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.toSorted ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.toSorted.call( value, compareFcn ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.toSorted( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.toSorted( compareFcn ); - - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a new typed array containing elements in sorted order', function test( t ) { - var expected; - var arr; - var out; - var buf; - - arr = new Float16Array( [ 4.05, 3.05, 1.05, 5.05, 2.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ), - toWord( 5.05 ) - ]); - out = arr.toSorted( compareFcn ); - buf = new Uint16Array( out.buffer ); - - t.strictEqual( instanceOf( out, Float16Array ), true, 'returns expected value' ); - t.notEqual( out, arr, 'returns a new instance' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Float16Array( [ 4.05, 3.05, 1.05, 5.05, 2.05 ] ); - out = arr.toSorted( compareFcn ); - - t.strictEqual( out.length, arr.length, 'returns expected value' ); - t.end(); -}); diff --git a/test/polyfill/test.to_string.js b/test/polyfill/test.to_string.js deleted file mode 100644 index b0c098b..0000000 --- a/test/polyfill/test.to_string.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `toString` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.toString ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.toString.call( value ); - }; - } -}); - -tape( 'the method returns an empty string if invoked on an empty array', function test( t ) { - var str; - var arr; - - arr = new Float16Array( 0 ); - str = arr.toString(); - - t.strictEqual( str, '', 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a string representation of a floating-point number array', function test( t ) { - var expected; - var str; - var arr; - - arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - expected = '1,2,3,4'; - - str = arr.toString(); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); diff --git a/test/polyfill/test.values.js b/test/polyfill/test.values.js deleted file mode 100644 index ce5fc09..0000000 --- a/test/polyfill/test.values.js +++ /dev/null @@ -1,264 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 proxyquire = require( 'proxyquire' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var isNumber = require( '@stdlib/assert-is-number' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `values` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'values' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.values ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.values.call( value ); - }; - } -}); - -tape( 'the method returns an iterator protocol-compliant object', function test( t ) { - var expected; - var arr; - var it; - var i; - var r; - var e; - - arr = new Float16Array( [ 1.05, 2.05 ] ); - expected = [ - { - 'value': float64ToFloat16( 1.05 ), - 'done': false - }, - { - 'value': float64ToFloat16( 2.05 ), - 'done': false - }, - { - 'done': true - } - ]; - it = arr.values(); - - t.strictEqual( typeof it, 'object', 'returns expected value' ); - t.strictEqual( typeof it.next, 'function', 'has next method' ); - - for ( i = 0; i < expected.length; i++ ) { - r = it.next(); - e = expected[ i ]; - if ( e.value === void 0 ) { - t.deepEqual( r, e, 'returns expected value' ); - } else { - t.strictEqual( isNumber( r.value ), true, 'returns expected value' ); - t.strictEqual( r.value, e.value, 'returns expected value' ); - t.strictEqual( r.done, e.done, 'returns expected value' ); - } - } - - t.end(); -}); - -tape( 'the method returns an iterator which does not iterate over empty arrays', function test( t ) { - var expected; - var arr; - var it; - var i; - var v; - - arr = new Float16Array( [] ); - expected = [ - { - 'done': true - }, - { - 'done': true - }, - { - 'done': true - } - ]; - it = arr.values(); - - t.strictEqual( typeof it, 'object', 'returns expected value' ); - t.strictEqual( typeof it.next, 'function', 'has next method' ); - - for ( i = 0; i < expected.length; i++ ) { - v = it.next(); - t.deepEqual( v, expected[ i ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (no argument)', function test( t ) { - var arr; - var it; - var v; - - arr = new Float16Array( [ 1.05, 2.05, 3.05 ] ); - it = arr.values(); - - v = it.next(); - t.strictEqual( v.value, float64ToFloat16( 1.05 ), 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, float64ToFloat16( 2.05 ), 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.return(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (argument)', function test( t ) { - var arr; - var it; - var v; - - arr = new Float16Array( [ 1.05, 2.05, 3.05 ] ); - it = arr.values(); - - v = it.next(); - t.strictEqual( v.value, float64ToFloat16( 1.05 ), 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, float64ToFloat16( 2.05 ), 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.return( 'beep' ); - t.strictEqual( v.value, 'beep', 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'if an environment supports `Symbol.iterator`, the method returns an iterable', function test( t ) { - var Float16Array; - var arr; - var buf; - var it1; - var it2; - var v1; - var v2; - var i; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - buf = [ 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( buf ); - - it1 = arr.values(); - t.strictEqual( typeof it1[ '__ITERATOR_SYMBOL__' ], 'function', 'has method' ); - t.strictEqual( it1[ '__ITERATOR_SYMBOL__' ].length, 0, 'has zero arity' ); - - it2 = it1[ '__ITERATOR_SYMBOL__' ](); - t.strictEqual( typeof it2, 'object', 'returns expected value' ); - t.strictEqual( typeof it2.next, 'function', 'has `next` method' ); - t.strictEqual( typeof it2.return, 'function', 'has `return` method' ); - - for ( i = 0; i < arr.length; i++ ) { - v1 = it1.next().value; - v2 = it2.next().value; - t.strictEqual( v1, v2, 'returns expected value' ); - } - t.end(); -}); - -tape( 'if an environment does not support `Symbol.iterator`, the method does not return an "iterable"', function test( t ) { - var Float16Array; - var arr; - var buf; - var it; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/symbol-iterator': false - }); - - buf = [ 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( buf ); - - it = arr.values(); - t.strictEqual( it[ ITERATOR_SYMBOL ], void 0, 'does not have property' ); - - t.end(); -}); diff --git a/test/polyfill/test.with.js b/test/polyfill/test.with.js deleted file mode 100644 index 0b6eda1..0000000 --- a/test/polyfill/test.with.js +++ /dev/null @@ -1,213 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `with` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'with' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.with ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.with.call( value, 0, true ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 3.14, - 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.with( value, true ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not in bounds', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - -11, - -12, - 11, - 12 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.with( value, 1.0 ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not a numeric value', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 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.with( 0, value ); - }; - } -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 10 ); - out = arr.with( 5, 1.0 ); - - t.strictEqual( out.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a new floating-point number array with the element at a provided index replaced with a provided value', function test( t ) { - var expected; - var arr; - var buf; - var out; - - arr = new Float16Array( [ 1.05, 1.05, 1.05, 1.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 1.05 ), - toWord( 1.05 ), - toWord( 2.05 ) - ]); - out = arr.with( 3, 2.05 ); - buf = new Uint16Array( out.buffer ); - - t.strictEqual( out instanceof Float16Array, true, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.notEqual( out, arr, 'returns new instance' ); - t.end(); -}); - -tape( 'the method supports negative indices', function test( t ) { - var expected; - var arr; - var buf; - var out; - - arr = new Float16Array( [ 1.05, 1.05, 1.05, 1.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 1.05 ), - toWord( 1.05 ), - toWord( 2.05 ) - ]); - out = arr.with( -1, 2.05 ); - buf = new Uint16Array( out.buffer ); - - t.strictEqual( out instanceof Float16Array, true, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.at.js b/test/test.at.js deleted file mode 100644 index 19df3bd..0000000 --- a/test/test.at.js +++ /dev/null @@ -1,111 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `at` method for returning an array element', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.at ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.at.call( value, 0 ); - }; - } -}); - -tape( 'the method returns `undefined` if provided an index which exceeds array dimensions', function test( t ) { - var arr; - var v; - var i; - - arr = new Float16Array( 10 ); - for ( i = -arr.length; i < arr.length; i++ ) { - if ( i < 0 ) { - v = arr.at( i-arr.length ); - t.strictEqual( v, void 0, 'returns expected value for index '+(i-arr.length) ); - } else { - v = arr.at( arr.length+i ); - t.strictEqual( v, void 0, 'returns expected value for index '+(arr.length+i) ); - } - } - t.end(); -}); - -tape( 'the method returns an array element', function test( t ) { - var arr; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( i+0.05 ); - } - - arr = new Float16Array( arr ); - - for ( i = -arr.length; i < arr.length; i++ ) { - v = arr.at( i ); - if ( i < 0 ) { - t.strictEqual( v, float64ToFloat16( arr.length + i + 0.05 ), 'returns expected value for index '+i ); - } else { - t.strictEqual( v, float64ToFloat16( i + 0.05 ), 'returns expected value for index '+i ); - } - } - t.end(); -}); diff --git a/test/test.copy_within.js b/test/test.copy_within.js deleted file mode 100644 index d286509..0000000 --- a/test/test.copy_within.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `copyWithin` method for copying a sequence of array elements within a floating-point number array', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within an array', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( 0, 3 ); - buf = new Uint16Array( arr.buffer ); - - // Overwritten: - t.strictEqual( buf[ 0 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 4.05 ), 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 2 ], toWord( 2.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (negative target)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( -arr.length, 3 ); - buf = new Uint16Array( arr.buffer ); - - // Overwritten: - t.strictEqual( buf[ 0 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 4.05 ), 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 2 ], toWord( 2.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (negative start)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( 0, -2 ); - buf = new Uint16Array( arr.buffer ); - - // Overwritten: - t.strictEqual( buf[ 0 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 4.05 ), 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 2 ], toWord( 2.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (end=length)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( 0, 3, arr.length ); - buf = new Uint16Array( arr.buffer ); - - // Overwritten: - t.strictEqual( buf[ 0 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 4.05 ), 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 2 ], toWord( 2.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (non-inclusive end)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( 2, 0, 2 ); - buf = new Uint16Array( arr.buffer ); - - // Remain the same: - t.strictEqual( buf[ 0 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - - // Overwritten: - t.strictEqual( buf[ 2 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 1.05 ), 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (negative end)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( 2, 0, -3 ); - buf = new Uint16Array( arr.buffer ); - - // Remain the same: - t.strictEqual( buf[ 0 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - - // Overwritten: - t.strictEqual( buf[ 2 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 1.05 ), 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (target >= length)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( arr.length, 3 ); - buf = new Uint16Array( arr.buffer ); - - // Remain the same: - t.strictEqual( buf[ 0 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 2 ], toWord( 2.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (target > start)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( 2, 0 ); - buf = new Uint16Array( arr.buffer ); - - // Remain the same: - t.strictEqual( buf[ 0 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - - // Overwritten: - t.strictEqual( buf[ 2 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 4 ], toWord( 2.05 ), 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.entries.js b/test/test.entries.js deleted file mode 100644 index 396dd8e..0000000 --- a/test/test.entries.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isNumber = require( '@stdlib/assert-is-number' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `entries` method for returning an iterator for iterating over array key-value pairs', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.entries ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.entries.call( value ); - }; - } -}); - -tape( 'the method returns an iterator protocol-compliant object', function test( t ) { - var buf; - var arr; - var it; - var v; - var i; - - buf = [ 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( buf ); - - it = arr.entries(); - t.strictEqual( it.next.length, 0, 'has zero arity' ); - - for ( i = 0; i < arr.length; i++ ) { - v = it.next(); - t.strictEqual( isArray( v.value ), true, 'returns expected value' ); - t.strictEqual( v.value[ 0 ], i, 'returns expected value' ); - t.strictEqual( isNumber( v.value[ 1 ] ), true, 'returns expected value' ); - t.strictEqual( v.value[ 1 ], float64ToFloat16( buf[ i ] ), 'returns expected value' ); - t.strictEqual( typeof v.done, 'boolean', 'returns expected value' ); - } - t.end(); -}); diff --git a/test/test.every.js b/test/test.every.js deleted file mode 100644 index 0742d6a..0000000 --- a/test/test.every.js +++ /dev/null @@ -1,172 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `every` method for returning boolean indicating whether all elements pass a test', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.every ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.every.call( value, predicate ); - }; - } - - function predicate( v ) { - return v === 0.0; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.every( value ); - }; - } -}); - -tape( 'the method returns `true` if operating on an empty floating-point number array', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( 0 ); - bool = arr.every( predicate ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns `true` if all elements pass a test', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 1.05, 1.05, 1.05 ] ); - bool = arr.every( predicate ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v === float64ToFloat16( 1.05 ); - } -}); - -tape( 'the method returns `false` if one or more elements fail a test', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 1.05, 0.05, 1.05 ] ); - bool = arr.every( predicate ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v === float64ToFloat16( 1.05 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var bool; - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ 1.05, 1.05, 1.05, 1.05 ] ); - bool = arr.every( predicate, ctx ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v === float64ToFloat16( 1.05 ); - } -}); diff --git a/test/test.fill.js b/test/test.fill.js deleted file mode 100644 index d434060..0000000 --- a/test/test.fill.js +++ /dev/null @@ -1,212 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `fill` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.fill ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.fill.call( value, 1.0 ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.fill( 1.05 ); - - t.strictEqual( out instanceof Float16Array, true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 10 ); - out = arr.fill( 1.05 ); - - t.strictEqual( out, arr, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'if called with one argument, the method sets each array element to the provided value', function test( t ) { - var arr; - var buf; - var i; - - arr = new Float16Array( 3 ); - arr.fill( 1.05 ); - - buf = new Uint16Array( arr.buffer ); - - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( buf[ i ], toWord( 1.05 ), 'returns expected value' ); - } - - t.end(); -}); - -tape( 'if called with two arguments, the method sets each array element to the provided value starting from a start index (inclusive)', function test( t ) { - var arr; - var buf; - - arr = new Float16Array( 3 ); - buf = new Uint16Array( arr.buffer ); - - arr.fill( 1.05, 1 ); - - t.strictEqual( buf[ 0 ], toWord( 0.0 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 2 ], toWord( 1.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'if called with three arguments, the method sets each array element to the provided value starting from a start index (inclusive) until a specified end index (exclusive)', function test( t ) { - var arr; - var buf; - - arr = new Float16Array( 3 ); - buf = new Uint16Array( arr.buffer ); - - arr.fill( 1.05, 0, 2 ); - - t.strictEqual( buf[ 0 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 2 ], toWord( 0.0 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method supports negative indices', function test( t ) { - var arr; - var buf; - - arr = new Float16Array( 3 ); - buf = new Uint16Array( arr.buffer ); - - arr.fill( 1.05, -3, -1 ); - - t.strictEqual( buf[ 0 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 2 ], toWord( 0.0 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'if a provided start index resolves to a negative index, the method fills an array starting from the first element', function test( t ) { - var arr; - var buf; - var i; - - arr = new Float16Array( 3 ); - buf = new Uint16Array( arr.buffer ); - - arr.fill( 1.05, -10 ); - - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( buf[ i ], toWord( 1.05 ), 'returns expected value' ); - } - - t.end(); -}); - -tape( 'if a provided end index resolves to an index exceeding the last array element index, the method fills an array until the last element (inclusive)', function test( t ) { - var arr; - var buf; - var i; - - arr = new Float16Array( 3 ); - buf = new Uint16Array( arr.buffer ); - - arr.fill( 1.05, 1, 10 ); - - t.strictEqual( buf[ 0 ], toWord( 0.0 ), 'returns expected value' ); - for ( i = 1; i < arr.length; i++ ) { - t.strictEqual( buf[ i ], toWord( 1.05 ), 'returns expected value' ); - } - - t.end(); -}); - -tape( 'if a provided start index resolves to an index which is greater than or equal to a resolved end index, the method does not fill an array', function test( t ) { - var arr; - var buf; - - arr = new Float16Array( 3 ); - buf = new Uint16Array( arr.buffer ); - - arr.fill( 1.0, 2, 1 ); - - t.strictEqual( buf[ 0 ], toWord( 0.0 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 0.0 ), 'returns expected value' ); - t.strictEqual( buf[ 2 ], toWord( 0.0 ), 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.filter.js b/test/test.filter.js deleted file mode 100644 index 1b77a61..0000000 --- a/test/test.filter.js +++ /dev/null @@ -1,224 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `filter` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.filter ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.filter.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( v === 1.0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.filter( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.filter( predicate ); - - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v === 1.0 ); - } -}); - -tape( 'the method returns a new floating-point number array containing only those elements which satisfy a test condition', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 1.05, 2.05 ] ); - expected = new Uint16Array( [ toWord( 1.05 ), toWord( 1.05 ) ] ); - actual = arr.filter( predicate ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v === float64ToFloat16( 1.05 ) ); - } -}); - -tape( 'the method copies all elements to a new array if all elements satisfy a test condition', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ) - ]); - actual = arr.filter( predicate ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.notEqual( actual, arr, 'returns a new instance' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v > 1.0 ); - } -}); - -tape( 'the method returns an empty array if no elements satisfy a test condition', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array( [] ); - actual = arr.filter( predicate ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.notEqual( actual, arr, 'returns a new instance' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 1.0 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var expected; - var actual; - var arr; - var buf; - var ctx; - - arr = new Float16Array( [ 1.05, 2.05, 1.05, 1.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 1.05 ), - toWord( 1.05 ) - ]); - ctx = { - 'count': 0 - }; - actual = arr.filter( predicate, ctx ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v === float64ToFloat16( 1.05 ) ); - } -}); diff --git a/test/test.find.js b/test/test.find.js deleted file mode 100644 index 1836dc3..0000000 --- a/test/test.find.js +++ /dev/null @@ -1,172 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `find` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.find ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.find.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( v === 1.0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.find( value ); - }; - } -}); - -tape( 'the method returns `undefined` if operating on an empty floating-point number array', function test( t ) { - var arr; - var v; - - arr = new Float16Array( 0 ); - v = arr.find( predicate ); - - t.strictEqual( v, void 0, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns the first element which passes a test', function test( t ) { - var arr; - var v; - - arr = new Float16Array( [ 1.05, -2.05, 3.05, -4.05 ] ); - v = arr.find( predicate ); - - t.strictEqual( v, float64ToFloat16( -2.05 ), 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method returns `undefined` if all elements fail a test', function test( t ) { - var arr; - var v; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - v = arr.find( predicate ); - - t.strictEqual( v, void 0, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - var v; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ -1.05, -2.05, 3.05, 4.05, 5.05 ] ); - v = arr.find( predicate, ctx ); - - t.strictEqual( v, float64ToFloat16( 3.05 ), 'returns expected value' ); - t.strictEqual( ctx.count, 3, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v > 0.0 ); - } -}); diff --git a/test/test.find_index.js b/test/test.find_index.js deleted file mode 100644 index b3e9023..0000000 --- a/test/test.find_index.js +++ /dev/null @@ -1,171 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `findIndex` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.findIndex ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.findIndex.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( v === 1.0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.findIndex( value ); - }; - } -}); - -tape( 'the method returns `-1` if operating on an empty floating-point number array', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( 0 ); - idx = arr.findIndex( predicate ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns the index of the first element which passes a test', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( [ 1.05, -2.05, 3.05, -4.05 ] ); - idx = arr.findIndex( predicate ); - - t.strictEqual( idx, 1, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0); - } -}); - -tape( 'the method returns `-1` if all elements fail a test', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - idx = arr.findIndex( predicate ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - var idx; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ -1.05, -2.05, 3.05, 4.05, 5.05 ] ); - idx = arr.findIndex( predicate, ctx ); - - t.strictEqual( idx, 2, 'returns expected value' ); - t.strictEqual( ctx.count, 3, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v > 0.0 ); - } -}); diff --git a/test/test.find_last.js b/test/test.find_last.js deleted file mode 100644 index 4451b22..0000000 --- a/test/test.find_last.js +++ /dev/null @@ -1,172 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `findLast` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.findLast ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.findLast.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( v === 0.0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.findLast( value ); - }; - } -}); - -tape( 'the method returns `undefined` if operating on an empty floating-point number array', function test( t ) { - var arr; - var v; - - arr = new Float16Array( 0 ); - v = arr.findLast( predicate ); - - t.strictEqual( v, void 0, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns the last element which passes a test', function test( t ) { - var arr; - var v; - - arr = new Float16Array( [ 1.05, -2.05, 3.05, -4.05 ] ); - v = arr.findLast( predicate ); - - t.strictEqual( v, float64ToFloat16( -4.05 ), 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method returns `undefined` if all elements fail a test', function test( t ) { - var arr; - var v; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - v = arr.findLast( predicate ); - - t.strictEqual( v, void 0, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - var v; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ -1.05, -2.05, 3.05, 4.05, 5.05 ] ); - v = arr.findLast( predicate, ctx ); - - t.strictEqual( v, float64ToFloat16( 5.05 ), 'returns expected value' ); - t.strictEqual( ctx.count, 1, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v > 0.0 ); - } -}); diff --git a/test/test.find_last_index.js b/test/test.find_last_index.js deleted file mode 100644 index c303468..0000000 --- a/test/test.find_last_index.js +++ /dev/null @@ -1,171 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `findLastIndex` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.findLastIndex ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.findLastIndex.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( v === 1.0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.findLastIndex( value ); - }; - } -}); - -tape( 'the method returns `-1` if operating on an empty floating-point number array', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( 0 ); - idx = arr.findLastIndex( predicate ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns the index of the last element which passes a test', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( [ 1.05, -2.05, 3.05, -4.05 ] ); - idx = arr.findLastIndex( predicate ); - - t.strictEqual( idx, 3, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method returns `-1` if all elements fail a test', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - idx = arr.findLastIndex( predicate ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - var idx; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ -1.05, -2.05, 3.05, 4.05, 5.05 ] ); - idx = arr.findLastIndex( predicate, ctx ); - - t.strictEqual( idx, 4, 'returns expected value' ); - t.strictEqual( ctx.count, 1, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v > 0.0 ); - } -}); diff --git a/test/test.for_each.js b/test/test.for_each.js deleted file mode 100644 index af6afda..0000000 --- a/test/test.for_each.js +++ /dev/null @@ -1,194 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `forEach` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.forEach ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.forEach.call( value, fcn ); - }; - } - - function fcn( v ) { - if ( !isNumber( v ) ) { - t.fail( 'should be a number' ); - } - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.forEach( value ); - }; - } -}); - -tape( 'the method should not invoke a provided callback function if operating on an empty floating-point array', function test( t ) { - var arr; - - arr = new Float16Array( 0 ); - arr.forEach( fcn ); - - t.end(); - - function fcn() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns `undefined`', function test( t ) { - var arr; - var out; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - out = arr.forEach( fcn ); - - t.strictEqual( out, void 0, 'returns expected value' ); - t.end(); - - function fcn( v ) { - if ( !isNumber( v ) ) { - t.fail( 'should be a number' ); - } - } -}); - -tape( 'the method invokes a provided function for each element in an array', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var arr; - - indices = []; - values = []; - arrays = []; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - arr.forEach( fcn ); - - expected = [ - float64ToFloat16( 1.05 ), - float64ToFloat16( 2.05 ), - float64ToFloat16( 3.05 ), - float64ToFloat16( 4.05 ) - ]; - - t.deepEqual( values, expected, 'returns expected value' ); - t.deepEqual( indices, [ 0, 1, 2, 3 ], 'returns expected value' ); - t.strictEqual( arrays[ 0 ], arr, 'returns expected value' ); - t.strictEqual( arrays[ 1 ], arr, 'returns expected value' ); - t.strictEqual( arrays[ 2 ], arr, 'returns expected value' ); - t.strictEqual( arrays[ 3 ], arr, 'returns expected value' ); - - t.end(); - - function fcn( v, i, arr ) { - values.push( v ); - indices.push( i ); - arrays.push( arr ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - arr.forEach( fcn, ctx ); - - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function fcn() { - this.count += 1; // eslint-disable-line no-invalid-this - } -}); diff --git a/test/test.from.js b/test/test.from.js deleted file mode 100644 index 15a43a2..0000000 --- a/test/test.from.js +++ /dev/null @@ -1,309 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 Uint16Array = require( '@stdlib/array-uint16' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is a `from` method for creating a 16-bit floating-point number array from an array-like object or an iterable', function test( t ) { - var arr; - - t.strictEqual( isFunction( Float16Array.from ), true, 'has method' ); - - arr = Float16Array.from( [] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a constructor', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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 Float16Array.from.call( value, [] ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array constructor', function test( t ) { - var values; - var i; - - values = [ - {}, - null, - 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 Float16Array.from.call( value, [] ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - {}, - [] - ]; - 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 Float16Array.from( [], value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not a function (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - {}, - [] - ]; - 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 Float16Array.from( [], value, {} ); - }; - } -}); - -tape( 'the method returns a floating-point number array', function test( t ) { - var arr; - var v; - - // Generic array: - arr = Float16Array.from( [] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Float16Array.from( [ 1.0, 2.0, 3.0, 4.0 ] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - // Generic array containing non-numeric values: - arr = Float16Array.from( [ 'beep' ] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - arr = Float16Array.from( [ null, 4 ] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - arr = Float16Array.from( [ true, {}, '' ] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 3, 'returns expected value' ); - - // Typed array: - arr = Float16Array.from( new Uint16Array( 0 ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Float16Array.from( new Uint16Array( [ 1, 1 ] ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // Floating-point number typed array: - arr = Float16Array.from( new Float16Array( 0 ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Float16Array.from( new Float16Array( [ 1.0, 2.0 ] ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method supports providing a "map" function which is invoked for each source element', function test( t ) { - var arr; - var v; - - // Generic array: - arr = Float16Array.from( [], clbk1 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Float16Array.from( [ 1.0, 2.0, 3.0, 4.0 ], clbk1 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - // Generic array containing non-numeric values: - arr = Float16Array.from( [ 'beep' ], clbk2 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - arr = Float16Array.from( [ null ], clbk2 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - arr = Float16Array.from( [ [], {} ], clbk1 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - arr = Float16Array.from( [ 4, 5 ], clbk1 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // Typed array: - arr = Float16Array.from( new Uint16Array( 0 ), clbk1 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Float16Array.from( new Uint16Array( [ 1, 1 ] ), clbk1 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // Floating-point number typed array: - arr = Float16Array.from( new Float16Array( 0 ), clbk2 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Float16Array.from( new Float16Array( [ true, true ] ), clbk2 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - t.end(); - - function clbk1( v ) { - return v; - } - - function clbk2() { - return true; - } -}); - -tape( 'the method supports providing a `this` context for a provided map function', function test( t ) { - var arr; - var ctx; - - ctx = { - 'count': 0 - }; - arr = Float16Array.from( [ 1.0, 2.0, 3.0, 4.0 ], clbk1, ctx ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function clbk1( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v; - } -}); diff --git a/test/test.includes.js b/test/test.includes.js deleted file mode 100644 index a367b40..0000000 --- a/test/test.includes.js +++ /dev/null @@ -1,160 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `includes` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.includes ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.includes.call( value, true ); - }; - } -}); - -tape( 'the method returns `false` if operating on an empty floating-point number array', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( 0 ); - bool = arr.includes( 1.0 ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `false` if a floating-point number is not found', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( 10 ); - bool = arr.includes( 1.0 ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `true` if an array contains a specified floating-point number', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05] ); - bool = arr.includes( float64ToFloat16( 1.05 ) ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `false` if provided a second argument which exceeds the input array length', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( 10 ); - bool = arr.includes( 0.0, 20 ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 1.05, 1.05, 1.05 ] ); - - bool = arr.includes( float64ToFloat16( 1.05 ), 0 ); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = arr.includes( float64ToFloat16( 2.05 ), 1 ); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = arr.includes( float64ToFloat16( 2.05 ), 3 ); - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index (negative)', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 1.05, 1.05, 1.05 ] ); - - bool = arr.includes( float64ToFloat16( 1.05 ), -5 ); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = arr.includes( float64ToFloat16( 2.05 ), -2 ); - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'when provided a starting index which resolves to an index which is less than zero, the method searches from the first array element', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 1.05, 1.05, 1.05 ] ); - - bool = arr.includes( float64ToFloat16( 1.05 ), -10 ); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = arr.includes( float64ToFloat16( 2.05 ), -10 ); - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.index_of.js b/test/test.index_of.js deleted file mode 100644 index 2a684aa..0000000 --- a/test/test.index_of.js +++ /dev/null @@ -1,160 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `indexOf` method for returning the index of an array element', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.indexOf ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.indexOf.call( value, 1.0 ); - }; - } -}); - -tape( 'the method returns `-1` if operating on an empty floating-point number array', function test( t ) { - var arr; - var idx; - - arr = new Float16Array(); - idx = arr.indexOf( 1.0 ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `-1` if a numeric value is not found', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( 10 ); - idx = arr.indexOf( 1.0 ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns the index of the first match if a numeric value is found', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - idx = arr.indexOf( float64ToFloat16( 2.05 ) ); - - t.strictEqual( idx, 1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `-1` if provided a second argument which exceeds the input array length', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( 10 ); - idx = arr.indexOf( 1.0, 20 ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 2.05, 5.05 ] ); - - idx = arr.indexOf( float64ToFloat16( 2.05 ), 0 ); - t.strictEqual( idx, 1, 'returns expected value' ); - - idx = arr.indexOf( float64ToFloat16( 2.05 ), 2 ); - t.strictEqual( idx, 3, 'returns expected value' ); - - idx = arr.indexOf( float64ToFloat16( 2.05 ), 4 ); - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index (negative)', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 2.05, 5.05 ] ); - - idx = arr.indexOf( float64ToFloat16( 2.05 ), -5 ); - t.strictEqual( idx, 1, 'returns expected value' ); - - idx = arr.indexOf( float64ToFloat16( 2.05 ), -1 ); - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'when provided a starting index which resolves to an index which is less than zero, the method searches from the first array element', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 2.05, 5.05 ] ); - - idx = arr.indexOf( float64ToFloat16( 2.05 ), -10 ); - t.strictEqual( idx, 1, 'returns expected value' ); - - idx = arr.indexOf( float64ToFloat16( 1.05 ), -10 ); - t.strictEqual( idx, 0, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.join.js b/test/test.join.js deleted file mode 100644 index 800bb1f..0000000 --- a/test/test.join.js +++ /dev/null @@ -1,141 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `join` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.join ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.join.call( value ); - }; - } -}); - -tape( 'the method returns an empty string if invoked on an empty array', function test( t ) { - var str; - var arr; - - arr = new Float16Array( 0 ); - str = arr.join(); - - t.strictEqual( str, '', 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a string representation of a floating-point number array with elements separated by a separator', function test( t ) { - var expected; - var str; - var arr; - var i; - - arr = new Float16Array( [ 0.05, 1.05, 2.05, 3.05, 4.05 ] ); - - expected = float64ToFloat16( 0.05 ); - for ( i = 1; i < arr.length; i++ ) { - expected += '@' + float64ToFloat16( i + 0.05 ); - } - - str = arr.join( '@' ); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a string representation of a floating-point number array with elements separated by a separator (single element)', function test( t ) { - var expected; - var str; - var arr; - - arr = new Float16Array( [ 1.05 ] ); - expected = '' + float64ToFloat16( 1.05 ); - - str = arr.join(); - - t.strictEqual( str, expected, 'returns expected value' ); - - arr = new Float16Array( [ 1.05 ] ); - expected = '' + float64ToFloat16( 1.05 ); - - str = arr.join( '@' ); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if the method is invoked without a separator argument, the method returns a string representation of a floating-point number array with elements separated by a comma', function test( t ) { - var expected; - var str; - var arr; - var i; - - arr = new Float16Array( [ 0.05, 1.05, 2.05, 3.05, 4.05 ] ); - - expected = float64ToFloat16( 0.05 ); - for ( i = 1; i < arr.length; i++ ) { - expected += ',' + float64ToFloat16( i + 0.05 ); - } - - str = arr.join(); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 930feef..0000000 --- a/test/test.js +++ /dev/null @@ -1,320 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var arr = new Float16Array( 0 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (no argument)', function test( t ) { - var arr = new Float16Array(); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (length)', function test( t ) { - var arr = new Float16Array( 10 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (array)', function test( t ) { - var arr = new Float16Array( [] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (typed array)', function test( t ) { - var arr = new Float16Array( new Uint16Array( 0 ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (ArrayBuffer)', function test( t ) { - var arr = new Float16Array( new ArrayBuffer( 0 ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (ArrayBuffer, byte offset)', function test( t ) { - var arr = new Float16Array( new ArrayBuffer( 8 ), 8 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (ArrayBuffer, byte offset, length)', function test( t ) { - var arr = new Float16Array( new ArrayBuffer( 8 ), 8, 0 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the constructor is a property returning the number of bytes per array element', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Float16Array.BYTES_PER_ELEMENT, 2, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the constructor is a property returning the constructor name', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array, 'name' ), true, 'has property' ); - t.strictEqual( Float16Array.name, 'Float16Array', 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance having a `BYTES_PER_ELEMENT` property returning the number of bytes per array element', function test( t ) { - var arr; - - t.strictEqual( hasOwnProp( Float16Array.prototype, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Float16Array.prototype.BYTES_PER_ELEMENT, 2, 'returns expected value' ); - - arr = new Float16Array( 0 ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance having a `buffer` property for returning the underlying memory (i.e., ArrayBuffer)', function test( t ) { - var arr; - var buf; - - arr = new Float16Array( 0 ); - buf = arr.buffer; - t.strictEqual( isArrayBuffer( buf ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance having a `byteLength` property for returning the number of bytes belonging to the array view', function test( t ) { - var arr; - var v; - - arr = new Float16Array( 0 ); - v = arr.byteLength; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( new ArrayBuffer( 64 ), 8 ); - v = arr.byteLength; - t.strictEqual( v, 56, 'returns expected value' ); - - arr = new Float16Array( new ArrayBuffer( 64 ), 64 ); - v = arr.byteLength; - t.strictEqual( v, 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance having a `byteOffset` property for returning the byte offset pointing to the first array element in the underlying memory', function test( t ) { - var arr; - var v; - - arr = new Float16Array( 0 ); - v = arr.byteOffset; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( new ArrayBuffer( 64 ), 32 ); - v = arr.byteOffset; - t.strictEqual( v, 32, 'returns expected value' ); - - arr = new Float16Array( new ArrayBuffer( 64 ), 64 ); - v = arr.byteOffset; - t.strictEqual( v, 64, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance having a `length` property for returning the number of array elements', function test( t ) { - var arr; - var v; - - // No arguments: - arr = new Float16Array(); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - // Explicit array length: - arr = new Float16Array( 0 ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( 10 ); - v = arr.length; - t.strictEqual( v, 10, 'returns expected value' ); - - // Generic array: - arr = new Float16Array( [] ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - // Typed array: - arr = new Float16Array( new Uint16Array( 0 ) ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( new Uint16Array( [ 1.0, 1.0 ] ) ); - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // Float16 typed array: - arr = new Float16Array( new Float16Array( 0 ) ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( new Float16Array( [ 1.0, 2.0 ] ) ); - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // ArrayBuffer: - arr = new Float16Array( new ArrayBuffer( 64 ), 32 ); - v = arr.length; - t.strictEqual( v, 16, 'returns expected value' ); - - arr = new Float16Array( new ArrayBuffer( 64 ), 64 ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( new ArrayBuffer( 64 ), 32, 2 ); - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor throws an error if provided an ArrayBuffer which is not a multiple of 2', function test( t ) { - var values; - var i; - - values = [ - 1, - 3, - 5, - 7, - 9, - 11, - 101, - 1001 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided an ArrayBuffer having a byte length equal to '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Float16Array( new ArrayBuffer( value ) ); - }; - } -}); - -tape( 'the constructor throws an error if provided a byte offset argument which is not a multiple of 2', function test( t ) { - var values; - var i; - - values = [ - 1, - 3, - 5, - 7, - 9, - 11, - 101, - 1001 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Float16Array( new ArrayBuffer( 1e3 ), value ); - }; - } -}); - -tape( 'the constructor throws an error if provided a byte offset argument such that the view byte length is not a multiple of 8', function test( t ) { - var values; - var i; - - values = [ - 2, - 4, - 6, - 8, - 10, - 12, - 14, - 16, - 18, - 20 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Float16Array( new ArrayBuffer( 101 ), value ); - }; - } -}); - -tape( 'the constructor throws an error if provided insufficient memory to accommodate byte offset and length arguments', function test( t ) { - var values; - var i; - - values = [ - 8, - 16, - 24, - 32 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Float16Array( new ArrayBuffer( 100 ), value, 1e3 ); - }; - } -}); diff --git a/test/test.keys.js b/test/test.keys.js deleted file mode 100644 index 283d682..0000000 --- a/test/test.keys.js +++ /dev/null @@ -1,144 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `keys` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.keys ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.keys.call( value ); - }; - } -}); - -tape( 'the method returns an iterator protocol-compliant object', function test( t ) { - var expected; - var arr; - var it; - var i; - var r; - var e; - - arr = new Float16Array( [ 1.05, 2.05 ] ); - expected = [ - { - 'value': 0, - 'done': false - }, - { - 'value': 1, - 'done': false - }, - { - 'done': true - } - ]; - it = arr.keys(); - - t.strictEqual( typeof it, 'object', 'returns expected value' ); - t.strictEqual( typeof it.next, 'function', 'has next method' ); - - for ( i = 0; i < expected.length; i++ ) { - r = it.next(); - e = expected[ i ]; - if ( e.value === void 0 ) { - t.strictEqual( r.value, e.value, 'returns expected value' ); - t.strictEqual( r.done, e.done, 'returns expected value' ); - } else { - t.strictEqual( r.value, e.value, 'returns expected value' ); - t.strictEqual( r.done, e.done, 'returns expected value' ); - } - } - - t.end(); -}); - -tape( 'the method returns an iterator which does not iterate over empty arrays', function test( t ) { - var expected; - var arr; - var it; - var i; - var v; - - arr = new Float16Array( [] ); - expected = [ - { - 'done': true - }, - { - 'done': true - }, - { - 'done': true - } - ]; - it = arr.keys(); - - t.strictEqual( typeof it, 'object', 'returns expected value' ); - t.strictEqual( typeof it.next, 'function', 'has next method' ); - - for ( i = 0; i < expected.length; i++ ) { - v = it.next(); - t.strictEqual( v.value, expected[ i ].value, 'returns expected value' ); - t.strictEqual( v.done, expected[ i ].done, 'returns expected value' ); - } - t.end(); -}); diff --git a/test/test.last_index_of.js b/test/test.last_index_of.js deleted file mode 100644 index 5a42168..0000000 --- a/test/test.last_index_of.js +++ /dev/null @@ -1,149 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `lastIndexOf` method for returning the index of an array element', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.lastIndexOf ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.lastIndexOf.call( value, true ); - }; - } -}); - -tape( 'the method returns `-1` if operating on an empty floating-point number array', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( 0 ); - idx = arr.lastIndexOf( 0.0 ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `-1` if a numeric value is not found', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( 10 ); - idx = arr.lastIndexOf( 1.0 ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns the index of the first match when searching from the end of the array if a search element is found', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 1.05, 2.05 ] ); - idx = arr.lastIndexOf( float64ToFloat16( 1.05 ) ); - - t.strictEqual( idx, 2, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 2.05, 1.05, 1.05 ] ); - - idx = arr.lastIndexOf( float64ToFloat16( 1.05 ), 4 ); - t.strictEqual( idx, 4, 'returns expected value' ); - - idx = arr.lastIndexOf( float64ToFloat16( 2.05 ), 2 ); - t.strictEqual( idx, 2, 'returns expected value' ); - - idx = arr.lastIndexOf( float64ToFloat16( 2.05 ), 0 ); - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index (negative)', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 2.05, 1.05, 1.05 ] ); - - idx = arr.lastIndexOf( float64ToFloat16( 1.05 ), -3 ); - t.strictEqual( idx, 0, 'returns expected value' ); - - idx = arr.lastIndexOf( float64ToFloat16( 2.05 ), -1 ); - t.strictEqual( idx, 2, 'returns expected value' ); - t.end(); -}); - -tape( 'when the method is provided a starting index which resolves to an index which exceeds the maximum array index, the method searches from the last array element', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 2.05, 1.05, 1.05 ] ); - - idx = arr.lastIndexOf( float64ToFloat16( 1.05 ), 10 ); - t.strictEqual( idx, 4, 'returns expected value' ); - - idx = arr.lastIndexOf( float64ToFloat16( 2.05 ), 10 ); - t.strictEqual( idx, 2, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.map.js b/test/test.map.js deleted file mode 100644 index f7e5594..0000000 --- a/test/test.map.js +++ /dev/null @@ -1,176 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var identity = require( '@stdlib/utils-identity-function' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `map` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.map ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.map.call( value, identity ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.map( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.map( identity ); - - t.strictEqual( instanceOf( out, Float16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - t.notEqual( out, arr, 'returns a new instance' ); - t.end(); -}); - -tape( 'the method returns a new floating-point number array containing elements which are the result of a provided callback function', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( -1.05 ), - toWord( -2.05 ), - toWord( -3.05 ), - toWord( -4.05 ) - ]); - actual = arr.map( invert ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.notEqual( actual, arr, 'returns a new instance' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); - - function invert( v ) { - return -v; - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var expected; - var actual; - var arr; - var buf; - var ctx; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( -1.05 ), - toWord( -2.05 ), - toWord( -3.05 ), - toWord( -4.05 ) - ]); - ctx = { - 'count': 0 - }; - actual = arr.map( invert, ctx ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.strictEqual( ctx.count, 6, 'returns expected value' ); - t.end(); - - function invert( v, i ) { - this.count += i; // eslint-disable-line no-invalid-this - return -v; - } -}); diff --git a/test/test.of.js b/test/test.of.js deleted file mode 100644 index 6486686..0000000 --- a/test/test.of.js +++ /dev/null @@ -1,128 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `of` method for creating a 16-bit floating-point number array from a variable number of arguments', function test( t ) { - var arr; - - t.strictEqual( isFunction( Float16Array.of ), true, 'has method' ); - - arr = Float16Array.of(); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a constructor', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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 Float16Array.of.call( value, true, true ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point array constructor', function test( t ) { - var values; - var i; - - values = [ - {}, - null, - 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 Float16Array.of.call( value, true, true ); - }; - } -}); - -tape( 'the method returns a floating-point number array', function test( t ) { - var arr; - var v; - - // No arguments: - arr = Float16Array.of(); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - // Numeric arguments: - arr = Float16Array.of( 1.0, 2.0, 3.0, 4.0 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - // Non-numeric arguments: - arr = Float16Array.of( 1, {}, 0, null, 'beep' ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 5, 'returns expected value' ); - - // Mixed arguments: - arr = Float16Array.of( true, 1, false, 0 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 2010bde..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 proxyquire = require( 'proxyquire' ); -var hasFloat16ArraySupport = require( '@stdlib/assert-has-float16array-support' ); -var polyfill = require( './../lib/polyfill' ); -var ctor = require( './../lib' ); - - -// VARIABLES // - -var hasFloat16Arrays = hasFloat16ArraySupport(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports `Float16Array`, the export is an alias for `Float16Array`', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-float16array-support': isTrue, - './main.js': Mock - }); - t.strictEqual( Foo, Mock, 'returns builtin' ); - - if ( hasFloat16Arrays ) { - t.strictEqual( ctor, Float16Array, 'is alias' ); // eslint-disable-line stdlib/require-globals, no-undef - } - - t.end(); - - function Mock() { - return this; - } - - function isTrue() { - return true; - } -}); - -tape( 'if an environment does not support `Float16Array`, the export is a polyfill', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-float16array-support': isFalse - }); - - t.strictEqual( Foo, polyfill, 'returns polyfill' ); - t.end(); - - function isFalse() { - return false; - } -}); diff --git a/test/test.reduce.js b/test/test.reduce.js deleted file mode 100644 index 34786fc..0000000 --- a/test/test.reduce.js +++ /dev/null @@ -1,187 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `reduce` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.reduce ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.reduce.call( value, reducer ); - }; - } - - function reducer( acc, value ) { - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.reduce( value ); - }; - } -}); - -tape( 'the method throws an error if not provided an initial value when operating on an empty floating-point number array', function test( t ) { - var arr; - - arr = new Float16Array( 0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - arr.reduce( reducer ); - } - - function reducer( acc, value ) { - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method uses the first element of the array as the initial value when an initial value is not provided', function test( t ) { - var valueArray; - var accArray; - var expected; - var actual; - var arr; - var ind; - - arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - accArray = [ 1.0, 3.0 ]; - valueArray = [ 2.0, 3.0 ]; - expected = float64ToFloat16( 6.0 ); - actual = arr.reduce( reducer ); - - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); - - function reducer( acc, value, index ) { - ind = index-1; - t.strictEqual( acc, float64ToFloat16( accArray[ ind ] ), 'returns expected value' ); - t.strictEqual( value, float64ToFloat16( valueArray[ ind ] ), 'returns expected value' ); - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method supports providing an initial value as the second argument', function test( t ) { - var valueArray; - var accArray; - var expected; - var actual; - var arr; - - arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - accArray = [ 2.0, 3.0, 5.0 ]; - valueArray = [ 1.0, 2.0, 3.0 ]; - expected = 8.0; - actual = arr.reduce( reducer, 2.0 ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value, index ) { - t.strictEqual( acc, float64ToFloat16( accArray[ index ] ), 'returns expected value' ); - t.strictEqual( value, float64ToFloat16( valueArray[ index ] ), 'returns expected value' ); - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method returns the accumulated result', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = float64ToFloat16( 10.20 ); - actual = arr.reduce( reducer ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value ) { - return float64ToFloat16( acc + value ); - } -}); diff --git a/test/test.reduce_right.js b/test/test.reduce_right.js deleted file mode 100644 index 313b948..0000000 --- a/test/test.reduce_right.js +++ /dev/null @@ -1,190 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `reduceRight` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.reduceRight ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.reduceRight.call( value, reducer ); - }; - } - - function reducer( acc, value ) { - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.reduceRight( value ); - }; - } -}); - -tape( 'the method throws an error if not provided an initial value when operating on an empty floating-point number array', function test( t ) { - var arr; - - arr = new Float16Array( 0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - arr.reduceRight( reducer ); - } - - function reducer( acc, value ) { - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method uses the last element of the array as the initial value when an initial value is not provided', function test( t ) { - var valueArray; - var accArray; - var expected; - var actual; - var arr; - var len; - - arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - len = arr.length; - accArray = [ 3.0, 5.0 ]; - valueArray = [ 2.0, 1.0 ]; - expected = float64ToFloat16( 6.0 ); - actual = arr.reduceRight( reducer ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value, index ) { - var ind = (len-index-2); - t.strictEqual( acc, float64ToFloat16( accArray[ ind ] ), 'returns expected value' ); - t.strictEqual( value, float64ToFloat16( valueArray[ ind ] ), 'returns expected value' ); - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method supports providing an initial value as the second argument', function test( t ) { - var valueArray; - var accArray; - var expected; - var actual; - var arr; - var len; - - arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - len = arr.length; - accArray = [ 2.0, 5.0, 7.0 ]; - valueArray = [ 3.0, 2.0, 1.0 ]; - expected = 8.0; - actual = arr.reduceRight( reducer, 2.0 ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value, index ) { - var ind = (len-index-1); - t.strictEqual( acc, float64ToFloat16( accArray[ ind ] ), 'returns expected value' ); - t.strictEqual( value, float64ToFloat16( valueArray[ ind ] ), 'returns expected value' ); - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method returns the accumulated result', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = float64ToFloat16( 10.20 ); - actual = arr.reduceRight( reducer ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value ) { - return float64ToFloat16( acc + value ); - } -}); diff --git a/test/test.reverse.js b/test/test.reverse.js deleted file mode 100644 index 147a4a0..0000000 --- a/test/test.reverse.js +++ /dev/null @@ -1,120 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, '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( isFunction( Float16Array.prototype.reverse ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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 floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - 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 floating-point number array in-place', function test( t ) { - var expected; - var arr; - var buf; - var out; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05, 5.05 ] ); - expected = new Uint16Array([ - toWord( 5.05 ), - toWord( 4.05 ), - toWord( 3.05 ), - toWord( 2.05 ), - toWord( 1.05 ) - ]); - out = arr.reverse(); - buf = new Uint16Array( arr.buffer ); - - t.strictEqual( instanceOf( arr, Float16Array ), true, 'returns expected value' ); - t.strictEqual( out, arr, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 10 ); - out = arr.reverse(); - - t.strictEqual( out.length, 10, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.set.js b/test/test.set.js deleted file mode 100644 index 559efab..0000000 --- a/test/test.set.js +++ /dev/null @@ -1,225 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `set` method for setting one or more array elements', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.set ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.set.call( value, 0 ); - }; - } -}); - -tape( 'the method throws an error if provided an index argument which is out-of-bounds', function test( t ) { - var values; - var arr1; - var arr2; - var i; - - arr1 = new Float16Array( 10 ); - arr2 = []; - for ( i = 0; i < arr1.length; i++ ) { - arr2.push( 1.0 ); - } - - values = [ - 1, - 2, - 3, - 4, - 5 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr1.set( arr2, value ); - }; - } -}); - -tape( 'the method sets one or more array elements', function test( t ) { - var arr; - var v; - var i; - - arr = new Float16Array( 10 ); - - v = arr[ 0 ]; - t.strictEqual( v, 0.0, 'returns expected value' ); - - // No index argument: - arr.set( [ 1.0 ] ); - - v = arr[ 0 ]; - t.strictEqual( v, 1.0, 'returns expected value' ); - - arr.set( [ 0.0 ] ); - - // Index argument: - for ( i = 0; i < arr.length; i++ ) { - v = arr[ i ]; - t.strictEqual( v, 0.0, 'returns expected value' ); - - arr.set( [ 1.05 ], i ); - - v = arr[ i ]; - t.strictEqual( v, float64ToFloat16( 1.05 ), 'returns expected value' ); - } - - // Multiple values, no index argument: - arr.set( [ 1.05, 2.05 ] ); - - v = arr[ 0 ]; - t.strictEqual( v, float64ToFloat16( 1.05 ), 'returns expected value' ); - - v = arr[ 1 ]; - t.strictEqual( v, float64ToFloat16( 2.05 ), 'returns expected value' ); - - // Multiple values, index argument: - arr.set( [ 1.05, 2.05 ], 2 ); - - v = arr[ 2 ]; - t.strictEqual( v, float64ToFloat16( 1.05 ), 'returns expected value' ); - - v = arr[ 3 ]; - t.strictEqual( v, float64ToFloat16( 2.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method sets an array element (floating-point number array; shared buffer)', function test( t ) { - var byteOffset; - var arr; - var src; - var buf; - var ab; - var v; - var i; - - byteOffset = 112; - - ab = new ArrayBuffer( 240 ); - arr = new Float16Array( ab, byteOffset, 10 ); - - // Overlapping (requires copy), multiple values, no index argument: - buf = [ 1.05, 2.05 ]; - src = new Float16Array( ab, byteOffset-(1*arr.BYTES_PER_ELEMENT), 2 ); - for ( i = 0; i < buf.length; i++ ) { - src[ i ] = buf[ i ]; - } - arr.set( src ); - - v = arr[ 0 ]; - t.strictEqual( v, float64ToFloat16( buf[ 0 ] ), 'returns expected value' ); - - v = arr[ 1 ]; - t.strictEqual( v, float64ToFloat16( buf[ 1 ] ), 'returns expected value' ); - - // Overlapping (requires copy), multiple values, index argument: - buf = [ -1.05, -2.05 ]; - src = new Float16Array( ab, byteOffset+(1*arr.BYTES_PER_ELEMENT), 2 ); - for ( i = 0; i < buf.length; i++ ) { - src[ i ] = buf[ i ]; - } - arr.set( src, 2 ); - - v = arr[ 2 ]; - t.strictEqual( v, float64ToFloat16( buf[ 0 ] ), 'returns expected value' ); - - v = arr[ 3 ]; - t.strictEqual( v, float64ToFloat16( buf[ 1 ] ), 'returns expected value' ); - - // Overlapping (no copy), multiple values, no index argument: - buf = [ 3.05, 4.05 ]; - src = new Float16Array( ab, byteOffset+(1*arr.BYTES_PER_ELEMENT), 2 ); - for ( i = 0; i < buf.length; i++ ) { - src[ i ] = buf[ i ]; - } - arr.set( src ); - - v = arr[ 0 ]; - t.strictEqual( v, float64ToFloat16( buf[ 0 ] ), 'returns expected value' ); - - v = arr[ 1 ]; - t.strictEqual( v, float64ToFloat16( buf[ 1 ] ), 'returns expected value' ); - - // Overlapping (no copy), multiple values, index argument: - buf = [ -3.05, -4.05 ]; - src = new Float16Array( ab, byteOffset+(3*arr.BYTES_PER_ELEMENT), 2 ); - for ( i = 0; i < buf.length; i++ ) { - src[ i ] = buf[ i ]; - } - arr.set( src, 2 ); - - v = arr[ 2 ]; - t.strictEqual( v, float64ToFloat16( buf[ 0 ] ), 'returns expected value' ); - - v = arr[ 3 ]; - t.strictEqual( v, float64ToFloat16( buf[ 1 ] ), 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.slice.js b/test/test.slice.js deleted file mode 100644 index a9f9e04..0000000 --- a/test/test.slice.js +++ /dev/null @@ -1,249 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `slice` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.slice ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.slice.call( value ); - }; - } -}); - -tape( 'the method returns an empty typed array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.slice(); - - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'if called without arguments, the method returns a typed array containing the same elements as the original array', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ) - ]); - actual = arr.slice(); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.notEqual( actual, arr, 'returns a new instance' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if called with one argument, the method returns a typed array containing elements starting from a specified beginning index (inclusive)', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ) - ]); - actual = arr.slice( 1 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if provided two arguments, the method returns a typed array containing elements starting from a specified beginning index (inclusive) and ending at a specified stop index (exclusive)', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ) - ]); - actual = arr.slice( 1, 3 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ) - ]); - actual = arr.slice( 1, 30 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method resolves negative indices relative to the last element', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ) - ]); - actual = arr.slice( -3, -1 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ) - ]); - actual = arr.slice( -30, -2 ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty typed array if a resolved beginning index exceeds a resolved ending index', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array( [] ); - actual = arr.slice( 2, 0 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty typed array if a resolved beginning index exceeds the maximum array index', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array( [] ); - actual = arr.slice( 5 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty typed array if a resolved ending index is less than or equal to zero', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); - expected = new Uint16Array( [] ); - actual = arr.slice( 2, -8 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - - actual = arr.slice( 1, 0 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.some.js b/test/test.some.js deleted file mode 100644 index 238d1d9..0000000 --- a/test/test.some.js +++ /dev/null @@ -1,194 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `some` method for returning boolean indicating whether at least one element passes a test', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.some ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.some.call( value, predicate ); - }; - } - - function predicate( v ) { - return v === 1.0; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.some( value ); - }; - } -}); - -tape( 'the method returns `false` if operating on an empty floating-point number array', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( 0 ); - bool = arr.some( predicate ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns `true` if at least one element passes a test', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - bool = arr.some( predicate ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v === float64ToFloat16( 1.05 ); - } -}); - -tape( 'the method returns `false` if all elements fail a test', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - bool = arr.some( predicate ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v === float64ToFloat16( 5.05 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var bool; - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - bool = arr.some( predicate, ctx ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v === float64ToFloat16( 4.05 ); - } -}); - -tape( 'the method stops executing upon encountering the first element which passes a test', function test( t ) { - var bool; - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - bool = arr.some( predicate, ctx ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.strictEqual( ctx.count, 1, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v === float64ToFloat16( 1.05 ); - } -}); diff --git a/test/test.sort.js b/test/test.sort.js deleted file mode 100644 index e976a68..0000000 --- a/test/test.sort.js +++ /dev/null @@ -1,186 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Comparison function. -* -* @private -* @param {boolean} a - first value for comparison -* @param {boolean} b - second value for comparison -* @returns {number} comparison result -*/ -function compareFcn( a, b ) { - if ( a < b ) { - return -1; - } - if ( a > b ) { - return 1; - } - return 0; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `sort` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.sort ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.sort.call( value, compareFcn ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - {}, - [] - ]; - 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.sort( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.sort( compareFcn ); - - t.strictEqual( out.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the method sorts elements of a floating-point number array in-place', function test( t ) { - var expected; - var arr; - var out; - var buf; - - arr = new Float16Array( [ 4.05, 3.05, 1.05, 5.05, 2.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ), - toWord( 5.05 ) - ]); - out = arr.sort( compareFcn ); - buf = new Uint16Array( out.buffer ); - - t.strictEqual( instanceOf( arr, Float16Array ), true, 'returns expected value' ); - t.strictEqual( out, arr, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - - arr = new Float16Array( [ 2.05, 1.05, -1.05, 0.05, -2.05 ] ); - expected = new Uint16Array([ - toWord( -2.05 ), - toWord( -1.05 ), - toWord( 0.05 ), - toWord( 1.05 ), - toWord( 2.05 ) - ]); - out = arr.sort( compareFcn ); - buf = new Uint16Array( out.buffer ); - - t.strictEqual( instanceOf( arr, Float16Array ), true, 'returns expected value' ); - t.strictEqual( out, arr, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Float16Array( [ 4.05, 3.05, 1.05, 5.05, 2.05 ] ); - out = arr.sort( compareFcn ); - - t.strictEqual( out.length, arr.length, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.subarray.js b/test/test.subarray.js deleted file mode 100644 index 6684448..0000000 --- a/test/test.subarray.js +++ /dev/null @@ -1,246 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `subarray` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.subarray ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.subarray.call( value ); - }; - } -}); - -tape( 'the method returns empty array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.subarray(); - - t.strictEqual( out.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'if called without arguments, the method returns a view containing the same elements as the original array', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ) - ]); - actual = arr.subarray(); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if called with one argument, the method returns a view containing elements starting from a specified beginning index (inclusive)', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ) - ]); - actual = arr.subarray( 1 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if provided two arguments, the method returns a view containing elements starting from a specified beginning index (inclusive) and ending at a specified stop index (exclusive)', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ) - ]); - actual = arr.subarray( 1, 3 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method resolves negative indices relative to the last element', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ) - ]); - actual = arr.subarray( -3, -1 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 2.05 ) - ]); - actual = arr.subarray( -30, -2 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty view if a resolved beginning index exceeds a resolved ending index', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array( [] ); - actual = arr.subarray( 2, 0 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty view if a resolved beginning index exceeds the maximum array index', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array( [] ); - actual = arr.subarray( 5 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty view if a resolved ending index is less than or equal to zero', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array( [] ); - actual = arr.subarray( 2, -8 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - - actual = arr.subarray( 1, 0 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.to_locale_string.js b/test/test.to_locale_string.js deleted file mode 100644 index 6359a2c..0000000 --- a/test/test.to_locale_string.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `toLocaleString` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.toLocaleString ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.toLocaleString.call( value ); - }; - } -}); - -tape( 'the method returns an empty string if invoked on an empty array', function test( t ) { - var str; - var arr; - - arr = new Float16Array( 0 ); - str = arr.toLocaleString(); - - t.strictEqual( str, '', 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a string representation of a floating-point number array', function test( t ) { - var expected; - var str; - var arr; - - arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - expected = '1,2,3'; - - str = arr.toLocaleString(); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.to_reversed.js b/test/test.to_reversed.js deleted file mode 100644 index a82ad13..0000000 --- a/test/test.to_reversed.js +++ /dev/null @@ -1,119 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, '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( isFunction( Float16Array.prototype.toReversed ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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 floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - 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 buf; - var out; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05, 5.05 ] ); - expected = new Uint16Array([ - toWord( 5.05 ), - toWord( 4.05 ), - toWord( 3.05 ), - toWord( 2.05 ), - toWord( 1.05 ) - ]); - out = arr.toReversed(); - buf = new Uint16Array( out.buffer ); - - t.strictEqual( instanceOf( out, Float16Array ), true, 'returns expected value' ); - t.notEqual( out, arr, 'returns a new instance' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 10 ); - out = arr.toReversed(); - - t.strictEqual( out.length, 10, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.to_sorted.js b/test/test.to_sorted.js deleted file mode 100644 index 77508b5..0000000 --- a/test/test.to_sorted.js +++ /dev/null @@ -1,169 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Comparison function. -* -* @private -* @param {boolean} a - first value for comparison -* @param {boolean} b - second value for comparison -* @returns {number} comparison result -*/ -function compareFcn( a, b ) { - if ( a < b ) { - return -1; - } - if ( a > b ) { - return 1; - } - return 0; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `toSorted` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.toSorted ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.toSorted.call( value, compareFcn ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - {}, - [] - ]; - 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.toSorted( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.toSorted( compareFcn ); - - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a new typed array containing elements in sorted order', function test( t ) { - var expected; - var arr; - var out; - var buf; - - arr = new Float16Array( [ 4.05, 3.05, 1.05, 5.05, 2.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ), - toWord( 5.05 ) - ]); - out = arr.toSorted( compareFcn ); - buf = new Uint16Array( out.buffer ); - - t.strictEqual( instanceOf( out, Float16Array ), true, 'returns expected value' ); - t.notEqual( out, arr, 'returns a new instance' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Float16Array( [ 4.05, 3.05, 1.05, 5.05, 2.05 ] ); - out = arr.toSorted( compareFcn ); - - t.strictEqual( out.length, arr.length, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.to_string.js b/test/test.to_string.js deleted file mode 100644 index a2bb9e3..0000000 --- a/test/test.to_string.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `toString` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.toString ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with an invalid `this` context', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - null, - void 0 - ]; - 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.toString.call( value ); - }; - } -}); - -tape( 'the method returns an empty string if invoked on an empty array', function test( t ) { - var str; - var arr; - - arr = new Float16Array( 0 ); - str = arr.toString(); - - t.strictEqual( str, '', 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a string representation of a floating-point number array', function test( t ) { - var expected; - var str; - var arr; - - arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - expected = '1,2,3,4'; - - str = arr.toString(); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.values.js b/test/test.values.js deleted file mode 100644 index 225b3fe..0000000 --- a/test/test.values.js +++ /dev/null @@ -1,147 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var isNumber = require( '@stdlib/assert-is-number' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `values` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.values ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.values.call( value ); - }; - } -}); - -tape( 'the method returns an iterator protocol-compliant object', function test( t ) { - var expected; - var arr; - var it; - var i; - var r; - var e; - - arr = new Float16Array( [ 1.05, 2.05 ] ); - expected = [ - { - 'value': float64ToFloat16( 1.05 ), - 'done': false - }, - { - 'value': float64ToFloat16( 2.05 ), - 'done': false - }, - { - 'done': true - } - ]; - it = arr.values(); - - t.strictEqual( typeof it, 'object', 'returns expected value' ); - t.strictEqual( typeof it.next, 'function', 'has next method' ); - - for ( i = 0; i < expected.length; i++ ) { - r = it.next(); - e = expected[ i ]; - if ( e.value === void 0 ) { - t.strictEqual( r.value, e.value, 'returns expected value' ); - t.strictEqual( r.done, e.done, 'returns expected value' ); - } else { - t.strictEqual( isNumber( r.value ), true, 'returns expected value' ); - t.strictEqual( r.value, e.value, 'returns expected value' ); - t.strictEqual( r.done, e.done, 'returns expected value' ); - } - } - - t.end(); -}); - -tape( 'the method returns an iterator which does not iterate over empty arrays', function test( t ) { - var expected; - var arr; - var it; - var i; - var v; - - arr = new Float16Array( [] ); - expected = [ - { - 'done': true - }, - { - 'done': true - }, - { - 'done': true - } - ]; - it = arr.values(); - - t.strictEqual( typeof it, 'object', 'returns expected value' ); - t.strictEqual( typeof it.next, 'function', 'has next method' ); - - for ( i = 0; i < expected.length; i++ ) { - v = it.next(); - t.strictEqual( v.value, expected[ i ].value, 'returns expected value' ); - t.strictEqual( v.done, expected[ i ].done, 'returns expected value' ); - } - t.end(); -}); diff --git a/test/test.with.js b/test/test.with.js deleted file mode 100644 index de134c8..0000000 --- a/test/test.with.js +++ /dev/null @@ -1,151 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `with` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.with ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.with.call( value, 0, true ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not in bounds', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - -11, - -12, - 11, - 12 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.with( value, 1.0 ); - }; - } -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 10 ); - out = arr.with( 5, 1.0 ); - - t.strictEqual( out.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a new floating-point number array with the element at a provided index replaced with a provided value', function test( t ) { - var expected; - var arr; - var buf; - var out; - - arr = new Float16Array( [ 1.05, 1.05, 1.05, 1.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 1.05 ), - toWord( 1.05 ), - toWord( 2.05 ) - ]); - out = arr.with( 3, 2.05 ); - buf = new Uint16Array( out.buffer ); - - t.strictEqual( out instanceof Float16Array, true, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.notEqual( out, arr, 'returns new instance' ); - t.end(); -}); - -tape( 'the method supports negative indices', function test( t ) { - var expected; - var arr; - var buf; - var out; - - arr = new Float16Array( [ 1.05, 1.05, 1.05, 1.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 1.05 ), - toWord( 1.05 ), - toWord( 2.05 ) - ]); - out = arr.with( -1, 2.05 ); - buf = new Uint16Array( out.buffer ); - - t.strictEqual( out instanceof Float16Array, true, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); From 3cab145a739973eca0c347388327d4a6fbb7375e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 31 May 2026 11:58:20 +0000 Subject: [PATCH 09/14] Transform error messages --- lib/polyfill/index.js | 104 +++++++++++++++++++++--------------------- package.json | 2 +- 2 files changed, 53 insertions(+), 53 deletions(-) diff --git a/lib/polyfill/index.js b/lib/polyfill/index.js index bd087e9..f4a1a8f 100644 --- a/lib/polyfill/index.js +++ b/lib/polyfill/index.js @@ -38,7 +38,7 @@ var setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); var setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' ); var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var Uint16Array = require( '@stdlib/array-uint16' ); var f16 = require( '@stdlib/number-float64-base-to-float16' ); var toWord = require( '@stdlib/number-float16-base-to-word' ); @@ -234,49 +234,49 @@ function Float16Array() { } } else if ( isArrayBuffer( arg ) ) { if ( !isInteger( arg.byteLength/BYTES_PER_ELEMENT ) ) { - throw new RangeError( format( 'invalid argument. ArrayBuffer byte length must be a multiple of %u. Byte length: `%u`.', BYTES_PER_ELEMENT, arg.byteLength ) ); + throw new RangeError( format( 'nullE9', BYTES_PER_ELEMENT, arg.byteLength ) ); } buf = new Uint16Array( arg ); } else if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, ArrayBuffer, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( 'null29', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( 'null2A', arg ) ); } buf = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( buf.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( 'null2A', arg ) ); } buf = new Uint16Array( fromIterator( buf ) ); } else { - throw new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( 'null2A', arg ) ); } } else { buf = arguments[ 0 ]; if ( !isArrayBuffer( buf ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', buf ) ); + throw new TypeError( format( 'null2B', buf ) ); } byteOffset = arguments[ 1 ]; if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) ); + throw new TypeError( format( 'null2C', byteOffset ) ); } if ( !isInteger( byteOffset/BYTES_PER_ELEMENT ) ) { - throw new RangeError( format( 'invalid argument. Byte offset must be a multiple of %u. Value: `%u`.', BYTES_PER_ELEMENT, byteOffset ) ); + throw new RangeError( format( 'nullEA', BYTES_PER_ELEMENT, byteOffset ) ); } if ( nargs === 2 ) { len = buf.byteLength - byteOffset; if ( !isInteger( len/BYTES_PER_ELEMENT ) ) { - throw new RangeError( format( 'invalid arguments. ArrayBuffer view byte length must be a multiple of %u. View byte length: `%u`.', BYTES_PER_ELEMENT, len ) ); + throw new RangeError( format( 'null2E', BYTES_PER_ELEMENT, len ) ); } buf = new Uint16Array( buf, byteOffset ); } else { len = arguments[ 2 ]; if ( !isNonNegativeInteger( len ) ) { - throw new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', len ) ); + throw new TypeError( format( 'null2F', len ) ); } if ( (len*BYTES_PER_ELEMENT) > (buf.byteLength-byteOffset) ) { - throw new RangeError( format( 'invalid arguments. ArrayBuffer has insufficient capacity. Either decrease the array length or provide a bigger buffer. Minimum capacity: `%u`.', len*BYTES_PER_ELEMENT ) ); + throw new RangeError( format( 'null2G', len*BYTES_PER_ELEMENT ) ); } buf = new Uint16Array( buf, byteOffset, len ); } @@ -362,7 +362,7 @@ setReadOnly( Float16Array, 'from', function from( src ) { var len; var i; if ( !isFunction( this ) ) { - throw new TypeError( 'invalid invocation. `this` context must be a constructor.' ); + throw new TypeError( format('null01') ); } if ( !isFloatingPointArrayConstructor( this ) ) { throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); @@ -371,7 +371,7 @@ setReadOnly( Float16Array, 'from', function from( src ) { if ( nargs > 1 ) { clbk = arguments[ 1 ]; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( 'null2H', clbk ) ); } if ( nargs > 2 ) { thisArg = arguments[ 2 ]; @@ -392,7 +392,7 @@ setReadOnly( Float16Array, 'from', function from( src ) { if ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) { // eslint-disable-line max-len buf = src[ ITERATOR_SYMBOL ](); if ( !isFunction( buf.next ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) ); + throw new TypeError( format( 'null2J', src ) ); } if ( clbk ) { tmp = fromIteratorMap( buf, clbk, thisArg ); @@ -410,7 +410,7 @@ setReadOnly( Float16Array, 'from', function from( src ) { } return out; } - throw new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) ); + throw new TypeError( format( 'null2J', src ) ); }); /** @@ -438,7 +438,7 @@ setReadOnly( Float16Array, 'of', function of() { var args; var i; if ( !isFunction( this ) ) { - throw new TypeError( 'invalid invocation. `this` context must be a constructor.' ); + throw new TypeError( format('null01') ); } if ( !isFloatingPointArrayConstructor( this ) ) { throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); @@ -478,7 +478,7 @@ setReadOnly( Float16Array.prototype, 'at', function at( idx ) { throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Must provide an integer. Value: `%s`.', idx ) ); + throw new TypeError( format( 'null8A', idx ) ); } if ( idx < 0 ) { idx += this._length; @@ -731,7 +731,7 @@ setReadOnly( Float16Array.prototype, 'every', function every( predicate, thisArg throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( 'null3c', predicate ) ); } buf = this._buffer; for ( i = 0; i < this._length; i++ ) { @@ -781,13 +781,13 @@ setReadOnly( Float16Array.prototype, 'fill', function fill( value, start, end ) throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isNumber( value ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a number. Value: `%s`.', value ) ); + throw new TypeError( format( 'null49', value ) ); } buf = this._buffer; len = this._length; if ( arguments.length > 1 ) { if ( !isInteger( start ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', start ) ); + throw new TypeError( format( 'null7f', start ) ); } if ( start < 0 ) { start += len; @@ -797,7 +797,7 @@ setReadOnly( Float16Array.prototype, 'fill', function fill( value, start, end ) } if ( arguments.length > 2 ) { if ( !isInteger( end ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', end ) ); + throw new TypeError( format( 'null2z', end ) ); } if ( end < 0 ) { end += len; @@ -863,7 +863,7 @@ setReadOnly( Float16Array.prototype, 'filter', function filter( predicate, thisA throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( 'null3c', predicate ) ); } buf = this._buffer; out = []; @@ -907,7 +907,7 @@ setReadOnly( Float16Array.prototype, 'find', function find( predicate, thisArg ) throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( 'null3c', predicate ) ); } buf = this._buffer; for ( i = 0; i < this._length; i++ ) { @@ -949,7 +949,7 @@ setReadOnly( Float16Array.prototype, 'findIndex', function findIndex( predicate, throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( 'null3c', predicate ) ); } buf = this._buffer; for ( i = 0; i < this._length; i++ ) { @@ -992,7 +992,7 @@ setReadOnly( Float16Array.prototype, 'findLast', function findLast( predicate, t throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( 'null3c', predicate ) ); } buf = this._buffer; for ( i = this._length-1; i >= 0; i-- ) { @@ -1034,7 +1034,7 @@ setReadOnly( Float16Array.prototype, 'findLastIndex', function findLastIndex( pr throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( 'null3c', predicate ) ); } buf = this._buffer; for ( i = this._length-1; i >= 0; i-- ) { @@ -1074,7 +1074,7 @@ setReadOnly( Float16Array.prototype, 'forEach', function forEach( fcn, thisArg ) throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( 'null3c', fcn ) ); } buf = this._buffer; for ( i = 0; i < this._length; i++ ) { @@ -1099,7 +1099,7 @@ setReadOnly( Float16Array.prototype, '_get', function get( idx ) { throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isNonNegativeInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Must provide a nonnegative integer. Value: `%s`.', idx ) ); + throw new TypeError( format( 'null2K', idx ) ); } if ( idx >= this._length ) { return; @@ -1141,11 +1141,11 @@ setReadOnly( Float16Array.prototype, 'includes', function includes( searchElemen throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isNumber( searchElement ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a number. Value: `%s`.', searchElement ) ); + throw new TypeError( format( 'null49', searchElement ) ); } if ( arguments.length > 1 ) { if ( !isInteger( fromIndex ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) ); + throw new TypeError( format( 'null7f', fromIndex ) ); } if ( fromIndex < 0 ) { fromIndex += this._length; @@ -1200,11 +1200,11 @@ setReadOnly( Float16Array.prototype, 'indexOf', function indexOf( searchElement, throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isNumber( searchElement ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a number. Value: `%s`.', searchElement ) ); + throw new TypeError( format( 'null49', searchElement ) ); } if ( arguments.length > 1 ) { if ( !isInteger( fromIndex ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) ); + throw new TypeError( format( 'null7f', fromIndex ) ); } if ( fromIndex < 0 ) { fromIndex += this._length; @@ -1255,7 +1255,7 @@ setReadOnly( Float16Array.prototype, 'join', function join( separator ) { } if ( arguments.length > 0 ) { if ( !isString( separator ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', separator ) ); + throw new TypeError( format( 'null3F', separator ) ); } } else { separator = ','; @@ -1404,11 +1404,11 @@ setReadOnly( Float16Array.prototype, 'lastIndexOf', function lastIndexOf( search throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isNumber( searchElement ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a number. Value: `%s`.', searchElement ) ); + throw new TypeError( format( 'null49', searchElement ) ); } if ( arguments.length > 1 ) { if ( !isInteger( fromIndex ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) ); + throw new TypeError( format( 'null7f', fromIndex ) ); } if ( fromIndex >= this._length ) { fromIndex = this._length - 1; @@ -1486,7 +1486,7 @@ setReadOnly( Float16Array.prototype, 'map', function map( fcn, thisArg ) { throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isFunction( fcn ) ) { - throw new TypeError( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ); + throw new TypeError( format('null3c'), fcn ); } buf = this._buffer; out = new this.constructor( this._length ); @@ -1529,7 +1529,7 @@ setReadOnly( Float16Array.prototype, 'reduce', function reduce( reducer, initial throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isFunction( reducer ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', reducer ) ); + throw new TypeError( format( 'null3c', reducer ) ); } buf = this._buffer; len = this._length; @@ -1581,7 +1581,7 @@ setReadOnly( Float16Array.prototype, 'reduceRight', function reduceRight( reduce throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isFunction( reducer ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', reducer ) ); + throw new TypeError( format( 'null3c', reducer ) ); } buf = this._buffer; len = this._length; @@ -1707,20 +1707,20 @@ setReadOnly( Float16Array.prototype, 'set', function set( value ) { throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isCollection( value ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', value ) ); + throw new TypeError( format( 'null2O', value ) ); } buf = this._buffer; if ( arguments.length > 1 ) { idx = arguments[ 1 ]; if ( !isNonNegativeInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Index argument must be a nonnegative integer. Value: `%s`.', idx ) ); + throw new TypeError( format( 'null2L', idx ) ); } } else { idx = 0; } N = value.length; if ( idx+N > this._length ) { - throw new RangeError( 'invalid arguments. Target array lacks sufficient storage to accommodate source values.' ); + throw new RangeError( format('null03') ); } if ( isFloat16Array( value ) ) { sbuf = value._buffer; // eslint-disable-line no-underscore-dangle @@ -1814,7 +1814,7 @@ setReadOnly( Float16Array.prototype, 'slice', function slice( begin, end ) { end = len; } else { if ( !isInteger( begin ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', begin ) ); + throw new TypeError( format( 'null7e', begin ) ); } if ( begin < 0 ) { begin += len; @@ -1826,7 +1826,7 @@ setReadOnly( Float16Array.prototype, 'slice', function slice( begin, end ) { end = len; } else { if ( !isInteger( end ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', end ) ); + throw new TypeError( format( 'null7f', end ) ); } if ( end < 0 ) { end += len; @@ -1881,7 +1881,7 @@ setReadOnly( Float16Array.prototype, 'some', function some( predicate, thisArg ) throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( 'null3c', predicate ) ); } buf = this._buffer; for ( i = 0; i < this._length; i++ ) { @@ -1939,7 +1939,7 @@ setReadOnly( Float16Array.prototype, 'sort', function sort( compareFcn ) { return this; } if ( !isFunction( compareFcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', compareFcn ) ); + throw new TypeError( format( 'null3c', compareFcn ) ); } buf.sort( compare ); return this; @@ -2044,7 +2044,7 @@ setReadOnly( Float16Array.prototype, 'subarray', function subarray( begin, end ) end = len; } else { if ( !isInteger( begin ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', begin ) ); + throw new TypeError( format( 'null7e', begin ) ); } if ( begin < 0 ) { begin += len; @@ -2056,7 +2056,7 @@ setReadOnly( Float16Array.prototype, 'subarray', function subarray( begin, end ) end = len; } else { if ( !isInteger( end ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', end ) ); + throw new TypeError( format( 'null7f', end ) ); } if ( end < 0 ) { end += len; @@ -2122,7 +2122,7 @@ setReadOnly( Float16Array.prototype, 'toLocaleString', function toLocaleString( } else if ( isObject( options ) ) { opts = options; } else { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( 'null2V', options ) ); } buf = this._buffer; out = []; @@ -2387,17 +2387,17 @@ setReadOnly( Float16Array.prototype, 'with', function copyWith( index, value ) { throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isInteger( index ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', index ) ); + throw new TypeError( format( 'null7e', index ) ); } len = this._length; if ( index < 0 ) { index += len; } if ( index < 0 || index >= len ) { - throw new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%s`.', index ) ); + throw new RangeError( format( 'nullFP', index ) ); } if ( !isNumber( value ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a number. Value: `%s`.', value ) ); + throw new TypeError( format( 'null4A', value ) ); } out = new this.constructor( this ); out[ index ] = value; diff --git a/package.json b/package.json index 7f32128..0ed7acd 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "@stdlib/number-float16-base-from-word": "^0.2.1", "@stdlib/number-float16-base-to-word": "^0.1.1", "@stdlib/number-float64-base-to-float16": "^0.1.2", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/symbol-iterator": "^0.2.3", "@stdlib/types": "^0.4.3", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.4", From e62d1ce1ff8e8d1973655ff7a09b237b42051e4d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 31 May 2026 12:00:19 +0000 Subject: [PATCH 10/14] Remove files --- index.d.ts | 1312 -------------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 6159 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index ed52b06..0000000 --- a/index.d.ts +++ /dev/null @@ -1,1312 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2026 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. -*/ - -/* eslint-disable max-lines */ - -// TypeScript Version: 4.1 - -/// - -import { Iterator as Iter, IterableIterator, TypedIterator } from '@stdlib/types/iter'; -import { ArrayLike } from '@stdlib/types/array'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = Iter | IterableIterator; - -/** -* Locale-specific configuration options. -*/ -interface LocaleOptions { - /** - * Configuration property. - */ - [ key: string | symbol | number ]: T | undefined; -} - -/** -* Callback invoked for each element in a source object. -* -* @returns transformed value -*/ -type FromNullary = ( this: U ) => number; - -/** -* Callback invoked for each element in a source object. -* -* @param value - source element -* @returns transformed value -*/ -type FromUnary = ( this: U, value: number ) => number; - -/** -* Callback invoked for each element in a source object. -* -* @param value - source element -* @param index - source element index -* @returns transformed value -*/ -type FromBinary = ( this: U, value: number, index: number ) => number; - -/** -* Callback invoked for each element in a source object. -* -* @param value - source element -* @param index - source element index -* @returns transformed value -*/ -type FromCallback = FromNullary | FromUnary | FromBinary; - -/** -* Checks whether an element in an array passes a test. -* -* @returns boolean indicating whether an element in an array passes a test -*/ -type NullaryPredicate = ( this: U ) => boolean; - -/** -* Checks whether an element in an array passes a test. -* -* @param value - current array element -* @returns boolean indicating whether an element in an array passes a test -*/ -type UnaryPredicate = ( this: U, value: number ) => boolean; - -/** -* Checks whether an element in an array passes a test. -* -* @param value - current array element -* @param index - current array element index -* @returns boolean indicating whether an element in an array passes a test -*/ -type BinaryPredicate = ( this: U, value: number, index: number ) => boolean; - -/** -* Checks whether an element in an array passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - array on which the method was called -* @returns boolean indicating whether an element in an array passes a test -*/ -type TernaryPredicate = ( this: U, value: number, index: number, arr: Float16Array ) => boolean; - -/** -* Checks whether an element in an array passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - array on which the method was called -* @returns boolean indicating whether an element in an array passes a test -*/ -type Predicate = NullaryPredicate | UnaryPredicate | BinaryPredicate | TernaryPredicate; - -/** -* Callback invoked for each element in an array. -* -* @returns undefined -*/ -type NullaryCallback = ( this: U ) => void; - -/** -* Callback invoked for each element in an array. -* -* @param value - current array element -* @returns undefined -*/ -type UnaryCallback = ( this: U, value: number ) => void; - -/** -* Callback invoked for each element in an array. -* -* @param value - current array element -* @param index - current array element index -* @returns undefined -*/ -type BinaryCallback = ( this: U, value: number, index: number ) => void; - -/** -* Callback invoked for each element in an array. -* -* @param value - current array element -* @param index - current array element index -* @param arr - array on which the method was called -* @returns undefined -*/ -type TernaryCallback = ( this: U, value: number, index: number, arr: Float16Array ) => void; - -/** -* Callback invoked for each element in an array. -* -* @param value - current array element -* @param index - current array element index -* @param arr - array on which the method was called -* @returns undefined -*/ -type Callback = NullaryCallback | UnaryCallback | BinaryCallback | TernaryCallback; - -/** -* Callback invoked for each element in an array. -* -* @returns returned value -*/ -type NullaryMapFcn = ( this: U ) => number; - -/** -* Callback invoked for each element in an array. -* -* @param value - current array element -* @returns returned value -*/ -type UnaryMapFcn = ( this: U, value: number ) => number; - -/** -* Callback invoked for each element in an array. -* -* @param value - current array element -* @param index - current array element index -* @returns returned value -*/ -type BinaryMapFcn = ( this: U, value: number, index: number ) => number; - -/** -* Callback invoked for each element in an array. -* -* @param value - current array element -* @param index - current array element index -* @param arr - array on which the method was called -* @returns returned value -*/ -type TernaryMapFcn = ( this: U, value: number, index: number, arr: Float16Array ) => number; - -/** -* Callback invoked for each element in an array. -* -* @param value - current array element -* @param index - current array element index -* @param arr - array on which the method was called -* @returns returned value -*/ -type MapFcn = NullaryMapFcn | UnaryMapFcn | BinaryMapFcn | TernaryMapFcn; - -/** -* Reducer function invoked for each element in an array. -* -* @returns accumulated result -*/ -type NullaryReducer = () => U; - -/** -* Reducer function invoked for each element in an array. -* -* @param acc - accumulated result -* @returns accumulated result -*/ -type UnaryReducer = ( acc: U ) => U; - -/** -* Reducer function invoked for each element in an array. -* -* @param acc - accumulated result -* @param value - current array element -* @returns accumulated result -*/ -type BinaryReducer = ( acc: U, value: number ) => U; - -/** -* Reducer function invoked for each element in an array. -* -* @param acc - accumulated result -* @param value - current array element -* @param index - current array element index -* @returns accumulated result -*/ -type TernaryReducer = ( acc: U, value: number, index: number ) => U; - -/** -* @param acc - accumulated result -* @param value - current array element -* @param index - current array element index -* @param arr - array on which the method was called -* @returns accumulated result -*/ -type QuaternaryReducer = ( acc: U, value: number, index: number, arr: Float16Array ) => U; - -/** -* Reducer function invoked for each element in an array. -* -* @param acc - accumulated result -* @param value - current array element -* @param index - current array element index -* @param arr - array on which the method was called -* @returns accumulated result -*/ -type Reducer = NullaryReducer | UnaryReducer | BinaryReducer | TernaryReducer | QuaternaryReducer; - -/** -* Comparator function. -* -* @param a - first number for comparison -* @param b - second number for comparison -* @returns number indicating comparison result -*/ -type CompareFcn = ( a: number, b: number ) => number; - -/** -* Class for creating a half-precision floating-point number array. -*/ -declare class Float16Array { - /** - * Half-precision floating-point number array constructor. - * - * @param arg - length, typed array, array-like object, or buffer - * @param byteOffset - byte offset (default: 0) - * @param length - view length - * @throws ArrayBuffer byte length must be a multiple of `2` - * @throws if provided only a single argument, must provide a valid argument - * @throws byte offset must be a nonnegative integer - * @throws view length must be a positive multiple of `2` - * @throws must provide sufficient memory to accommodate byte offset and view length requirements - * @returns half-precision floating-point number array - * - * @example - * var arr = new Float16Array(); - * // returns - * - * var len = arr.length; - * // returns 0 - * - * @example - * var arr = new Float16Array( 2 ); - * // returns - * - * var len = arr.length; - * // returns 2 - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0 ] ); - * // returns - * - * var len = arr.length; - * // returns 2 - * - * @example - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = new Float16Array( buf ); - * // returns - * - * var len = arr.length; - * // returns 8 - * - * @example - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = new Float16Array( buf, 8 ); - * // returns - * - * var len = arr.length; - * // returns 4 - * - * @example - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = new Float16Array( buf, 8, 2 ); - * // returns - * - * var len = arr.length; - * // returns 2 - */ - constructor( arg?: number | ArrayLike | ArrayBuffer | Iterable, byteOffset?: number, length?: number ); - - /** - * Returns an array element located at integer position (index) `i`, with support for both nonnegative and negative integer indices. - * - * @param i - element index - * @throws index argument must be an integer - * @returns array element - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var v = arr.at( 0 ); - * // returns 1.0 - * - * v = arr.at( -1 ); - * // returns 3.0 - * - * v = arr.at( 100 ); - * // returns undefined - */ - at( i: number ): number | void; - - /** - * Pointer to the underlying data buffer. - * - * @example - * var arr = new Float16Array( 10 ); - * - * var buf = arr.buffer; - * // returns - */ - readonly buffer: ArrayBuffer; - - /** - * Length (in bytes) of the array. - * - * @example - * var arr = new Float16Array( 10 ); - * - * var byteLength = arr.byteLength; - * // returns 20 - */ - readonly byteLength: number; - - /** - * Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`. - * - * @example - * var arr = new Float16Array( 10 ); - * - * var byteOffset = arr.byteOffset; - * // returns 0 - */ - readonly byteOffset: number; - - /** - * Size (in bytes) of each array element. - * - * @example - * var arr = new Float16Array( 10 ); - * - * var nbytes = arr.BYTES_PER_ELEMENT; - * // returns 2 - */ - readonly BYTES_PER_ELEMENT: 2; - - /** - * Number of array elements. - * - * @example - * var arr = new Float16Array( 10 ); - * - * var len = arr.length; - * // returns 10 - */ - readonly length: number; - - /** - * Copies a sequence of elements within the array to the position starting at `target`. - * - * @param target - index at which to start copying elements - * @param start - source index at which to copy elements from - * @param end - source index at which to stop copying elements from - * @returns modified array - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - * - * // Copy the first two elements to the last two elements: - * arr.copyWithin( 2, 0, 2 ); - * - * var v = arr[ 2 ]; - * // returns 1.0 - * - * v = arr[ 3 ]; - * // returns 2.0 - */ - copyWithin( target: number, start: number, end?: number ): Float16Array; - - /** - * Returns an iterator for iterating over array key-value pairs. - * - * @returns iterator - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var it = arr.entries(); - * - * var v = it.next().value; - * // returns [ 0, 1.0 ] - * - * v = it.next().value; - * // returns [ 1, 2.0 ] - * - * v = it.next().value; - * // returns [ 2, 3.0 ] - * - * var bool = it.next().done; - * // returns true - */ - entries(): TypedIterator<[number, number]>; - - /** - * Tests whether all elements in an array pass a test implemented by a predicate function. - * - * @param predicate - predicate function - * @param thisArg - predicate function execution context - * @returns boolean indicating whether all elements pass a test - * - * @example - * function predicate( v ) { - * return v >= 0.0; - * } - * - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var bool = arr.every( predicate ); - * // returns true - */ - every( predicate: Predicate, thisArg?: ThisParameterType> ): boolean; - - /** - * Returns a modified typed array filled with a fill value. - * - * @param value - fill value - * @param start - starting index (inclusive) - * @param end - ending index (exclusive) - * @returns modified typed array - * - * @example - * var arr = new Float16Array( 3 ); - * - * arr.fill( 1.0, 1 ); - * - * var v = arr[ 0 ]; - * // returns 0.0 - * - * v = arr[ 1 ]; - * // returns 1.0 - * - * v = arr[ 2 ]; - * // returns 1.0 - */ - fill( value: number, start?: number, end?: number ): Float16Array; - - /** - * Returns a new array containing the elements of an array which pass a test implemented by a predicate function. - * - * @param predicate - test function - * @param thisArg - execution context - * @returns new array containing elements which pass a test implemented by a predicate function - * - * @example - * function predicate( v ) { - * return ( v >= 2.0 ); - * } - * - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var out = arr.filter( predicate ); - * // returns - * - * var len = out.length; - * // returns 2 - * - * var v = out[ 0 ]; - * // returns 2.0 - * - * v = out[ 1 ]; - * // returns 3.0 - */ - filter( predicate: Predicate, thisArg?: ThisParameterType> ): Float16Array; - - /** - * Returns the first element in an array for which a predicate function returns a truthy value. - * - * @param predicate - predicate function - * @param thisArg - predicate function execution context - * @returns array element or undefined - * - * @example - * function predicate( v ) { - * return v > 1.0; - * } - * - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var v = arr.find( predicate ); - * // returns 2.0 - */ - find( predicate: Predicate, thisArg?: ThisParameterType> ): number | void; - - /** - * Returns the index of the first element in an array for which a predicate function returns a truthy value. - * - * @param predicate - predicate function - * @param thisArg - predicate function execution context - * @returns array index or -1 - * - * @example - * function predicate( v ) { - * return v > 1.0; - * } - * - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var v = arr.findIndex( predicate ); - * // returns 1 - */ - findIndex( predicate: Predicate, thisArg?: ThisParameterType> ): number; - - /** - * Returns the last element in an array for which a predicate function returns a truthy value. - * - * @param predicate - predicate function - * @param thisArg - predicate function execution context - * @returns array element or undefined - * - * @example - * function predicate( v ) { - * return v > 1.0; - * } - * - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var v = arr.findLast( predicate ); - * // returns 3.0 - */ - findLast( predicate: Predicate, thisArg?: ThisParameterType> ): number | void; - - /** - * Returns the index of the last element in an array for which a predicate function returns a truthy value. - * - * @param predicate - predicate function - * @param thisArg - predicate function execution context - * @returns array index or -1 - * - * @example - * function predicate( v ) { - * return v > 1.0; - * } - * - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var v = arr.findLastIndex( predicate ); - * // returns 2 - */ - findLastIndex( predicate: Predicate, thisArg?: ThisParameterType> ): number; - - /** - * Invokes a function once for each array element. - * - * @param fcn - function to invoke - * @param thisArg - execution context - * @returns undefined - * - * @example - * function log( v, i ) { - * console.log( '%s: %s', i, v.toString() ); - * } - * - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * arr.forEach( log ); - */ - forEach( fcn: Callback, thisArg?: ThisParameterType> ): void; - - /** - * Returns a boolean indicating whether an array includes a provided value. - * - * @param searchElement - element to search for - * @param fromIndex - starting index (inclusive) - * @returns boolean indicating whether an array includes a value - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - * - * var bool = arr.includes( 3.0 ); - * // returns true - * - * bool = arr.includes( 3.0, 3 ); - * // returns false - */ - includes( searchElement: number, fromIndex?: number ): boolean; - - /** - * Returns the first index at which a given element can be found. - * - * @param searchElement - element to find - * @param fromIndex - starting index (inclusive) - * @returns index or -1 - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - * - * var idx = arr.indexOf( 3.0 ); - * // returns 2 - * - * idx = arr.indexOf( 3.0, 3 ); - * // returns -1 - * - * idx = arr.indexOf( 6.0 ); - * // returns -1 - */ - indexOf( searchElement: number, fromIndex?: number ): number; - - /** - * Returns a new string by concatenating all array elements. - * - * @param separator - value separator (default: ',') - * @returns string - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var str = arr.join(); - * // returns '1,2,3' - * - * str = arr.join( '|' ); - * // returns '1|2|3' - */ - join( separator?: string ): string; - - /** - * Returns an iterator for iterating over each index key in a typed array. - * - * @returns iterator - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0 ] ); - * - * var iter = arr.keys(); - * - * var v = iter.next().value; - * // returns 0 - * - * v = iter.next().value; - * // returns 1 - * - * var bool = iter.next().done; - * // returns true - */ - keys(): TypedIterator; - - /** - * Returns the last index at which a given element can be found. - * - * @param searchElement - element to find - * @param fromIndex - index at which to start searching backward (inclusive) - * @returns index or -1 - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0, 3.0, 2.0, 1.0 ] ); - * - * var idx = arr.lastIndexOf( 2.0 ); - * // returns 3 - * - * idx = arr.lastIndexOf( 2.0, 2 ); - * // returns 1 - * - * idx = arr.lastIndexOf( 5.0 ); - * // returns -1 - */ - lastIndexOf( searchElement: number, fromIndex?: number ): number; - - /** - * Returns a new array with each element being the result of a provided callback function. - * - * @param fcn - callback function - * @param thisArg - callback function execution context - * @returns new half-precision floating-point number array - * - * @example - * function scale( v ) { - * return v * 2.0; - * } - * - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var out = arr.map( scale ); - * // returns - * - * var v = out[ 0 ]; - * // returns 2.0 - * - * v = out[ 1 ]; - * // returns 4.0 - * - * v = out[ 2 ]; - * // returns 6.0 - */ - map( fcn: MapFcn, thisArg?: ThisParameterType> ): Float16Array; - - /** - * Applies a provided callback function to each element of the array, in order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion. - * - * @param reducer - callback function - * @param initialValue - initial value - * @returns accumulated result - * - * @example - * function reducer( acc, v ) { - * return acc + v; - * } - * - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var out = arr.reduce( reducer, 0.0 ); - * // returns 6.0 - */ - reduce( reducer: Reducer, initialValue?: U ): U; - - /** - * Applies a provided callback function to each element of the array, in reverse order, passing in the return value from the calculation on the following element and returning the accumulated result upon completion. - * - * @param reducer - callback function - * @param initialValue - initial value - * @returns accumulated result - * - * @example - * function reducer( acc, v ) { - * return acc + v; - * } - * - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var out = arr.reduceRight( reducer, 0.0 ); - * // returns 6.0 - */ - reduceRight( reducer: Reducer, initialValue?: U ): U; - - /** - * Reverses an array in-place. - * - * @returns reversed array - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var out = arr.reverse(); - * // returns - * - * var v = out[ 0 ]; - * // returns 3.0 - * - * v = out[ 1 ]; - * // returns 2.0 - * - * v = out[ 2 ]; - * // returns 1.0 - */ - reverse(): Float16Array; - - /** - * Sets one or more array elements. - * - * ## Notes - * - * - When provided a typed array, we must check whether the source array shares the same buffer as the target array and whether the underlying memory overlaps. In particular, we are concerned with the following scenario: - * - * ```text - * buf: --------------------- - * src: --------------------- - * ``` - * - * In the above, as we copy values from `src`, we will overwrite values in the `src` view, resulting in duplicated values copied into the end of `buf`, which is not intended. Hence, to avoid overwriting source values, we must **copy** source values to a temporary array. - * - * In the other overlapping scenario, - * - * ```text - * buf: --------------------- - * src: --------------------- - * ``` - * - * by the time we begin copying into the overlapping region, we are copying from the end of `src`, a non-overlapping region, which means we don't run the risk of copying copied values, rather than the original `src` values as intended. - * - * - * @param value - value(s) - * @param i - element index at which to start writing values (default: 0) - * @throws index argument must be a nonnegative integer - * @throws index argument is out-of-bounds - * @throws target array lacks sufficient storage to accommodate source values - * - * @example - * var arr = new Float16Array( 10 ); - * - * var v = arr[ 0 ]; - * // returns 0.0 - * - * arr.set( [ 1.0 ], 0 ); - * - * v = arr[ 0 ]; - * // returns 1.0 - */ - set( value: ArrayLike, i?: number ): void; - - /** - * Copies a portion of a typed array to a new typed array. - * - * @param start - starting index (inclusive) - * @param end - ending index (exclusive) - * @throws indices must be integers - * @returns output array - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - * - * var out = arr.slice(); - * // returns - * - * var len = out.length; - * // returns 5 - * - * var v = out[ 0 ]; - * // returns 1.0 - * - * v = out[ len-1 ]; - * // returns 5.0 - * - * out = arr.slice( 1, -2 ); - * // returns - * - * len = out.length; - * // returns 2 - * - * v = out[ 0 ]; - * // returns 2.0 - * - * v = out[ len-1 ]; - * // returns 3.0 - */ - slice( start?: number, end?: number ): Float16Array; - - /** - * Tests whether at least one element in an array passes a test implemented by a predicate function. - * - * @param predicate - predicate function - * @param thisArg - predicate function execution context - * @returns boolean indicating whether at least one element passes a test - * - * @example - * function predicate( v ) { - * return v > 2.0; - * } - * - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var bool = arr.some( predicate ); - * // returns true - */ - some( predicate: Predicate, thisArg?: ThisParameterType> ): boolean; - - /** - * Sorts an array in-place. - * - * @param compareFcn - comparison function - * @returns sorted array - * - * @example - * function compare( a, b ) { - * if ( a < b ) { - * return -1; - * } - * if ( a > b ) { - * return 1; - * } - * return 0; - * } - * - * var arr = new Float16Array( [ 3.0, 1.0, 2.0 ] ); - * - * arr.sort( compare ); - * - * var v = arr[ 0 ]; - * // returns 1.0 - * - * v = arr[ 1 ]; - * // returns 2.0 - * - * v = arr[ 2 ]; - * // returns 3.0 - */ - sort( compareFcn?: CompareFcn ): Float16Array; - - /** - * Creates a new typed array view over the same underlying `ArrayBuffer` and with the same underlying data type as the host array. - * - * @param begin - starting index (inclusive) - * @param end - ending index (exclusive) - * @throws indices must be integers - * @returns subarray - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - * - * var subarr = arr.subarray(); - * // returns - * - * var len = subarr.length; - * // returns 5 - * - * var v = subarr[ 0 ]; - * // returns 1.0 - * - * v = subarr[ len-1 ]; - * // returns 5.0 - * - * subarr = arr.subarray( 1, -2 ); - * // returns - * - * len = subarr.length; - * // returns 2 - * - * v = subarr[ 0 ]; - * // returns 2.0 - * - * v = subarr[ len-1 ]; - * // returns 3.0 - */ - subarray( begin?: number, end?: number ): Float16Array; - - /** - * Serializes an array as a locale-specific string. - * - * @param locales - locale identifier(s) - * @param options - configuration options - * @returns string - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var str = arr.toLocaleString(); - * // returns '1,2,3' - */ - toLocaleString( locales?: string | Array, options?: LocaleOptions ): string; - - /** - * Returns a new typed array containing the elements in reversed order. - * - * @returns reversed array - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var out = arr.toReversed(); - * // returns - * - * var v = out[ 0 ]; - * // returns 3.0 - * - * v = out[ 1 ]; - * // returns 2.0 - * - * v = out[ 2 ]; - * // returns 1.0 - */ - toReversed(): Float16Array; - - /** - * Returns a new typed array containing the elements in sorted order. - * - * @param compareFcn - comparison function - * @returns sorted array - * - * @example - * function compare( a, b ) { - * if ( a < b ) { - * return -1; - * } - * if ( a > b ) { - * return 1; - * } - * return 0; - * } - * - * var arr = new Float16Array( [ 3.0, 1.0, 2.0 ] ); - * - * var out = arr.toSorted( compare ); - * // returns - * - * var v = out[ 0 ]; - * // returns 1.0 - * - * v = out[ 1 ]; - * // returns 2.0 - * - * v = out[ 2 ]; - * // returns 3.0 - */ - toSorted( compareFcn?: CompareFcn ): Float16Array; - - /** - * Serializes an array as a string. - * - * @returns string - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var str = arr.toString(); - * // returns '1,2,3' - */ - toString(): string; - - /** - * Returns an iterator for iterating over each value in a typed array. - * - * @returns iterator - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0 ] ); - * - * var iter = arr.values(); - * - * var v = iter.next().value; - * // returns 1.0 - * - * v = iter.next().value; - * // returns 2.0 - * - * var bool = iter.next().done; - * // returns true - */ - values(): TypedIterator; - - /** - * Returns a new typed array with the element at a provided index replaced with a provided value. - * - * @param index - element index - * @param value - new value - * @throws first argument must be an integer - * @throws second argument must be a number - * @throws index argument is out-of-bounds - * @returns modified typed array - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var out = arr.with( 0, 4.0 ); - * // returns - * - * var v = out[ 0 ]; - * // returns 4.0 - */ - with( index: number, value: number ): Float16Array; -} - -/** -* Interface defining a Float16Array constructor which is both "newable" and "callable". -*/ -interface Float16ArrayConstructor { - /** - * Half-precision floating-point number array constructor. - * - * @param arg - length, typed array, array-like object, or buffer - * @param byteOffset - byte offset (default: 0) - * @param length - view length - * @throws ArrayBuffer byte length must be a multiple of `2` - * @throws if provided only a single argument, must provide a valid argument - * @throws byte offset must be a nonnegative integer - * @throws byte offset must be a multiple of `2` - * @throws view length must be a positive multiple of `2` - * @throws must provide sufficient memory to accommodate byte offset and view length requirements - * @returns half-precision floating-point number array - * - * @example - * var arr = new Float16Array(); - * // returns - * - * var len = arr.length; - * // returns 0 - * - * @example - * var arr = new Float16Array( 2 ); - * // returns - * - * var len = arr.length; - * // returns 2 - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0 ] ); - * // returns - * - * var len = arr.length; - * // returns 2 - * - * @example - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = new Float16Array( buf ); - * // returns - * - * var len = arr.length; - * // returns 8 - * - * @example - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = new Float16Array( buf, 8 ); - * // returns - * - * var len = arr.length; - * // returns 4 - * - * @example - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = new Float16Array( buf, 8, 2 ); - * // returns - * - * var len = arr.length; - * // returns 2 - */ - new( arg?: number | ArrayLike | ArrayBuffer | Iterable, byteOffset?: number, length?: number ): Float16Array; - - /** - * Constructor name. - * - * @example - * var str = Float16Array.name; - * // returns 'Float16Array' - */ - readonly name: 'Float16Array'; - - /** - * Size (in bytes) of each array element. - * - * @example - * var nbytes = Float16Array.BYTES_PER_ELEMENT; - * // returns 2 - */ - readonly BYTES_PER_ELEMENT: 2; - - /** - * Creates a new half-precision floating-point number array from an array-like object or an iterable. - * - * @param src - array-like object or iterable - * @param clbk - callback to invoke for each source element - * @param thisArg - context - * @returns half-precision floating-point number array - * - * @example - * var arr = Float16Array.from( [ 1.0, 2.0 ] ); - * // returns - * - * var len = arr.length; - * // returns 2 - * - * @example - * function clbk( v ) { - * return v * 2.0; - * } - * - * var arr = Float16Array.from( [ 1.0, 2.0 ], clbk ); - * // returns - * - * var len = arr.length; - * // returns 2 - */ - from( src: ArrayLike | Iterable, clbk?: FromCallback, thisArg?: ThisParameterType> ): Float16Array; - - /** - * Creates a new half-precision floating-point number array from a variable number of arguments. - * - * @param elements - array elements - * @returns half-precision floating-point number array - * - * @example - * var arr = Float16Array.of( 1.0, 2.0, 3.0, 4.0 ); - * // returns - * - * var len = arr.length; - * // returns 4 - */ - of( ...elements: Array ): Float16Array; -} - -/** -* Half-precision floating-point number array constructor. -* -* @param arg - length, typed array, array-like object, or buffer -* @param byteOffset - byte offset (default: 0) -* @param length - view length -* @throws ArrayBuffer byte length must be a multiple of `2` -* @throws if provided only a single argument, must provide a valid argument -* @throws byte offset must be a nonnegative integer -* @throws byte offset must be a multiple of `2` -* @throws view length must be a positive multiple of `2` -* @throws must provide sufficient memory to accommodate byte offset and view length requirements -* @returns half-precision floating-point number array -* -* @example -* var arr = new Float16Array(); -* // returns -* -* var len = arr.length; -* // returns 0 -* -* @example -* var arr = new Float16Array( 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var arr = new Float16Array( [ 1.0, 2.0 ] ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float16Array( buf ); -* // returns -* -* var len = arr.length; -* // returns 8 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float16Array( buf, 8 ); -* // returns -* -* var len = arr.length; -* // returns 4 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = new Float16Array( buf, 8, 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -*/ -declare var ctor: Float16ArrayConstructor; - - -// EXPORTS // - -export = ctor; - -// eslint-doctest-alias: Float16Array diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 16ac68e..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-float16array-support@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.3-esm/index.mjs";import{isPrimitive as n}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.3-esm/index.mjs";import{primitives as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string-array@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.3-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.3-esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.3-esm/index.mjs";import{isPrimitive as h}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.3-esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.3-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-assert-is-nan@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.4-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.3-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@v0.2.4-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint16@v0.2.3-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-float16@v0.1.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float16-base-to-word@v0.1.1-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float16-base-from-word@v0.2.1-esm/index.mjs";import T from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-base-gcopy@v0.2.3-esm/index.mjs";function _(t){var r,n;for(r=[];!(n=t.next()).done;)r.push(b(m(n.value)));return r}var j=g.BYTES_PER_ELEMENT,x=r();function L(t){return"object"==typeof t&&null!==t&&"Float16Array"===t.constructor.name&&t.BYTES_PER_ELEMENT===j}function R(t){return t===A}function O(t,r){return function(){return t._get(r)}}function S(t,r){return function(n){t.set([n],r)}}function A(){var t,r,i,h,l,u;if(r=arguments.length,!(this instanceof A))return 0===r?new A:1===r?new A(arguments[0]):2===r?new A(arguments[0],arguments[1]):new A(arguments[0],arguments[1],arguments[2]);if(0===r)i=new g(0);else if(1===r)if(n(l=arguments[0]))i=new g(l);else if(e(l))L(l)?(i=new g(l.length),T.ndarray(l.length,new g(l.buffer,l.byteOffset,l.length),1,0,i,1,0)):i=function(t,r){var n,i;for(n=r.length,i=0;ii.byteLength-t)throw new RangeError(d("null2G",h*j));i=new g(i,t,h)}}for(y(this,"_buffer",i),y(this,"_length",i.length),u=0;u1){if(!s(i=arguments[1]))throw new TypeError(d("null2H",i));n>2&&(r=arguments[2])}if(e(t)){if(i){for(f=(o=new this(l=t.length))._buffer,u=0;u=this._length))return E(this._buffer[t])})),w(A.prototype,"buffer",(function(){return this._buffer.buffer})),w(A.prototype,"byteLength",(function(){return this._buffer.byteLength})),w(A.prototype,"byteOffset",(function(){return this._buffer.byteOffset})),y(A.prototype,"BYTES_PER_ELEMENT",A.BYTES_PER_ELEMENT),y(A.prototype,"copyWithin",(function(t,r){if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");return 2===arguments.length?this._buffer.copyWithin(t,r):this._buffer.copyWithin(t,r,arguments[2]),this})),y(A.prototype,"entries",(function(){var t,r,n,i,e,o;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");return t=this,i=this._buffer,n=this._length,o=-1,y(r={},"next",(function(){if(o+=1,e||o>=n)return{done:!0};return{value:[o,E(i[o])],done:!1}})),y(r,"return",(function(t){if(e=!0,arguments.length)return{value:t,done:!0};return{done:!0}})),p&&y(r,p,(function(){return t.entries()})),r})),y(A.prototype,"every",(function(t,r){var n,i;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!s(t))throw new TypeError(d("null3c",t));for(n=this._buffer,i=0;i1){if(!f(r))throw new TypeError(d("null7f",r));if(r<0&&(r+=e)<0&&(r=0),arguments.length>2){if(!f(n))throw new TypeError(d("null2z",n));n<0&&(n+=e)<0&&(n=0),n>e&&(n=e)}else n=e}else r=0,n=e;for(s=b(t),o=r;o=0;e--)if(i=E(n[e]),t.call(r,i,e,this))return i})),y(A.prototype,"findLastIndex",(function(t,r){var n,i,e;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!s(t))throw new TypeError(d("null3c",t));for(n=this._buffer,e=this._length-1;e>=0;e--)if(i=E(n[e]),t.call(r,i,e,this))return e;return-1})),y(A.prototype,"forEach",(function(t,r){var n,i;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!s(t))throw new TypeError(d("null3c",t));for(n=this._buffer,i=0;i=this._length))return E(this._buffer[t])})),y(A.prototype,"includes",(function(t,r){var n,i,e;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!h(t))throw new TypeError(d("null49",t));if(arguments.length>1){if(!f(r))throw new TypeError(d("null7f",r));r<0&&(r+=this._length)<0&&(r=0)}else r=0;for(n=this._buffer,e=b(t),i=r;i1){if(!f(r))throw new TypeError(d("null7f",r));r<0&&(r+=this._length)<0&&(r=0)}else r=0;for(n=this._buffer,e=b(t),i=r;i0){if(!l(t))throw new TypeError(d("null3F",t))}else t=",";for(r=this._buffer,n=[],i=0;i=n)return{done:!0};return{value:e,done:!1}})),y(r,"return",(function(t){if(i=!0,arguments.length)return{value:t,done:!0};return{done:!0}})),p&&y(r,p,(function(){return t.keys()})),r})),y(A.prototype,"lastIndexOf",(function(t,r){var n,i,e;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!h(t))throw new TypeError(d("null49",t));if(arguments.length>1){if(!f(r))throw new TypeError(d("null7f",r));r>=this._length?r=this._length-1:r<0&&(r+=this._length)}else r=this._length-1;for(n=this._buffer,e=b(t),i=r;i>=0;i--)if(e===n[i])return i;return-1})),w(A.prototype,"length",(function(){return this._length})),y(A.prototype,"map",(function(t,r){var n,i,e,o;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!s(t))throw new TypeError(d("null3c"),t);for(e=this._buffer,n=(i=new this.constructor(this._length))._buffer,o=0;o1)e=r,o=0;else{if(0===i)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");e=E(n[0]),o=1}for(;o1)e=r,o=i-1;else{if(0===i)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");e=E(n[i-1]),o=i-2}for(;o>=0;o--)e=t(e,E(n[o]),o,this);return e})),y(A.prototype,"reverse",(function(){var t,r,n,i,e,o;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");for(t=this._buffer,n=this._length,i=v(n/2),e=0;e1){if(!n(i=arguments[1]))throw new TypeError(d("null2L",i))}else i=0;if(i+(h=t.length)>this._length)throw new RangeError(d("null03"));if(L(t)?(r=t._buffer,f=!0):(r=t,f=!1),a=o.byteOffset+i*j,r.buffer===o.buffer&&r.byteOffseta){for(s=new g(r.length),l=0;ls&&(r=s)}}for(n=ti)return 1;return 0})),this;if(!s(t))throw new TypeError(d("null3c",t));return r.sort((function(r,n){return t(E(r),E(n))})),this})),y(A.prototype,"subarray",(function(t,r){var n,i,e;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(i=this._buffer,e=this._length,0===arguments.length)t=0,r=e;else{if(!f(t))throw new TypeError(d("null7e",t));if(t<0&&(t+=e)<0&&(t=0),1===arguments.length)r=e;else{if(!f(r))throw new TypeError(d("null7f",r));r<0?(r+=e)<0&&(r=0):r>e&&(r=e)}}return t>=e?(e=0,n=i.byteLength):t>=r?(e=0,n=i.byteOffset+t*j):(e=r-t,n=i.byteOffset+t*j),new this.constructor(i.buffer,n,e<0?0:e)})),y(A.prototype,"toLocaleString",(function(t,r){var n,e,o,s,f;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(0===arguments.length)e=[];else{if(!l(t)&&!i(t))throw new TypeError(d("invalid argument. First argument must be a string or an array of strings. Value: `%s`.",t));e=t}if(arguments.length<2)n={};else{if(!a(r))throw new TypeError(d("null2V",r));n=r}for(s=this._buffer,o=[],f=0;f=n)return{done:!0};return{value:E(e[o]),done:!1}})),y(t,"return",(function(t){if(i=!0,arguments.length)return{value:t,done:!0};return{done:!0}})),p&&y(t,p,(function(){return r.values()})),t})),y(A.prototype,"with",(function(t,r){var n,i;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!f(t))throw new TypeError(d("null7e",t));if(i=this._length,t<0&&(t+=i),t<0||t>=i)throw new RangeError(d("nullFP",t));if(!h(r))throw new TypeError(d("invalid argument. Second argument must be a floating-point number. Value: `%s`.",r));return(n=new this.constructor(this))[t]=r,n}));var P="function"==typeof Float16Array?Float16Array:void 0,F=t()?P:A;export{F as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index d0d8a32..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/polyfill/from_iterator.js","../lib/polyfill/index.js","../lib/polyfill/from_array.js","../lib/polyfill/from_iterator_map.js","../lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport f16 from '@stdlib/number-float64-base-to-float16';\nimport toWord from '@stdlib/number-float16-base-to-word';\n\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @returns {Array} output array\n*/\nfunction fromIterator( it ) {\n\tvar out;\n\tvar v;\n\n\tout = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tout.push( toWord( f16( v.value ) ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIterator;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this, stdlib/jsdoc-typedef-typos, max-lines */\n\n'use strict';\n\n// MODULES //\n\nimport hasIteratorSymbolSupport from '@stdlib/assert-has-iterator-symbol-support';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport { primitives as isStringArray } from '@stdlib/assert-is-string-array';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isFunction from '@stdlib/assert-is-function';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isObject from '@stdlib/assert-is-object';\nimport isnan from '@stdlib/math-base-assert-is-nan';\nimport ITERATOR_SYMBOL from '@stdlib/symbol-iterator';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadWriteAccessor from '@stdlib/utils-define-read-write-accessor';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport Uint16Array from '@stdlib/array-uint16';\nimport f16 from '@stdlib/number-float64-base-to-float16';\nimport toWord from '@stdlib/number-float16-base-to-word';\nimport fromWord from '@stdlib/number-float16-base-from-word';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport fromArray from './from_array.js';\nimport fromIterator from './from_iterator.js';\nimport fromIteratorMap from './from_iterator_map.js';\n\n\n// VARIABLES //\n\nvar BYTES_PER_ELEMENT = Uint16Array.BYTES_PER_ELEMENT;\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\n\n\n// FUNCTIONS //\n\n/**\n* Returns a boolean indicating if a value is a `Float16Array`.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `Float16Array`\n*/\nfunction isFloat16Array( value ) {\n\treturn (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\tvalue.constructor.name === 'Float16Array' &&\n\t\tvalue.BYTES_PER_ELEMENT === BYTES_PER_ELEMENT\n\t);\n}\n\n/**\n* Returns a boolean indicating if a value is a floating-point typed array constructor.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a floating-point typed array constructor\n*/\nfunction isFloatingPointArrayConstructor( value ) { // eslint-disable-line id-length\n\treturn ( value === Float16Array );\n}\n\n/**\n* Returns a getter.\n*\n* @private\n* @param {Float16Array} ctx - typed array instance\n* @param {NonNegativeInteger} idx - element index\n* @returns {Function} getter\n*/\nfunction getter( ctx, idx ) {\n\treturn get;\n\n\t/**\n\t* Returns an array element.\n\t*\n\t* @private\n\t* @returns {(number|void)} array element\n\t*/\n\tfunction get() {\n\t\treturn ctx._get( idx ); // eslint-disable-line no-underscore-dangle\n\t}\n}\n\n/**\n* Returns a setter.\n*\n* @private\n* @param {Float16Array} ctx - typed array instance\n* @param {NonNegativeInteger} idx - element index\n* @returns {Function} setter\n*/\nfunction setter( ctx, idx ) {\n\treturn set;\n\n\t/**\n\t* Sets an array element.\n\t*\n\t* @private\n\t* @param {number} value - value to set\n\t*/\n\tfunction set( value ) {\n\t\tctx.set( [ value ], idx );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* 16-bit floating-point number array constructor.\n*\n* @constructor\n* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable\n* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n* @param {NonNegativeInteger} [length] - view length\n* @throws {RangeError} ArrayBuffer byte length must be a multiple of `2`\n* @throws {TypeError} if provided only a single argument, must provide a valid argument\n* @throws {TypeError} byte offset must be a nonnegative integer\n* @throws {RangeError} byte offset must be a multiple of `2`\n* @throws {TypeError} view length must be a positive multiple of `2`\n* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n* @returns {Float16Array} half-precision floating-point number array\n*\n* @example\n* var arr = new Float16Array();\n* // returns \n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var arr = new Float16Array( 5 );\n* // returns \n*\n* var len = arr.length;\n* // returns 5\n*\n* @example\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 5\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float16Array( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 8\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float16Array( buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 4\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Float16Array( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nfunction Float16Array() {\n\tvar byteOffset;\n\tvar nargs;\n\tvar buf;\n\tvar len;\n\tvar arg;\n\tvar i;\n\n\tnargs = arguments.length;\n\tif ( !(this instanceof Float16Array) ) {\n\t\tif ( nargs === 0 ) {\n\t\t\treturn new Float16Array();\n\t\t}\n\t\tif ( nargs === 1 ) {\n\t\t\treturn new Float16Array( arguments[0] );\n\t\t}\n\t\tif ( nargs === 2 ) {\n\t\t\treturn new Float16Array( arguments[0], arguments[1] );\n\t\t}\n\t\treturn new Float16Array( arguments[0], arguments[1], arguments[2] );\n\t}\n\t// Create the underlying data buffer...\n\tif ( nargs === 0 ) {\n\t\tbuf = new Uint16Array( 0 ); // backward-compatibility\n\t} else if ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\t\tif ( isNonNegativeInteger( arg ) ) {\n\t\t\tbuf = new Uint16Array( arg );\n\t\t} else if ( isCollection( arg ) ) {\n\t\t\tif ( isFloat16Array( arg ) ) {\n\t\t\t\tbuf = new Uint16Array( arg.length );\n\t\t\t\tgcopy.ndarray( arg.length, new Uint16Array( arg.buffer, arg.byteOffset, arg.length ), 1, 0, buf, 1, 0 ); // eslint-disable-line max-len\n\t\t\t} else {\n\t\t\t\tbuf = fromArray( new Uint16Array( arg.length ), arg );\n\t\t\t}\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tif ( !isInteger( arg.byteLength/BYTES_PER_ELEMENT ) ) {\n\t\t\t\tthrow new RangeError( format( 'nullE9', BYTES_PER_ELEMENT, arg.byteLength ) );\n\t\t\t}\n\t\t\tbuf = new Uint16Array( arg );\n\t\t} else if ( isObject( arg ) ) {\n\t\t\tif ( HAS_ITERATOR_SYMBOL === false ) {\n\t\t\t\tthrow new TypeError( format( 'null29', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2A', arg ) );\n\t\t\t}\n\t\t\tbuf = arg[ ITERATOR_SYMBOL ]();\n\t\t\tif ( !isFunction( buf.next ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2A', arg ) );\n\t\t\t}\n\t\t\tbuf = new Uint16Array( fromIterator( buf ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( 'null2A', arg ) );\n\t\t}\n\t} else {\n\t\tbuf = arguments[ 0 ];\n\t\tif ( !isArrayBuffer( buf ) ) {\n\t\t\tthrow new TypeError( format( 'null2B', buf ) );\n\t\t}\n\t\tbyteOffset = arguments[ 1 ];\n\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\tthrow new TypeError( format( 'null2C', byteOffset ) );\n\t\t}\n\t\tif ( !isInteger( byteOffset/BYTES_PER_ELEMENT ) ) {\n\t\t\tthrow new RangeError( format( 'nullEA', BYTES_PER_ELEMENT, byteOffset ) );\n\t\t}\n\t\tif ( nargs === 2 ) {\n\t\t\tlen = buf.byteLength - byteOffset;\n\t\t\tif ( !isInteger( len/BYTES_PER_ELEMENT ) ) {\n\t\t\t\tthrow new RangeError( format( 'null2E', BYTES_PER_ELEMENT, len ) );\n\t\t\t}\n\t\t\tbuf = new Uint16Array( buf, byteOffset );\n\t\t} else {\n\t\t\tlen = arguments[ 2 ];\n\t\t\tif ( !isNonNegativeInteger( len ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2F', len ) );\n\t\t\t}\n\t\t\tif ( (len*BYTES_PER_ELEMENT) > (buf.byteLength-byteOffset) ) {\n\t\t\t\tthrow new RangeError( format( 'null2G', len*BYTES_PER_ELEMENT ) );\n\t\t\t}\n\t\t\tbuf = new Uint16Array( buf, byteOffset, len );\n\t\t}\n\t}\n\tsetReadOnly( this, '_buffer', buf );\n\tsetReadOnly( this, '_length', buf.length );\n\tfor ( i = 0; i < buf.length; i++ ) {\n\t\tsetReadWriteAccessor( this, i, getter( this, i ), setter( this, i ) );\n\t}\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each array element.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Float16Array\n* @readonly\n* @type {PositiveInteger}\n* @default 2\n*\n* @example\n* var nbytes = Float16Array.BYTES_PER_ELEMENT;\n* // returns 2\n*/\nsetReadOnly( Float16Array, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT );\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof Float16Array\n* @readonly\n* @type {string}\n* @default 'Float16Array'\n*\n* @example\n* var str = Float16Array.name;\n* // returns 'Float16Array'\n*/\nsetReadOnly( Float16Array, 'name', 'Float16Array' );\n\n/**\n* Creates a new 16-bit floating-point number array from an array-like object or an iterable.\n*\n* @name from\n* @memberof Float16Array\n* @type {Function}\n* @param {(Collection|Iterable)} src - array-like object or iterable\n* @param {Function} [clbk] - callback to invoke for each source element\n* @param {*} [thisArg] - context\n* @throws {TypeError} `this` context must be a constructor\n* @throws {TypeError} `this` must be a floating-point array\n* @throws {TypeError} first argument must be an array-like object or an iterable\n* @throws {TypeError} second argument must be a function\n* @returns {Float16Array} half-precision floating-point number array\n*\n* @example\n* var arr = Float16Array.from( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* function clbk( v ) {\n* return v * 2.0;\n* }\n*\n* var arr = Float16Array.from( [ 1.0, 2.0 ], clbk );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nsetReadOnly( Float16Array, 'from', function from( src ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar clbk;\n\tvar out;\n\tvar buf;\n\tvar tmp;\n\tvar len;\n\tvar i;\n\tif ( !isFunction( this ) ) {\n\t\tthrow new TypeError( format('null01') );\n\t}\n\tif ( !isFloatingPointArrayConstructor( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point array.' );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs > 1 ) {\n\t\tclbk = arguments[ 1 ];\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'null2H', clbk ) );\n\t\t}\n\t\tif ( nargs > 2 ) {\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( isCollection( src ) ) {\n\t\tif ( clbk ) {\n\t\t\tlen = src.length;\n\t\t\tout = new this( len );\n\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tbuf[ i ] = toWord( f16( clbk.call( thisArg, src[ i ], i ) ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\treturn new this( src );\n\t}\n\tif ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) { // eslint-disable-line max-len\n\t\tbuf = src[ ITERATOR_SYMBOL ]();\n\t\tif ( !isFunction( buf.next ) ) {\n\t\t\tthrow new TypeError( format( 'null2J', src ) );\n\t\t}\n\t\tif ( clbk ) {\n\t\t\ttmp = fromIteratorMap( buf, clbk, thisArg );\n\t\t} else {\n\t\t\ttmp = fromIterator( buf );\n\t\t}\n\t\tif ( tmp instanceof Error ) {\n\t\t\tthrow tmp;\n\t\t}\n\t\tlen = tmp.length;\n\t\tout = new this( len );\n\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tbuf[ i ] = tmp[ i ];\n\t\t}\n\t\treturn out;\n\t}\n\tthrow new TypeError( format( 'null2J', src ) );\n});\n\n/**\n* Creates a new 16-bit floating-point number array from a variable number of arguments.\n*\n* @name of\n* @memberof Float16Array\n* @type {Function}\n* @param {...*} element - array elements\n* @throws {TypeError} `this` context must be a constructor\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Float16Array} half-precision floating-point number array\n*\n* @example\n* var arr = Float16Array.of( 1.0, 1.0, 1.0, 1.0 );\n* // returns \n*\n* var x = arr[ 0 ];\n* // returns 1.0\n*\n* var len = arr.length;\n* // returns 4\n*/\nsetReadOnly( Float16Array, 'of', function of() {\n\tvar args;\n\tvar i;\n\tif ( !isFunction( this ) ) {\n\t\tthrow new TypeError( format('null01') );\n\t}\n\tif ( !isFloatingPointArrayConstructor( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\targs = [];\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\targs.push( arguments[ i ] );\n\t}\n\treturn new this( args );\n});\n\n/**\n* Returns an array element with support for both nonnegative and negative integer indices.\n*\n* @name at\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} must provide an integer\n* @returns {(number|void)} array element\n*\n* @example\n* var arr = new Float16Array( [ 10.0, 20.0, 30.0 ] );\n*\n* var v = arr.at( 0 );\n* // returns 10.0\n*\n* v = arr.at( -1 );\n* // returns 30.0\n*\n* v = arr.at( 100 );\n* // returns undefined\n*/\nsetReadOnly( Float16Array.prototype, 'at', function at( idx ) {\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'null8A', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += this._length;\n\t}\n\tif ( idx < 0 || idx >= this._length ) {\n\t\treturn;\n\t}\n\treturn fromWord( this._buffer[ idx ] );\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name buffer\n* @memberof Float16Array.prototype\n* @readonly\n* @type {ArrayBuffer}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var buf = arr.buffer;\n* // returns \n*/\nsetReadOnlyAccessor( Float16Array.prototype, 'buffer', function get() {\n\treturn this._buffer.buffer;\n});\n\n/**\n* Size (in bytes) of the array.\n*\n* @name byteLength\n* @memberof Float16Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var byteLength = arr.byteLength;\n* // returns 20\n*/\nsetReadOnlyAccessor( Float16Array.prototype, 'byteLength', function get() {\n\treturn this._buffer.byteLength;\n});\n\n/**\n* Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`.\n*\n* @name byteOffset\n* @memberof Float16Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var byteOffset = arr.byteOffset;\n* // returns 0\n*/\nsetReadOnlyAccessor( Float16Array.prototype, 'byteOffset', function get() {\n\treturn this._buffer.byteOffset;\n});\n\n/**\n* Size (in bytes) of each array element.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Float16Array.prototype\n* @readonly\n* @type {PositiveInteger}\n* @default 2\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var nbytes = arr.BYTES_PER_ELEMENT;\n* // returns 2\n*/\nsetReadOnly( Float16Array.prototype, 'BYTES_PER_ELEMENT', Float16Array.BYTES_PER_ELEMENT );\n\n/**\n* Copies a sequence of elements within the array to the position starting at `target`.\n*\n* @name copyWithin\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} target - index at which to start copying elements\n* @param {integer} start - source index at which to copy elements from\n* @param {integer} [end] - source index at which to stop copying elements from\n* @throws {TypeError} `this` must be a floating-point array\n* @returns {Float16Array} modified array\n*\n* @example\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0 ] );\n*\n* // Copy the first two elements to the last two elements:\n* arr.copyWithin( 2, 0, 2 );\n*\n* var v = arr[ 2 ];\n* // returns 1.0\n*\n* v = arr[ 3 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'copyWithin', function copyWithin( target, start ) {\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\t// FIXME: prefer a functional `copyWithin` implementation which addresses lack of universal browser support (e.g., IE11 and Safari) or ensure that typed arrays are polyfilled\n\tif ( arguments.length === 2 ) {\n\t\tthis._buffer.copyWithin( target, start );\n\t} else {\n\t\tthis._buffer.copyWithin( target, start, arguments[2] );\n\t}\n\treturn this;\n});\n\n/**\n* Returns an iterator for iterating over array key-value pairs.\n*\n* @name entries\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] );\n*\n* var it = arr.entries();\n*\n* var v = it.next().value;\n* // returns [ 0, 1.0 ]\n*\n* v = it.next().value;\n* // returns [ 1, 2.0 ]\n*\n* v = it.next().value;\n* // returns [ 2, 3.0 ]\n*\n* var bool = it.next().done;\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'entries', function entries() {\n\tvar self;\n\tvar iter;\n\tvar len;\n\tvar buf;\n\tvar FLG;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tself = this;\n\tbuf = this._buffer;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': [ i, fromWord( buf[ i ] ) ],\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.entries();\n\t}\n});\n\n/**\n* Tests whether all elements in an array pass a test implemented by a predicate function.\n*\n* @name every\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {boolean} boolean indicating whether all elements pass a test\n*\n* @example\n* function predicate( v ) {\n* return v === 0.0;\n* }\n*\n* var arr = new Float16Array( 3 );\n*\n* var bool = arr.every( predicate );\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'every', function every( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( !predicate.call( thisArg, fromWord( buf[ i ] ), i, this ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n});\n\n/**\n* Returns a modified typed array filled with a fill value.\n*\n* @name fill\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {number} value - fill value\n* @param {integer} [start=0] - starting index (inclusive)\n* @param {integer} [end] - ending index (exclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a floating-point number\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be an integer\n* @returns {Float16Array} modified array\n*\n* @example\n* var arr = new Float16Array( 3 );\n*\n* arr.fill( 1.0, 1 );\n*\n* var v = arr[ 0 ];\n* // returns 0.0\n*\n* v = arr[ 1 ];\n* // returns 1.0\n*\n* v = arr[ 2 ];\n* // returns 1.0\n*/\nsetReadOnly( Float16Array.prototype, 'fill', function fill( value, start, end ) {\n\tvar buf;\n\tvar len;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNumber( value ) ) {\n\t\tthrow new TypeError( format( 'null49', value ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( start ) ) {\n\t\t\tthrow new TypeError( format( 'null7f', start ) );\n\t\t}\n\t\tif ( start < 0 ) {\n\t\t\tstart += len;\n\t\t\tif ( start < 0 ) {\n\t\t\t\tstart = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length > 2 ) {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2z', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t} else {\n\t\t\tend = len;\n\t\t}\n\t} else {\n\t\tstart = 0;\n\t\tend = len;\n\t}\n\tv = toWord( value );\n\tfor ( i = start; i < end; i++ ) {\n\t\tbuf[ i ] = v;\n\t}\n\treturn this;\n});\n\n/**\n* Returns a new array containing the elements of an array which pass a test implemented by a predicate function.\n*\n* @name filter\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {Float16Array} floating-point number array\n*\n* @example\n* function predicate( v ) {\n* return ( v === 0.0 );\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] );\n*\n* var out = arr.filter( predicate );\n* // returns \n*\n* var len = out.length;\n* // returns 2\n*\n* var v = out[ 0 ];\n* // returns 0.0\n*\n* v = out[ 1 ];\n* // returns 0.0\n*/\nsetReadOnly( Float16Array.prototype, 'filter', function filter( predicate, thisArg ) {\n\tvar buf;\n\tvar out;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\tout.push( v );\n\t\t}\n\t}\n\treturn new this.constructor( out );\n});\n\n/**\n* Returns the first element in an array for which a predicate function returns a truthy value.\n*\n* @name find\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {(boolean|void)} array element or undefined\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] );\n*\n* var v = arr.find( predicate );\n* // returns 1.0\n*/\nsetReadOnly( Float16Array.prototype, 'find', function find( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn v;\n\t\t}\n\t}\n});\n\n/**\n* Returns the index of the first element in an array for which a predicate function returns a truthy value.\n*\n* @name findIndex\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {integer} index or -1\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var v = arr.findIndex( predicate );\n* // returns 1\n*/\nsetReadOnly( Float16Array.prototype, 'findIndex', function findIndex( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Returns the last element in an array for which a predicate function returns a truthy value.\n*\n* @name findLast\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {(boolean|void)} array element or undefined\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] );\n*\n* var v = arr.findLast( predicate );\n* // returns 1.0\n*/\nsetReadOnly( Float16Array.prototype, 'findLast', function findLast( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = this._length-1; i >= 0; i-- ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn v;\n\t\t}\n\t}\n});\n\n/**\n* Returns the index of the last element in an array for which a predicate function returns a truthy value.\n*\n* @name findLastIndex\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {integer} index or -1\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] );\n*\n* var v = arr.findLastIndex( predicate );\n* // returns 1\n*/\nsetReadOnly( Float16Array.prototype, 'findLastIndex', function findLastIndex( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = this._length-1; i >= 0; i-- ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Invokes a function once for each array element.\n*\n* @name forEach\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} fcn - function to invoke\n* @param {*} [thisArg] - function invocation context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n*\n* @example\n* function log( v, i ) {\n* console.log( '%s: %s', i, v.toString() );\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* arr.forEach( log );\n*/\nsetReadOnly( Float16Array.prototype, 'forEach', function forEach( fcn, thisArg ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( fcn ) ) {\n\t\tthrow new TypeError( format( 'null3c', fcn ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tfcn.call( thisArg, fromWord( buf[ i ] ), i, this );\n\t}\n});\n\n/**\n* Returns an array element.\n*\n* @private\n* @name _get\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {NonNegativeInteger} idx - element index\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} must provide a nonnegative integer\n* @returns {(number|void)} array element\n*/\nsetReadOnly( Float16Array.prototype, '_get', function get( idx ) {\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNonNegativeInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'null2K', idx ) );\n\t}\n\tif ( idx >= this._length ) {\n\t\treturn;\n\t}\n\treturn fromWord( this._buffer[ idx ] );\n});\n\n/**\n* Returns a boolean indicating whether an array includes a provided value.\n*\n* @name includes\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {number} searchElement - search element\n* @param {integer} [fromIndex=0] - starting index (inclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a floating-point number\n* @throws {TypeError} second argument must be an integer\n* @returns {boolean} boolean indicating whether an array includes a value\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] );\n*\n* var bool = arr.includes( 1.0 );\n* // returns true\n*\n* bool = arr.includes( 1.0, 2 );\n* // returns false\n*\n* bool = arr.includes( 5.0 );\n* // returns false\n*/\nsetReadOnly( Float16Array.prototype, 'includes', function includes( searchElement, fromIndex ) {\n\tvar buf;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNumber( searchElement ) ) {\n\t\tthrow new TypeError( format( 'null49', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'null7f', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\tfromIndex = 0;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfromIndex = 0;\n\t}\n\tbuf = this._buffer;\n\tv = toWord( searchElement );\n\tfor ( i = fromIndex; i < this._length; i++ ) {\n\t\tif ( v === buf[ i ] ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n});\n\n/**\n* Returns the first index at which a given element can be found.\n*\n* @name indexOf\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {float16} searchElement - element to find\n* @param {integer} [fromIndex=0] - starting index (inclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a floating-point number\n* @throws {TypeError} second argument must be an integer\n* @returns {integer} index or -1\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] );\n*\n* var idx = arr.indexOf( 2.0 );\n* // returns 2\n*\n* idx = arr.indexOf( 2.0, 3 );\n* // returns -1\n*\n* idx = arr.indexOf( 3.0, 3 );\n* // returns 3\n*/\nsetReadOnly( Float16Array.prototype, 'indexOf', function indexOf( searchElement, fromIndex ) {\n\tvar buf;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNumber( searchElement ) ) {\n\t\tthrow new TypeError( format( 'null49', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'null7f', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\tfromIndex = 0;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfromIndex = 0;\n\t}\n\tbuf = this._buffer;\n\tv = toWord( searchElement );\n\tfor ( i = fromIndex; i < this._length; i++ ) {\n\t\tif ( v === buf[ i ] ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Returns a new string by concatenating all array elements.\n*\n* @name join\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {string} [separator=','] - element separator\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a string\n* @returns {string} string representation\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var str = arr.join();\n* // returns '0,1,2'\n*\n* str = arr.join( '|' );\n* // returns '0|1|2'\n*/\nsetReadOnly( Float16Array.prototype, 'join', function join( separator ) {\n\tvar buf;\n\tvar out;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( arguments.length > 0 ) {\n\t\tif ( !isString( separator ) ) {\n\t\t\tthrow new TypeError( format( 'null3F', separator ) );\n\t\t}\n\t} else {\n\t\tseparator = ',';\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( fromWord( buf[ i ] ) );\n\t}\n\treturn out.join( separator );\n});\n\n/**\n* Returns an iterator for iterating over each index key in a typed array.\n*\n* @name keys\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new Float16Array( [ 1.0, 2.0 ] );\n*\n* var iter = arr.keys();\n*\n* var v = iter.next().value;\n* // returns 0\n*\n* v = iter.next().value;\n* // returns 1\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'keys', function keys() {\n\tvar self;\n\tvar iter;\n\tvar len;\n\tvar FLG;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tself = this;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': i,\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.keys();\n\t}\n});\n\n/**\n* Returns the last index at which a given element can be found.\n*\n* @name lastIndexOf\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {number} searchElement - element to find\n* @param {integer} [fromIndex] - starting index (inclusive)\n* @throws {TypeError} `this` must be a floating-point number\n* @throws {TypeError} first argument must be a numeric value\n* @throws {TypeError} second argument must be an integer\n* @returns {integer} index or -1\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 2.0 ] );\n*\n* var idx = arr.lastIndexOf( 2.0 );\n* // returns 4\n*\n* idx = arr.lastIndexOf( 2.0, 3 );\n* // returns 2\n*\n* idx = arr.lastIndexOf( 4.0, 3 );\n* // returns -1\n*\n* idx = arr.lastIndexOf( 1.0, -3 );\n* // returns 1\n*/\nsetReadOnly( Float16Array.prototype, 'lastIndexOf', function lastIndexOf( searchElement, fromIndex ) {\n\tvar buf;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNumber( searchElement ) ) {\n\t\tthrow new TypeError( format( 'null49', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'null7f', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex >= this._length ) {\n\t\t\tfromIndex = this._length - 1;\n\t\t} else if ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t}\n\t} else {\n\t\tfromIndex = this._length - 1;\n\t}\n\tbuf = this._buffer;\n\tv = toWord( searchElement );\n\tfor ( i = fromIndex; i >= 0; i-- ) {\n\t\tif ( v === buf[ i ] ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Number of array elements.\n*\n* @name length\n* @memberof Float16Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var len = arr.length;\n* // returns 10\n*/\nsetReadOnlyAccessor( Float16Array.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Returns a new array with each element being the result of a provided callback function.\n*\n* @name map\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} fcn - callback function\n* @param {*} [thisArg] - callback function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {Float16Array} new floating-point number array\n*\n* @example\n* function scale( v ) {\n* return v * 2.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var out = arr.map( scale );\n* // returns \n*\n* var z = out[ 0 ];\n* // returns 0.0\n*\n* z = out[ 1 ];\n* // returns 2.0\n*\n* z = out[ 2 ];\n* // returns 4.0\n*/\nsetReadOnly( Float16Array.prototype, 'map', function map( fcn, thisArg ) {\n\tvar outbuf;\n\tvar out;\n\tvar buf;\n\tvar i;\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( fcn ) ) {\n\t\tthrow new TypeError( format('null3c'), fcn );\n\t}\n\tbuf = this._buffer;\n\tout = new this.constructor( this._length );\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\toutbuf[ i ] = toWord( fcn.call( thisArg, fromWord( buf[ i ] ), i, this ) ); // eslint-disable-line max-len\n\t}\n\treturn out;\n});\n\n/**\n* Applies a provided callback function to each element of the array, in order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion.\n*\n* @name reduce\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} reducer - callback function\n* @param {*} [initialValue] - initial value\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {Error} if not provided an initial value, the array must have at least one element\n* @returns {*} accumulated result\n*\n* @example\n* function add( acc, v ) {\n* return acc + v;\n* }\n*\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] );\n*\n* var out = arr.reduce( add, 0 );\n* // returns 6.0\n*/\nsetReadOnly( Float16Array.prototype, 'reduce', function reduce( reducer, initialValue ) {\n\tvar buf;\n\tvar len;\n\tvar acc;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( reducer ) ) {\n\t\tthrow new TypeError( format( 'null3c', reducer ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tacc = initialValue;\n\t\ti = 0;\n\t} else {\n\t\tif ( len === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' );\n\t\t}\n\t\tacc = fromWord( buf[ 0 ] );\n\t\ti = 1;\n\t}\n\tfor ( ; i < len; i++ ) {\n\t\tacc = reducer( acc, fromWord( buf[ i ] ), i, this );\n\t}\n\treturn acc;\n});\n\n/**\n* Applies a provided callback function to each element of the array, in reverse order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion.\n*\n* @name reduceRight\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} reducer - callback function\n* @param {*} [initialValue] - initial value\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {Error} if not provided an initial value, the array must have at least one element\n* @returns {*} accumulated result\n*\n* @example\n* function add( acc, v ) {\n* return acc + v;\n* }\n*\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] );\n*\n* var out = arr.reduceRight( add, 0 );\n* // returns 6.0\n*/\nsetReadOnly( Float16Array.prototype, 'reduceRight', function reduceRight( reducer, initialValue ) {\n\tvar buf;\n\tvar len;\n\tvar acc;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( reducer ) ) {\n\t\tthrow new TypeError( format( 'null3c', reducer ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tacc = initialValue;\n\t\ti = len - 1;\n\t} else {\n\t\tif ( len === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' );\n\t\t}\n\t\tacc = fromWord( buf[ len-1 ] );\n\t\ti = len - 2;\n\t}\n\tfor ( ; i >= 0; i-- ) {\n\t\tacc = reducer( acc, fromWord( buf[ i ] ), i, this );\n\t}\n\treturn acc;\n});\n\n/**\n* Reverses an array in-place.\n*\n* @name reverse\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Float16Array} reversed array\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var out = arr.reverse();\n* // returns \n*\n* var v = out[ 0 ];\n* // returns 2.0\n*\n* v = out[ 1 ];\n* // returns 1.0\n*\n* v = out[ 2 ];\n* // returns 0.0\n*/\nsetReadOnly( Float16Array.prototype, 'reverse', function reverse() {\n\tvar buf;\n\tvar tmp;\n\tvar len;\n\tvar N;\n\tvar i;\n\tvar j;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tN = floor( len / 2 );\n\tfor ( i = 0; i < N; i++ ) {\n\t\tj = len - i - 1;\n\t\ttmp = buf[ i ];\n\t\tbuf[ i ] = buf[ j ];\n\t\tbuf[ j ] = tmp;\n\t}\n\treturn this;\n});\n\n/**\n* Sets one or more array elements.\n*\n* ## Notes\n*\n* - When provided a typed array, we must check whether the source array shares the same buffer as the target array and whether the underlying memory overlaps. In particular, we are concerned with the following scenario:\n*\n* ```text\n* buf: ---------------------\n* src: ---------------------\n* ```\n*\n* In the above, as we copy values from `src`, we will overwrite values in the `src` view, resulting in duplicated values copied into the end of `buf`, which is not intended. Hence, to avoid overwriting source values, we must **copy** source values to a temporary array.\n*\n* In the other overlapping scenario,\n*\n* ```text\n* buf: ---------------------\n* src: ---------------------\n* ```\n*\n* by the time we begin copying into the overlapping region, we are copying from the end of `src`, a non-overlapping region, which means we don't run the risk of copying copied values, rather than the original `src` values, as intended.\n*\n* @name set\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {(Collection|Float16Array)} value - value(s)\n* @param {NonNegativeInteger} [i=0] - element index at which to start writing values\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a collection\n* @throws {TypeError} index argument must be a nonnegative integer\n* @throws {RangeError} index argument is out-of-bounds\n* @throws {RangeError} target array lacks sufficient storage to accommodate source values\n* @returns {void}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var v = arr[ 0 ];\n* // returns 0.0\n*\n* arr.set( [ 1.0, 2.0 ], 0 );\n*\n* v = arr[ 0 ];\n* // returns 1.0\n*/\nsetReadOnly( Float16Array.prototype, 'set', function set( value ) {\n\tvar sbuf;\n\tvar idx;\n\tvar buf;\n\tvar tmp;\n\tvar flg;\n\tvar N;\n\tvar i;\n\tvar j;\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isCollection( value ) ) {\n\t\tthrow new TypeError( format( 'null2O', value ) );\n\t}\n\tbuf = this._buffer;\n\tif ( arguments.length > 1 ) {\n\t\tidx = arguments[ 1 ];\n\t\tif ( !isNonNegativeInteger( idx ) ) {\n\t\t\tthrow new TypeError( format( 'null2L', idx ) );\n\t\t}\n\t} else {\n\t\tidx = 0;\n\t}\n\tN = value.length;\n\tif ( idx+N > this._length ) {\n\t\tthrow new RangeError( format('null03') );\n\t}\n\tif ( isFloat16Array( value ) ) {\n\t\tsbuf = value._buffer; // eslint-disable-line no-underscore-dangle\n\t\tflg = true;\n\t} else {\n\t\tsbuf = value;\n\t\tflg = false;\n\t}\n\t// Check for overlapping memory...\n\tj = buf.byteOffset + (idx*BYTES_PER_ELEMENT);\n\tif (\n\t\tsbuf.buffer === buf.buffer &&\n\t\t(\n\t\t\tsbuf.byteOffset < j &&\n\t\t\tsbuf.byteOffset+sbuf.byteLength > j\n\t\t)\n\t) {\n\t\t// We need to copy source values...\n\t\ttmp = new Uint16Array( sbuf.length );\n\t\tfor ( i = 0; i < sbuf.length; i++ ) {\n\t\t\ttmp[ i ] = sbuf[ i ];\n\t\t}\n\t\tsbuf = tmp;\n\t}\n\tif ( flg ) {\n\t\tfor ( i = 0; i < N; idx++, i++ ) {\n\t\t\tbuf[ idx ] = sbuf[ i ];\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < N; idx++, i++ ) {\n\t\t\tbuf[ idx ] = toWord( sbuf[ i ] );\n\t\t}\n\t}\n});\n\n/**\n* Copies a portion of a typed array to a new typed array.\n*\n* @name slice\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} [begin] - start index (inclusive)\n* @param {integer} [end] - end index (exclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be integer\n* @throws {TypeError} second argument must be integer\n* @returns {Float16Array} floating-point number array\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] );\n*\n* var out = arr.slice();\n* // returns \n*\n* var len = out.length;\n* // returns 5\n*\n* var v = out[ 0 ];\n* // returns 0.0\n*\n* v = out[ len-1 ];\n* // returns 4.0\n*\n* out = arr.slice( 1, -2 );\n* // returns \n*\n* len = out.length;\n* // returns 2\n*\n* v = out[ 0 ];\n* // returns 1.0\n*\n* v = out[ len-1 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'slice', function slice( begin, end ) {\n\tvar outlen;\n\tvar outbuf;\n\tvar out;\n\tvar buf;\n\tvar len;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length === 0 ) {\n\t\tbegin = 0;\n\t\tend = len;\n\t} else {\n\t\tif ( !isInteger( begin ) ) {\n\t\t\tthrow new TypeError( format( 'null7e', begin ) );\n\t\t}\n\t\tif ( begin < 0 ) {\n\t\t\tbegin += len;\n\t\t\tif ( begin < 0 ) {\n\t\t\t\tbegin = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\tend = len;\n\t\t} else {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'null7f', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t} else if ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t}\n\t}\n\tif ( begin < end ) {\n\t\toutlen = end - begin;\n\t} else {\n\t\toutlen = 0;\n\t}\n\tout = new this.constructor( outlen );\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < outlen; i++ ) {\n\t\toutbuf[ i ] = buf[ i+begin ];\n\t}\n\treturn out;\n});\n\n/**\n* Tests whether at least one element in an array passes a test implemented by a predicate function.\n*\n* @name some\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {boolean} boolean indicating whether at least one element passes a test\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var bool = arr.some( predicate );\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'some', function some( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( predicate.call( thisArg, fromWord( buf[ i ] ), i, this ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n});\n\n/**\n* Sorts an array in-place.\n*\n* @name sort\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} [compareFcn] - comparison function\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {Float16Array} sorted array\n*\n* @example\n* function compare( a, b ) {\n* if ( a < b ) {\n* return -1;\n* }\n* if ( a > b ) {\n* return 1;\n* }\n* return 0;\n* }\n*\n* var arr = new Float16Array( [ 1.0, 0.0, 2.0 ] );\n*\n* arr.sort( compare );\n*\n* var v = arr[ 0 ];\n* // returns 0.0\n*\n* v = arr[ 1 ];\n* // returns 1.0\n*\n* v = arr[ 2 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'sort', function sort( compareFcn ) {\n\tvar buf;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tif ( arguments.length === 0 ) {\n\t\tbuf.sort( defaultCompare );\n\t\treturn this;\n\t}\n\tif ( !isFunction( compareFcn ) ) {\n\t\tthrow new TypeError( format( 'null3c', compareFcn ) );\n\t}\n\tbuf.sort( compare );\n\treturn this;\n\n\t/**\n\t* Default comparison function for float16 values.\n\t*\n\t* @private\n\t* @param {unsigned16} a - unsigned 16-bit integer for comparison\n\t* @param {unsigned16} b - unsigned 16-bit integer for comparison\n\t* @returns {number} comparison result\n\t*/\n\tfunction defaultCompare( a, b ) { // eslint-disable-line stdlib/no-unnecessary-nested-functions\n\t\tvar x = fromWord( a );\n\t\tvar y = fromWord( b );\n\n\t\t// Handle NaN...\n\t\tif ( isnan( x ) && isnan( y ) ) {\n\t\t\treturn 0;\n\t\t}\n\t\tif ( isnan( x ) ) {\n\t\t\treturn 1;\n\t\t}\n\t\tif ( isnan( y ) ) {\n\t\t\treturn -1;\n\t\t}\n\t\t// Normal comparison\n\t\tif ( x < y ) {\n\t\t\treturn -1;\n\t\t}\n\t\tif ( x > y ) {\n\t\t\treturn 1;\n\t\t}\n\t\treturn 0;\n\t}\n\n\t/**\n\t* Comparison function wrapper.\n\t*\n\t* @private\n\t* @param {unsigned16} a - unsigned 16-bit integer for comparison\n\t* @param {unsigned16} b - unsigned 16-bit integer for comparison\n\t* @returns {number} comparison result\n\t*/\n\tfunction compare( a, b ) {\n\t\treturn compareFcn( fromWord( a ), fromWord( b ) );\n\t}\n});\n\n/**\n* Creates a new typed array view over the same underlying `ArrayBuffer` and with the same underlying data type as the host array.\n*\n* @name subarray\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} [begin] - start index (inclusive)\n* @param {integer} [end] - end index (exclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be an integer\n* @throws {TypeError} second argument must be an integer\n* @returns {Float16Array} subarray\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] );\n*\n* var subarr = arr.subarray();\n* // returns \n*\n* var len = subarr.length;\n* // returns 5\n*\n* var bool = subarr[ 0 ];\n* // returns 0.0\n*\n* bool = subarr[ len-1 ];\n* // returns 4.0\n*\n* subarr = arr.subarray( 1, -2 );\n* // returns \n*\n* len = subarr.length;\n* // returns 2\n*\n* bool = subarr[ 0 ];\n* // returns 1.0\n*\n* bool = subarr[ len-1 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'subarray', function subarray( begin, end ) {\n\tvar offset;\n\tvar buf;\n\tvar len;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length === 0 ) {\n\t\tbegin = 0;\n\t\tend = len;\n\t} else {\n\t\tif ( !isInteger( begin ) ) {\n\t\t\tthrow new TypeError( format( 'null7e', begin ) );\n\t\t}\n\t\tif ( begin < 0 ) {\n\t\t\tbegin += len;\n\t\t\tif ( begin < 0 ) {\n\t\t\t\tbegin = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\tend = len;\n\t\t} else {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'null7f', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t} else if ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t}\n\t}\n\tif ( begin >= len ) {\n\t\tlen = 0;\n\t\toffset = buf.byteLength;\n\t} else if ( begin >= end ) {\n\t\tlen = 0;\n\t\toffset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT );\n\t} else {\n\t\tlen = end - begin;\n\t\toffset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT );\n\t}\n\treturn new this.constructor( buf.buffer, offset, ( len < 0 ) ? 0 : len );\n});\n\n/**\n* Serializes an array as a locale-specific string.\n*\n* @name toLocaleString\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {(string|Array)} [locales] - locale identifier(s)\n* @param {Object} [options] - configuration options\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a string or an array of strings\n* @throws {TypeError} options argument must be an object\n* @returns {string} string representation\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var str = arr.toLocaleString();\n* // returns '0,1,2'\n*/\nsetReadOnly( Float16Array.prototype, 'toLocaleString', function toLocaleString( locales, options ) {\n\tvar opts;\n\tvar loc;\n\tvar out;\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( arguments.length === 0 ) {\n\t\tloc = [];\n\t} else if ( isString( locales ) || isStringArray( locales ) ) {\n\t\tloc = locales;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a string or an array of strings. Value: `%s`.', locales ) );\n\t}\n\tif ( arguments.length < 2 ) {\n\t\topts = {};\n\t} else if ( isObject( options ) ) {\n\t\topts = options;\n\t} else {\n\t\tthrow new TypeError( format( 'null2V', options ) );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( fromWord( buf[ i ] ) );\n\t}\n\treturn out.toLocaleString( loc, opts );\n});\n\n/**\n* Returns a new typed array containing the elements in reversed order.\n*\n* @name toReversed\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Float16Array} reversed array\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var out = arr.toReversed();\n* // returns \n*\n* var v = out[ 0 ];\n* // returns 2.0\n*\n* v = out[ 1 ];\n* // returns 1.0\n*\n* v = out[ 2 ];\n* // returns 0.0\n*/\nsetReadOnly( Float16Array.prototype, 'toReversed', function toReversed() {\n\tvar outbuf;\n\tvar out;\n\tvar len;\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tlen = this._length;\n\tout = new this.constructor( len );\n\tbuf = this._buffer;\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < len; i++ ) {\n\t\toutbuf[ i ] = buf[ len - i - 1 ];\n\t}\n\treturn out;\n});\n\n/**\n* Returns a new typed array containing the elements in sorted order.\n*\n* @name toSorted\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} [compareFcn] - comparison function\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {Float16Array} sorted array\n*\n* @example\n* function compare( a, b ) {\n* if ( a > b ) {\n* return 1;\n* }\n* if ( a < b ) {\n* return -1;\n* }\n* return 0;\n* }\n*\n* var arr = new Float16Array( [ 2.0, 0.0, 1.0 ] );\n*\n* var out = arr.toSorted( compare );\n* // returns \n*\n* var v = out[ 0 ];\n* // returns 0.0\n*\n* v = out[ 1 ];\n* // returns 1.0\n*\n* v = out[ 2 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'toSorted', function toSorted( compareFcn ) {\n\tvar out;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tout = new this.constructor( this );\n\tif ( arguments.length === 0 ) {\n\t\treturn out.sort();\n\t}\n\treturn out.sort( compareFcn );\n});\n\n/**\n* Serializes an array as a string.\n*\n* @name toString\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {string} string representation\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var str = arr.toString();\n* // returns '0,1,2'\n*/\nsetReadOnly( Float16Array.prototype, 'toString', function toString() {\n\tvar out;\n\tvar buf;\n\tvar i;\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( fromWord( buf[ i ] ) );\n\t}\n\treturn out.join( ',' );\n});\n\n/**\n* Returns an iterator for iterating over each value in a typed array.\n*\n* @name values\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0 ] );\n*\n* var iter = arr.values();\n*\n* var v = iter.next().value;\n* // returns 0.0\n*\n* v = iter.next().value;\n* // returns 1.0\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'values', function values() {\n\tvar iter;\n\tvar self;\n\tvar len;\n\tvar FLG;\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tself = this;\n\tbuf = this._buffer;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': fromWord( buf[ i ] ),\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.values();\n\t}\n});\n\n/**\n* Returns a new typed array with the element at a provided index replaced with a provided value.\n*\n* @name with\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} index - element index\n* @param {number} value - new value\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be an integer\n* @throws {RangeError} index argument is out-of-bounds\n* @throws {TypeError} second argument must be a floating-point number\n* @returns {Float16Array} new typed array\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var out = arr.with( 0, 3.0 );\n* // returns \n*\n* var v = out[ 0 ];\n* // returns 3.0\n*/\nsetReadOnly( Float16Array.prototype, 'with', function copyWith( index, value ) {\n\tvar out;\n\tvar len;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isInteger( index ) ) {\n\t\tthrow new TypeError( format( 'null7e', index ) );\n\t}\n\tlen = this._length;\n\tif ( index < 0 ) {\n\t\tindex += len;\n\t}\n\tif ( index < 0 || index >= len ) {\n\t\tthrow new RangeError( format( 'nullFP', index ) );\n\t}\n\tif ( !isNumber( value ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a floating-point number. Value: `%s`.', value ) );\n\t}\n\tout = new this.constructor( this );\n\tout[ index ] = value;\n\treturn out;\n});\n\n\n// EXPORTS //\n\nexport default Float16Array;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport f16 from '@stdlib/number-float64-base-to-float16';\nimport toWord from '@stdlib/number-float16-base-to-word';\n\n\n// MAIN //\n\n/**\n* Fills an output array with unsigned 16-bit integers corresponding to the IEEE 754 binary representation of respective half-precision floating-point numbers.\n*\n* @private\n* @param {Uint16Array} buf - output array\n* @param {Array} arr - input array\n* @returns {Uint16Array} output array\n*/\nfunction fromArray( buf, arr ) {\n\tvar len;\n\tvar i;\n\n\tlen = arr.length;\n\tfor ( i = 0; i < len; i++ ) {\n\t\tbuf[ i ] = toWord( f16( arr[ i ] ) );\n\t}\n\treturn buf;\n}\n\n\n// EXPORTS //\n\nexport default fromArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport f16 from '@stdlib/number-float64-base-to-float16';\nimport toWord from '@stdlib/number-float16-base-to-word';\n\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @param {Function} clbk - callback to invoke for each iterated value\n* @param {*} thisArg - invocation context\n* @returns {Array} output array\n*/\nfunction fromIteratorMap( it, clbk, thisArg ) {\n\tvar out;\n\tvar v;\n\tvar i;\n\n\tout = [];\n\ti = -1;\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\ti += 1;\n\t\tout.push( toWord( f16( clbk.call( thisArg, v.value, i ) ) ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIteratorMap;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Float16Array === 'function' ) ? Float16Array : void 0; // eslint-disable-line no-undef, stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* 16-bit floating-point number array constructor.\n*\n* @module @stdlib/array-float16\n*\n* @example\n* import Float16Array from '@stdlib/array-float16';\n*\n* var arr = new Float16Array();\n* // returns \n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* import Float16Array from '@stdlib/array-float16';\n*\n* var arr = new Float16Array( 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import Float16Array from '@stdlib/array-float16';\n*\n* var arr = new Float16Array( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n* import Float16Array from '@stdlib/array-float16';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float16Array( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 8\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n* import Float16Array from '@stdlib/array-float16';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float16Array( buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 4\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n* import Float16Array from '@stdlib/array-float16';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Float16Array( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\n\n// MODULES //\n\nimport hasFloat16ArraySupport from '@stdlib/assert-has-float16array-support';\nimport polyfill from './polyfill';\nimport builtin from './main.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasFloat16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n"],"names":["fromIterator","it","out","v","next","done","push","toWord","f16","value","BYTES_PER_ELEMENT","Uint16Array","HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","isFloat16Array","constructor","name","isFloatingPointArrayConstructor","Float16Array","getter","ctx","idx","_get","setter","set","byteOffset","nargs","buf","len","arg","i","arguments","length","this","isNonNegativeInteger","isCollection","gcopy","ndarray","buffer","arr","fromArray","isArrayBuffer","isInteger","byteLength","RangeError","format","isObject","TypeError","isFunction","ITERATOR_SYMBOL","setReadOnly","setReadWriteAccessor","src","thisArg","clbk","tmp","_buffer","call","fromIteratorMap","Error","args","prototype","_length","fromWord","setReadOnlyAccessor","target","start","copyWithin","self","iter","FLG","entries","predicate","end","isNumber","fcn","searchElement","fromIndex","separator","isString","join","keys","outbuf","reducer","initialValue","acc","N","j","floor","sbuf","flg","begin","outlen","compareFcn","sort","a","b","x","y","isnan","offset","locales","options","opts","loc","isStringArray","toLocaleString","values","index","ctor","ctor$1","hasFloat16ArraySupport","builtin","polyfill"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 41ab3bb..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From b343c9ac20498a3732c7cbbdac80dc4c99df5ee5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 31 May 2026 12:00:54 +0000 Subject: [PATCH 11/14] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 204 - .npmignore | 229 - .npmrc | 44 - CHANGELOG.md | 65 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 49 +- SECURITY.md | 5 - benchmark/benchmark.at.js | 79 - benchmark/benchmark.copy_within.js | 52 - benchmark/benchmark.copy_within.length.js | 95 - benchmark/benchmark.entries.js | 52 - benchmark/benchmark.every.js | 83 - benchmark/benchmark.every.length.js | 107 - benchmark/benchmark.fill.js | 53 - benchmark/benchmark.fill.length.js | 97 - benchmark/benchmark.filter.js | 82 - benchmark/benchmark.filter.length.js | 106 - benchmark/benchmark.find.js | 84 - benchmark/benchmark.find.length.js | 106 - benchmark/benchmark.find_index.js | 84 - benchmark/benchmark.find_index.length.js | 106 - benchmark/benchmark.find_last.js | 84 - benchmark/benchmark.find_last.length.js | 106 - benchmark/benchmark.find_last_index.js | 84 - benchmark/benchmark.find_last_index.length.js | 110 - benchmark/benchmark.for_each.js | 90 - benchmark/benchmark.for_each.length.js | 108 - benchmark/benchmark.from.js | 238 - benchmark/benchmark.get.js | 55 - benchmark/benchmark.includes.js | 54 - benchmark/benchmark.includes.length.js | 97 - benchmark/benchmark.index_of.js | 54 - benchmark/benchmark.index_of.length.js | 96 - benchmark/benchmark.join.js | 53 - benchmark/benchmark.join.length.js | 96 - benchmark/benchmark.js | 338 -- benchmark/benchmark.keys.js | 52 - benchmark/benchmark.keys.length.js | 96 - benchmark/benchmark.last_index_of.js | 53 - benchmark/benchmark.last_index_of.length.js | 95 - benchmark/benchmark.length.js | 93 - benchmark/benchmark.map.js | 82 - benchmark/benchmark.map.length.js | 106 - benchmark/benchmark.of.js | 48 - benchmark/benchmark.reduce.js | 82 - benchmark/benchmark.reduce.length.js | 107 - benchmark/benchmark.reduce_right.js | 82 - benchmark/benchmark.reduce_right.length.js | 107 - benchmark/benchmark.reverse.js | 53 - benchmark/benchmark.reverse.length.js | 96 - benchmark/benchmark.set.js | 95 - benchmark/benchmark.set.length.js | 110 - benchmark/benchmark.slice.js | 53 - benchmark/benchmark.slice.length.js | 96 - benchmark/benchmark.some.js | 83 - benchmark/benchmark.some.length.js | 107 - benchmark/benchmark.sort.js | 53 - benchmark/benchmark.sort.length.js | 96 - benchmark/benchmark.subarray.js | 52 - benchmark/benchmark.subarray.length.js | 95 - benchmark/benchmark.to_locale_string.js | 53 - .../benchmark.to_locale_string.length.js | 96 - benchmark/benchmark.to_reversed.js | 52 - benchmark/benchmark.to_reversed.length.js | 95 - benchmark/benchmark.to_sorted.js | 53 - benchmark/benchmark.to_sorted.length.js | 96 - benchmark/benchmark.to_string.js | 53 - benchmark/benchmark.to_string.length.js | 96 - benchmark/benchmark.values.js | 52 - benchmark/benchmark.values.length.js | 96 - benchmark/benchmark.with.js | 54 - benchmark/benchmark.with.length.js | 98 - benchmark/polyfill/benchmark.at.js | 79 - benchmark/polyfill/benchmark.copy_within.js | 52 - .../polyfill/benchmark.copy_within.length.js | 95 - benchmark/polyfill/benchmark.entries.js | 52 - benchmark/polyfill/benchmark.every.js | 83 - benchmark/polyfill/benchmark.every.length.js | 107 - benchmark/polyfill/benchmark.fill.js | 53 - benchmark/polyfill/benchmark.fill.length.js | 97 - benchmark/polyfill/benchmark.filter.js | 82 - benchmark/polyfill/benchmark.filter.length.js | 106 - benchmark/polyfill/benchmark.find.js | 84 - benchmark/polyfill/benchmark.find.length.js | 106 - benchmark/polyfill/benchmark.find_index.js | 84 - .../polyfill/benchmark.find_index.length.js | 106 - benchmark/polyfill/benchmark.find_last.js | 84 - .../polyfill/benchmark.find_last.length.js | 106 - .../polyfill/benchmark.find_last_index.js | 84 - .../benchmark.find_last_index.length.js | 110 - benchmark/polyfill/benchmark.for_each.js | 90 - .../polyfill/benchmark.for_each.length.js | 108 - benchmark/polyfill/benchmark.from.js | 238 - benchmark/polyfill/benchmark.get.js | 55 - benchmark/polyfill/benchmark.includes.js | 54 - .../polyfill/benchmark.includes.length.js | 97 - benchmark/polyfill/benchmark.index_of.js | 54 - .../polyfill/benchmark.index_of.length.js | 96 - benchmark/polyfill/benchmark.join.js | 53 - benchmark/polyfill/benchmark.join.length.js | 96 - benchmark/polyfill/benchmark.js | 338 -- benchmark/polyfill/benchmark.keys.js | 52 - benchmark/polyfill/benchmark.keys.length.js | 96 - benchmark/polyfill/benchmark.last_index_of.js | 53 - .../benchmark.last_index_of.length.js | 95 - benchmark/polyfill/benchmark.length.js | 93 - benchmark/polyfill/benchmark.map.js | 82 - benchmark/polyfill/benchmark.map.length.js | 106 - benchmark/polyfill/benchmark.of.js | 48 - benchmark/polyfill/benchmark.reduce.js | 82 - benchmark/polyfill/benchmark.reduce.length.js | 107 - benchmark/polyfill/benchmark.reduce_right.js | 82 - .../polyfill/benchmark.reduce_right.length.js | 107 - benchmark/polyfill/benchmark.reverse.js | 53 - .../polyfill/benchmark.reverse.length.js | 96 - benchmark/polyfill/benchmark.set.js | 95 - benchmark/polyfill/benchmark.set.length.js | 110 - benchmark/polyfill/benchmark.slice.js | 53 - benchmark/polyfill/benchmark.slice.length.js | 96 - benchmark/polyfill/benchmark.some.js | 83 - benchmark/polyfill/benchmark.some.length.js | 107 - benchmark/polyfill/benchmark.sort.js | 53 - benchmark/polyfill/benchmark.sort.length.js | 96 - benchmark/polyfill/benchmark.subarray.js | 52 - .../polyfill/benchmark.subarray.length.js | 95 - .../polyfill/benchmark.to_locale_string.js | 53 - .../benchmark.to_locale_string.length.js | 96 - benchmark/polyfill/benchmark.to_reversed.js | 52 - .../polyfill/benchmark.to_reversed.length.js | 95 - benchmark/polyfill/benchmark.to_sorted.js | 53 - .../polyfill/benchmark.to_sorted.length.js | 96 - benchmark/polyfill/benchmark.to_string.js | 53 - .../polyfill/benchmark.to_string.length.js | 96 - benchmark/polyfill/benchmark.values.js | 52 - benchmark/polyfill/benchmark.values.length.js | 96 - benchmark/polyfill/benchmark.with.js | 54 - benchmark/polyfill/benchmark.with.length.js | 98 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 1222 ----- docs/types/test.ts | 129 - examples/index.js | 42 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 106 - lib/main.js | 28 - lib/polyfill/from_array.js | 51 - lib/polyfill/from_iterator.js | 54 - lib/polyfill/from_iterator_map.js | 59 - lib/polyfill/index.js | 2410 -------- package.json | 86 +- stats.html | 4842 +++++++++++++++++ test/dist/test.js | 33 - test/polyfill/test.at.js | 144 - test/polyfill/test.copy_within.js | 281 - test/polyfill/test.entries.js | 238 - test/polyfill/test.every.js | 174 - test/polyfill/test.fill.js | 305 -- test/polyfill/test.filter.js | 226 - test/polyfill/test.find.js | 174 - test/polyfill/test.find_index.js | 173 - test/polyfill/test.find_last.js | 174 - test/polyfill/test.find_last_index.js | 173 - test/polyfill/test.for_each.js | 196 - test/polyfill/test.from.js | 654 --- test/polyfill/test.includes.js | 222 - test/polyfill/test.index_of.js | 222 - test/polyfill/test.join.js | 173 - test/polyfill/test.js | 740 --- test/polyfill/test.keys.js | 261 - test/polyfill/test.last_index_of.js | 211 - test/polyfill/test.map.js | 178 - test/polyfill/test.of.js | 130 - test/polyfill/test.reduce.js | 189 - test/polyfill/test.reduce_right.js | 192 - test/polyfill/test.reverse.js | 122 - test/polyfill/test.set.js | 259 - test/polyfill/test.slice.js | 311 -- test/polyfill/test.some.js | 196 - test/polyfill/test.sort.js | 189 - test/polyfill/test.subarray.js | 308 -- test/polyfill/test.to_locale_string.js | 187 - test/polyfill/test.to_reversed.js | 121 - test/polyfill/test.to_sorted.js | 172 - test/polyfill/test.to_string.js | 97 - test/polyfill/test.values.js | 264 - test/polyfill/test.with.js | 213 - test/test.at.js | 111 - test/test.copy_within.js | 279 - test/test.entries.js | 96 - test/test.every.js | 172 - test/test.fill.js | 212 - test/test.filter.js | 224 - test/test.find.js | 172 - test/test.find_index.js | 171 - test/test.find_last.js | 172 - test/test.find_last_index.js | 171 - test/test.for_each.js | 194 - test/test.from.js | 309 -- test/test.includes.js | 160 - test/test.index_of.js | 160 - test/test.join.js | 141 - test/test.js | 320 -- test/test.keys.js | 144 - test/test.last_index_of.js | 149 - test/test.map.js | 176 - test/test.of.js | 128 - test/test.polyfill.js | 80 - test/test.reduce.js | 187 - test/test.reduce_right.js | 190 - test/test.reverse.js | 120 - test/test.set.js | 225 - test/test.slice.js | 249 - test/test.some.js | 194 - test/test.sort.js | 186 - test/test.subarray.js | 246 - test/test.to_locale_string.js | 95 - test/test.to_reversed.js | 119 - test/test.to_sorted.js | 169 - test/test.to_string.js | 87 - test/test.values.js | 147 - test/test.with.js | 151 - 244 files changed, 4870 insertions(+), 33258 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.at.js delete mode 100644 benchmark/benchmark.copy_within.js delete mode 100644 benchmark/benchmark.copy_within.length.js delete mode 100644 benchmark/benchmark.entries.js delete mode 100644 benchmark/benchmark.every.js delete mode 100644 benchmark/benchmark.every.length.js delete mode 100644 benchmark/benchmark.fill.js delete mode 100644 benchmark/benchmark.fill.length.js delete mode 100644 benchmark/benchmark.filter.js delete mode 100644 benchmark/benchmark.filter.length.js delete mode 100644 benchmark/benchmark.find.js delete mode 100644 benchmark/benchmark.find.length.js delete mode 100644 benchmark/benchmark.find_index.js delete mode 100644 benchmark/benchmark.find_index.length.js delete mode 100644 benchmark/benchmark.find_last.js delete mode 100644 benchmark/benchmark.find_last.length.js delete mode 100644 benchmark/benchmark.find_last_index.js delete mode 100644 benchmark/benchmark.find_last_index.length.js delete mode 100644 benchmark/benchmark.for_each.js delete mode 100644 benchmark/benchmark.for_each.length.js delete mode 100644 benchmark/benchmark.from.js delete mode 100644 benchmark/benchmark.get.js delete mode 100644 benchmark/benchmark.includes.js delete mode 100644 benchmark/benchmark.includes.length.js delete mode 100644 benchmark/benchmark.index_of.js delete mode 100644 benchmark/benchmark.index_of.length.js delete mode 100644 benchmark/benchmark.join.js delete mode 100644 benchmark/benchmark.join.length.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.keys.js delete mode 100644 benchmark/benchmark.keys.length.js delete mode 100644 benchmark/benchmark.last_index_of.js delete mode 100644 benchmark/benchmark.last_index_of.length.js delete mode 100644 benchmark/benchmark.length.js delete mode 100644 benchmark/benchmark.map.js delete mode 100644 benchmark/benchmark.map.length.js delete mode 100644 benchmark/benchmark.of.js delete mode 100644 benchmark/benchmark.reduce.js delete mode 100644 benchmark/benchmark.reduce.length.js delete mode 100644 benchmark/benchmark.reduce_right.js delete mode 100644 benchmark/benchmark.reduce_right.length.js delete mode 100644 benchmark/benchmark.reverse.js delete mode 100644 benchmark/benchmark.reverse.length.js delete mode 100644 benchmark/benchmark.set.js delete mode 100644 benchmark/benchmark.set.length.js delete mode 100644 benchmark/benchmark.slice.js delete mode 100644 benchmark/benchmark.slice.length.js delete mode 100644 benchmark/benchmark.some.js delete mode 100644 benchmark/benchmark.some.length.js delete mode 100644 benchmark/benchmark.sort.js delete mode 100644 benchmark/benchmark.sort.length.js delete mode 100644 benchmark/benchmark.subarray.js delete mode 100644 benchmark/benchmark.subarray.length.js delete mode 100644 benchmark/benchmark.to_locale_string.js delete mode 100644 benchmark/benchmark.to_locale_string.length.js delete mode 100644 benchmark/benchmark.to_reversed.js delete mode 100644 benchmark/benchmark.to_reversed.length.js delete mode 100644 benchmark/benchmark.to_sorted.js delete mode 100644 benchmark/benchmark.to_sorted.length.js delete mode 100644 benchmark/benchmark.to_string.js delete mode 100644 benchmark/benchmark.to_string.length.js delete mode 100644 benchmark/benchmark.values.js delete mode 100644 benchmark/benchmark.values.length.js delete mode 100644 benchmark/benchmark.with.js delete mode 100644 benchmark/benchmark.with.length.js delete mode 100644 benchmark/polyfill/benchmark.at.js delete mode 100644 benchmark/polyfill/benchmark.copy_within.js delete mode 100644 benchmark/polyfill/benchmark.copy_within.length.js delete mode 100644 benchmark/polyfill/benchmark.entries.js delete mode 100644 benchmark/polyfill/benchmark.every.js delete mode 100644 benchmark/polyfill/benchmark.every.length.js delete mode 100644 benchmark/polyfill/benchmark.fill.js delete mode 100644 benchmark/polyfill/benchmark.fill.length.js delete mode 100644 benchmark/polyfill/benchmark.filter.js delete mode 100644 benchmark/polyfill/benchmark.filter.length.js delete mode 100644 benchmark/polyfill/benchmark.find.js delete mode 100644 benchmark/polyfill/benchmark.find.length.js delete mode 100644 benchmark/polyfill/benchmark.find_index.js delete mode 100644 benchmark/polyfill/benchmark.find_index.length.js delete mode 100644 benchmark/polyfill/benchmark.find_last.js delete mode 100644 benchmark/polyfill/benchmark.find_last.length.js delete mode 100644 benchmark/polyfill/benchmark.find_last_index.js delete mode 100644 benchmark/polyfill/benchmark.find_last_index.length.js delete mode 100644 benchmark/polyfill/benchmark.for_each.js delete mode 100644 benchmark/polyfill/benchmark.for_each.length.js delete mode 100644 benchmark/polyfill/benchmark.from.js delete mode 100644 benchmark/polyfill/benchmark.get.js delete mode 100644 benchmark/polyfill/benchmark.includes.js delete mode 100644 benchmark/polyfill/benchmark.includes.length.js delete mode 100644 benchmark/polyfill/benchmark.index_of.js delete mode 100644 benchmark/polyfill/benchmark.index_of.length.js delete mode 100644 benchmark/polyfill/benchmark.join.js delete mode 100644 benchmark/polyfill/benchmark.join.length.js delete mode 100644 benchmark/polyfill/benchmark.js delete mode 100644 benchmark/polyfill/benchmark.keys.js delete mode 100644 benchmark/polyfill/benchmark.keys.length.js delete mode 100644 benchmark/polyfill/benchmark.last_index_of.js delete mode 100644 benchmark/polyfill/benchmark.last_index_of.length.js delete mode 100644 benchmark/polyfill/benchmark.length.js delete mode 100644 benchmark/polyfill/benchmark.map.js delete mode 100644 benchmark/polyfill/benchmark.map.length.js delete mode 100644 benchmark/polyfill/benchmark.of.js delete mode 100644 benchmark/polyfill/benchmark.reduce.js delete mode 100644 benchmark/polyfill/benchmark.reduce.length.js delete mode 100644 benchmark/polyfill/benchmark.reduce_right.js delete mode 100644 benchmark/polyfill/benchmark.reduce_right.length.js delete mode 100644 benchmark/polyfill/benchmark.reverse.js delete mode 100644 benchmark/polyfill/benchmark.reverse.length.js delete mode 100644 benchmark/polyfill/benchmark.set.js delete mode 100644 benchmark/polyfill/benchmark.set.length.js delete mode 100644 benchmark/polyfill/benchmark.slice.js delete mode 100644 benchmark/polyfill/benchmark.slice.length.js delete mode 100644 benchmark/polyfill/benchmark.some.js delete mode 100644 benchmark/polyfill/benchmark.some.length.js delete mode 100644 benchmark/polyfill/benchmark.sort.js delete mode 100644 benchmark/polyfill/benchmark.sort.length.js delete mode 100644 benchmark/polyfill/benchmark.subarray.js delete mode 100644 benchmark/polyfill/benchmark.subarray.length.js delete mode 100644 benchmark/polyfill/benchmark.to_locale_string.js delete mode 100644 benchmark/polyfill/benchmark.to_locale_string.length.js delete mode 100644 benchmark/polyfill/benchmark.to_reversed.js delete mode 100644 benchmark/polyfill/benchmark.to_reversed.length.js delete mode 100644 benchmark/polyfill/benchmark.to_sorted.js delete mode 100644 benchmark/polyfill/benchmark.to_sorted.length.js delete mode 100644 benchmark/polyfill/benchmark.to_string.js delete mode 100644 benchmark/polyfill/benchmark.to_string.length.js delete mode 100644 benchmark/polyfill/benchmark.values.js delete mode 100644 benchmark/polyfill/benchmark.values.length.js delete mode 100644 benchmark/polyfill/benchmark.with.js delete mode 100644 benchmark/polyfill/benchmark.with.length.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill/from_array.js delete mode 100644 lib/polyfill/from_iterator.js delete mode 100644 lib/polyfill/from_iterator_map.js delete mode 100644 lib/polyfill/index.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/polyfill/test.at.js delete mode 100644 test/polyfill/test.copy_within.js delete mode 100644 test/polyfill/test.entries.js delete mode 100644 test/polyfill/test.every.js delete mode 100644 test/polyfill/test.fill.js delete mode 100644 test/polyfill/test.filter.js delete mode 100644 test/polyfill/test.find.js delete mode 100644 test/polyfill/test.find_index.js delete mode 100644 test/polyfill/test.find_last.js delete mode 100644 test/polyfill/test.find_last_index.js delete mode 100644 test/polyfill/test.for_each.js delete mode 100644 test/polyfill/test.from.js delete mode 100644 test/polyfill/test.includes.js delete mode 100644 test/polyfill/test.index_of.js delete mode 100644 test/polyfill/test.join.js delete mode 100644 test/polyfill/test.js delete mode 100644 test/polyfill/test.keys.js delete mode 100644 test/polyfill/test.last_index_of.js delete mode 100644 test/polyfill/test.map.js delete mode 100644 test/polyfill/test.of.js delete mode 100644 test/polyfill/test.reduce.js delete mode 100644 test/polyfill/test.reduce_right.js delete mode 100644 test/polyfill/test.reverse.js delete mode 100644 test/polyfill/test.set.js delete mode 100644 test/polyfill/test.slice.js delete mode 100644 test/polyfill/test.some.js delete mode 100644 test/polyfill/test.sort.js delete mode 100644 test/polyfill/test.subarray.js delete mode 100644 test/polyfill/test.to_locale_string.js delete mode 100644 test/polyfill/test.to_reversed.js delete mode 100644 test/polyfill/test.to_sorted.js delete mode 100644 test/polyfill/test.to_string.js delete mode 100644 test/polyfill/test.values.js delete mode 100644 test/polyfill/test.with.js delete mode 100644 test/test.at.js delete mode 100644 test/test.copy_within.js delete mode 100644 test/test.entries.js delete mode 100644 test/test.every.js delete mode 100644 test/test.fill.js delete mode 100644 test/test.filter.js delete mode 100644 test/test.find.js delete mode 100644 test/test.find_index.js delete mode 100644 test/test.find_last.js delete mode 100644 test/test.find_last_index.js delete mode 100644 test/test.for_each.js delete mode 100644 test/test.from.js delete mode 100644 test/test.includes.js delete mode 100644 test/test.index_of.js delete mode 100644 test/test.join.js delete mode 100644 test/test.js delete mode 100644 test/test.keys.js delete mode 100644 test/test.last_index_of.js delete mode 100644 test/test.map.js delete mode 100644 test/test.of.js delete mode 100644 test/test.polyfill.js delete mode 100644 test/test.reduce.js delete mode 100644 test/test.reduce_right.js delete mode 100644 test/test.reverse.js delete mode 100644 test/test.set.js delete mode 100644 test/test.slice.js delete mode 100644 test/test.some.js delete mode 100644 test/test.sort.js delete mode 100644 test/test.subarray.js delete mode 100644 test/test.to_locale_string.js delete mode 100644 test/test.to_reversed.js delete mode 100644 test/test.to_sorted.js delete mode 100644 test/test.to_string.js delete mode 100644 test/test.values.js delete mode 100644 test/test.with.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index f756a5e..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/float16) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 44e2d76..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/float16) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 4584730..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '9 21 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -1587,7 +1578,7 @@ logEach( '%s', out ); ## Notice -This package is part of [stdlib][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. +This package is part of [stdlib][stdlib], a standard library 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][stdlib], see the main project [repository][stdlib]. @@ -1652,9 +1643,9 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. [mdn-iterator-protocol]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterator_protocol -[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed +[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed/tree/esm -[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer +[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.at.js b/benchmark/benchmark.at.js deleted file mode 100644 index 7068020..0000000 --- a/benchmark/benchmark.at.js +++ /dev/null @@ -1,79 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s::nonnegative_indices:at', pkg ), function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float16Array( uniform( 10, 0.0, 10.0 ) ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.at( i%N ); - if ( typeof v !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNumber( v ) ) { - b.fail( 'should return a number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::negative_indices:at', pkg ), function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float16Array( uniform( 10, 1.0, 10.0 ) ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.at( -(i%N)-1 ); - if ( typeof v !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNumber( v ) ) { - b.fail( 'should return a number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.copy_within.js b/benchmark/benchmark.copy_within.js deleted file mode 100644 index 2182e0d..0000000 --- a/benchmark/benchmark.copy_within.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:copyWithin', pkg ), function benchmark( b ) { - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.copy_within.length.js b/benchmark/benchmark.copy_within.length.js deleted file mode 100644 index 9c952bb..0000000 --- a/benchmark/benchmark.copy_within.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - 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( format( '%s:copyWithin:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.entries.js b/benchmark/benchmark.entries.js deleted file mode 100644 index ddef73f..0000000 --- a/benchmark/benchmark.entries.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:entries', pkg ), function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.every.js b/benchmark/benchmark.every.js deleted file mode 100644 index ec830e9..0000000 --- a/benchmark/benchmark.every.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:every', pkg ), function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0.0; - } -}); - -bench( format( '%s::this_context:every', pkg ), function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0.0; - } -}); diff --git a/benchmark/benchmark.every.length.js b/benchmark/benchmark.every.length.js deleted file mode 100644 index a0f3d94..0000000 --- a/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,107 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - 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( format( '%s:every:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.fill.js b/benchmark/benchmark.fill.js deleted file mode 100644 index 7b27d39..0000000 --- a/benchmark/benchmark.fill.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:fill', pkg ), function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = [ 1.0, 2.0, 3.0 ]; - arr = new Float16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.fill( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.fill.length.js b/benchmark/benchmark.fill.length.js deleted file mode 100644 index 612d1b9..0000000 --- a/benchmark/benchmark.fill.length.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var values; - var out; - var i; - - values = [ 1.0, 2.0, 3.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.fill( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s:fill:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.filter.js b/benchmark/benchmark.filter.js deleted file mode 100644 index 555ad11..0000000 --- a/benchmark/benchmark.filter.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:filter', pkg ), function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0.0; - } -}); - -bench( format( '%s::this_context:filter', pkg ), function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0.0; - } -}); diff --git a/benchmark/benchmark.filter.length.js b/benchmark/benchmark.filter.length.js deleted file mode 100644 index 89f5124..0000000 --- a/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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 = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:filter:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.find.js b/benchmark/benchmark.find.js deleted file mode 100644 index b15c9fa..0000000 --- a/benchmark/benchmark.find.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:find', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); - -bench( format( '%s::this_context:find', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); diff --git a/benchmark/benchmark.find.length.js b/benchmark/benchmark.find.length.js deleted file mode 100644 index 58997d9..0000000 --- a/benchmark/benchmark.find.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value < 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - 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( format( '%s:find:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.find_index.js b/benchmark/benchmark.find_index.js deleted file mode 100644 index 4491bb3..0000000 --- a/benchmark/benchmark.find_index.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:findIndex', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); - -bench( format( '%s::this_context:findIndex', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); diff --git a/benchmark/benchmark.find_index.length.js b/benchmark/benchmark.find_index.length.js deleted file mode 100644 index 4bed308..0000000 --- a/benchmark/benchmark.find_index.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value < 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - 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( format( '%s:findIndex:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.find_last.js b/benchmark/benchmark.find_last.js deleted file mode 100644 index e134fbb..0000000 --- a/benchmark/benchmark.find_last.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:findLast', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findLast( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); - -bench( format( '%s::this_context:findLast', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findLast( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); diff --git a/benchmark/benchmark.find_last.length.js b/benchmark/benchmark.find_last.length.js deleted file mode 100644 index 50aad42..0000000 --- a/benchmark/benchmark.find_last.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value < 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.findLast( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - 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( format( '%s:findLast:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.find_last_index.js b/benchmark/benchmark.find_last_index.js deleted file mode 100644 index 85217bd..0000000 --- a/benchmark/benchmark.find_last_index.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:findLastIndex', pkg ), function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findLastIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -bench( format( '%s::this_context:findLastIndex', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findLastIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); diff --git a/benchmark/benchmark.find_last_index.length.js b/benchmark/benchmark.find_last_index.length.js deleted file mode 100644 index 69468cd..0000000 --- a/benchmark/benchmark.find_last_index.length.js +++ /dev/null @@ -1,110 +0,0 @@ -/** - * @license Apache-2.0 -* -* Copyright (c) 2026 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. -*/ - -/* eslint-disable stdlib/jsdoc-typedef-typos */ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {boolean} value - array element -* @param {NonNegativeInteger} idx - array element index -* @param {Float16Array} arr - array instance -* @returns {boolean} boolean indicating whether a value passes a test -*/ -function predicate( value ) { - return value < 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.findLastIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - 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( format( '%s:findLastIndex:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.for_each.js b/benchmark/benchmark.for_each.js deleted file mode 100644 index af73bce..0000000 --- a/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:forEach', pkg ), function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( format( '%s::this_context:forEach', pkg ), function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/benchmark/benchmark.for_each.length.js b/benchmark/benchmark.for_each.length.js deleted file mode 100644 index 935da80..0000000 --- a/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// 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( format( '%s:forEach:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.from.js b/benchmark/benchmark.from.js deleted file mode 100644 index 2242134..0000000 --- a/benchmark/benchmark.from.js +++ /dev/null @@ -1,238 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( format( '%s::typed_array:from', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::typed_array,clbk:from', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1.0; - } -}); - -bench( format( '%s::array:from', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1.0, 2.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::array,clbk:from', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1.0, 2.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1.0; - } -}); - -bench( format( '%s::iterable:from', pkg ), opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0.0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( format( '%s::iterable,clbk:from:', pkg ), opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1.0, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1.0; - } -}); diff --git a/benchmark/benchmark.get.js b/benchmark/benchmark.get.js deleted file mode 100644 index 90788e1..0000000 --- a/benchmark/benchmark.get.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:get', pkg ), function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float16Array( uniform( 10, 0.0, 10.0 ) ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( typeof v !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNumber( v ) ) { - b.fail( 'should return a number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.includes.js b/benchmark/benchmark.includes.js deleted file mode 100644 index c24dcc3..0000000 --- a/benchmark/benchmark.includes.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:includes', pkg ), function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Float16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1.0; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.includes.length.js b/benchmark/benchmark.includes.length.js deleted file mode 100644 index db686a1..0000000 --- a/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1.0; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - 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( format( '%s:includes:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.index_of.js b/benchmark/benchmark.index_of.js deleted file mode 100644 index 222370c..0000000 --- a/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:indexOf', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.indexOf( 11.0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( out ) ) { - b.fail( 'should return an integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.index_of.length.js b/benchmark/benchmark.index_of.length.js deleted file mode 100644 index ca2c5ee..0000000 --- a/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.indexOf( 11.0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( out ) ) { - b.fail( 'should return an integer' ); - } - 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( format( '%s:indexOf:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.join.js b/benchmark/benchmark.join.js deleted file mode 100644 index ce25730..0000000 --- a/benchmark/benchmark.join.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:join', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.join.length.js b/benchmark/benchmark.join.length.js deleted file mode 100644 index 26092d0..0000000 --- a/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - 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( format( '%s:join:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 1d756ec..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,338 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( format( '%s::instantiation,new', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array(); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::instantiation,no_new', pkg ), function benchmark( b ) { - var ctor; - var arr; - var i; - - ctor = Float16Array; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = ctor(); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::instantiation,length', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::instantiation,typed_array', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::instantiation,array', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = []; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::instantiation,iterable', pkg ), opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( createIterable() ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - return { - 'done': true - }; - } - } -}); - -bench( format( '%s::instantiation,arraybuffer', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::instantiation,arraybuffer,byte_offset', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 8 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( buf, 8 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::instantiation,arraybuffer,byte_offset,length', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 8 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( buf, 8, 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::get:buffer', pkg ), function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float16Array(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::get:byteLength', pkg ), function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float16Array(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::get:byteOffset', pkg ), function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float16Array(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::get:length', pkg ), function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float16Array(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.keys.js b/benchmark/benchmark.keys.js deleted file mode 100644 index 9bd4d5f..0000000 --- a/benchmark/benchmark.keys.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:keys', pkg ), function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.keys.length.js b/benchmark/benchmark.keys.length.js deleted file mode 100644 index a9b25c9..0000000 --- a/benchmark/benchmark.keys.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var iter; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isIteratorLike( iter ) ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - 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( format( '%s:keys:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.last_index_of.js b/benchmark/benchmark.last_index_of.js deleted file mode 100644 index 96d9d71..0000000 --- a/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:lastIndexOf', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.lastIndexOf( 11.0 ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.length.js b/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index 230c543..0000000 --- a/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.lastIndexOf( 11.0 ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - 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( format( '%s:lastIndexOf:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index c67eb26..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.map.js b/benchmark/benchmark.map.js deleted file mode 100644 index 7968e8c..0000000 --- a/benchmark/benchmark.map.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:map', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1.0; - } -}); - -bench( format( '%s::this_context:map', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1.0; - } -}); diff --git a/benchmark/benchmark.map.length.js b/benchmark/benchmark.map.length.js deleted file mode 100644 index 3948193..0000000 --- a/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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 = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:map:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.of.js b/benchmark/benchmark.of.js deleted file mode 100644 index 3b8ae26..0000000 --- a/benchmark/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:of', pkg ), function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.of( i, 2.0 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reduce.js b/benchmark/benchmark.reduce.js deleted file mode 100644 index 39ce31c..0000000 --- a/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:reduce', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1.0; - } -}); - -bench( format( '%s::initial_value:reduce', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3.14 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1.0; - } -}); diff --git a/benchmark/benchmark.reduce.length.js b/benchmark/benchmark.reduce.length.js deleted file mode 100644 index 763b4c2..0000000 --- a/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,107 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - 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( format( '%s:reduce:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.reduce_right.js b/benchmark/benchmark.reduce_right.js deleted file mode 100644 index 8a71b79..0000000 --- a/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:reduceRight', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1.0; - } -}); - -bench( format( '%s::initial_value:reduceRight', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3.14 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1.0; - } -}); diff --git a/benchmark/benchmark.reduce_right.length.js b/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index 2001fe5..0000000 --- a/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,107 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - 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( format( '%s:reduceRight:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.reverse.js b/benchmark/benchmark.reverse.js deleted file mode 100644 index a2a239c..0000000 --- a/benchmark/benchmark.reverse.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:reverse', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reverse.length.js b/benchmark/benchmark.reverse.length.js deleted file mode 100644 index 3b526c7..0000000 --- a/benchmark/benchmark.reverse.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s:reverse:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.set.js b/benchmark/benchmark.set.js deleted file mode 100644 index 7648c39..0000000 --- a/benchmark/benchmark.set.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s::array:set', pkg ), function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Float16Array( 2 ); - buf = [ 0.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::typed_array:set', pkg ), function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Float16Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Float16Array( 2 ); - buf = new Float16Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.set.length.js b/benchmark/benchmark.set.length.js deleted file mode 100644 index f174a4a..0000000 --- a/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - - arr1 = uniform( len, 0.0, 10.0 ); - arr2 = uniform( len, 0.0, 10.0 ); - arr = new Float16Array( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - 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( format( '%s:set:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.slice.js b/benchmark/benchmark.slice.js deleted file mode 100644 index 9f5005a..0000000 --- a/benchmark/benchmark.slice.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:slice', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.slice.length.js b/benchmark/benchmark.slice.length.js deleted file mode 100644 index 2374b1b..0000000 --- a/benchmark/benchmark.slice.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s:slice:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.some.js b/benchmark/benchmark.some.js deleted file mode 100644 index 0c81afa..0000000 --- a/benchmark/benchmark.some.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:some', pkg ), function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); - -bench( format( '%s::this_context:some', pkg ), function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); diff --git a/benchmark/benchmark.some.length.js b/benchmark/benchmark.some.length.js deleted file mode 100644 index dd32df4..0000000 --- a/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,107 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value < 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - 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( format( '%s:some:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.sort.js b/benchmark/benchmark.sort.js deleted file mode 100644 index d9e6c30..0000000 --- a/benchmark/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:sort', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.sort.length.js b/benchmark/benchmark.sort.length.js deleted file mode 100644 index 508049c..0000000 --- a/benchmark/benchmark.sort.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ i%len ] = i; - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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 = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:sort:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.subarray.js b/benchmark/benchmark.subarray.js deleted file mode 100644 index 9d6a26b..0000000 --- a/benchmark/benchmark.subarray.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:subarray', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.subarray.length.js b/benchmark/benchmark.subarray.length.js deleted file mode 100644 index c40760b..0000000 --- a/benchmark/benchmark.subarray.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s:subarray:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_locale_string.js b/benchmark/benchmark.to_locale_string.js deleted file mode 100644 index 682ca77..0000000 --- a/benchmark/benchmark.to_locale_string.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:toLocaleString', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_locale_string.length.js b/benchmark/benchmark.to_locale_string.length.js deleted file mode 100644 index 20f510e..0000000 --- a/benchmark/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - 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 = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:toLocaleString:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_reversed.js b/benchmark/benchmark.to_reversed.js deleted file mode 100644 index 1b78c11..0000000 --- a/benchmark/benchmark.to_reversed.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:toReversed', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - 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 ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_reversed.length.js b/benchmark/benchmark.to_reversed.length.js deleted file mode 100644 index 66bf5dc..0000000 --- a/benchmark/benchmark.to_reversed.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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 ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s:toReversed:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_sorted.js b/benchmark/benchmark.to_sorted.js deleted file mode 100644 index d2021b5..0000000 --- a/benchmark/benchmark.to_sorted.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:toSorted', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toSorted(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_sorted.length.js b/benchmark/benchmark.to_sorted.length.js deleted file mode 100644 index b74ea43..0000000 --- a/benchmark/benchmark.to_sorted.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ i%len ] = i; - out = arr.toSorted(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a isFloat16Array' ); - } - 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( format( '%s:toSorted:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_string.js b/benchmark/benchmark.to_string.js deleted file mode 100644 index 6a31520..0000000 --- a/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:toString', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_string.length.js b/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 375cc12..0000000 --- a/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - 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 = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:toString:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.values.js b/benchmark/benchmark.values.js deleted file mode 100644 index 4352d26..0000000 --- a/benchmark/benchmark.values.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:values', pkg ), function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.values.length.js b/benchmark/benchmark.values.length.js deleted file mode 100644 index e0ac1ed..0000000 --- a/benchmark/benchmark.values.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var iter; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isIteratorLike( iter ) ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - 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( format( '%s:values:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.with.js b/benchmark/benchmark.with.js deleted file mode 100644 index 0ca8231..0000000 --- a/benchmark/benchmark.with.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:with', pkg ), function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = uniform( 2, 0.0, 1.0 ); - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.with( i%arr.length, values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.with.length.js b/benchmark/benchmark.with.length.js deleted file mode 100644 index efdf808..0000000 --- a/benchmark/benchmark.with.length.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var values; - var out; - var i; - - values = uniform( 2, 0.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.with( i%len, values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s:with:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.at.js b/benchmark/polyfill/benchmark.at.js deleted file mode 100644 index f0b2b78..0000000 --- a/benchmark/polyfill/benchmark.at.js +++ /dev/null @@ -1,79 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill::nonnegative_indices:at', pkg ), function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float16Array( uniform( 10, 0.0, 10.0 ) ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.at( i%N ); - if ( typeof v !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNumber( v ) ) { - b.fail( 'should return a number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::negative_indices:at', pkg ), function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float16Array( uniform( 10, 1.0, 10.0 ) ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.at( -(i%N)-1 ); - if ( typeof v !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNumber( v ) ) { - b.fail( 'should return a number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.copy_within.js b/benchmark/polyfill/benchmark.copy_within.js deleted file mode 100644 index 867e40a..0000000 --- a/benchmark/polyfill/benchmark.copy_within.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:copyWithin', pkg ), function benchmark( b ) { - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.copy_within.length.js b/benchmark/polyfill/benchmark.copy_within.length.js deleted file mode 100644 index 86bd362..0000000 --- a/benchmark/polyfill/benchmark.copy_within.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - 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( format( '%s::polyfill:copyWithin:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.entries.js b/benchmark/polyfill/benchmark.entries.js deleted file mode 100644 index 013036c..0000000 --- a/benchmark/polyfill/benchmark.entries.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:entries', pkg ), function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.every.js b/benchmark/polyfill/benchmark.every.js deleted file mode 100644 index 2b505c5..0000000 --- a/benchmark/polyfill/benchmark.every.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:every', pkg ), function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0.0; - } -}); - -bench( format( '%s::polyfill::this_context:every', pkg ), function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0.0; - } -}); diff --git a/benchmark/polyfill/benchmark.every.length.js b/benchmark/polyfill/benchmark.every.length.js deleted file mode 100644 index df08cff..0000000 --- a/benchmark/polyfill/benchmark.every.length.js +++ /dev/null @@ -1,107 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - 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( format( '%s::polyfill:every:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.fill.js b/benchmark/polyfill/benchmark.fill.js deleted file mode 100644 index 0c6e740..0000000 --- a/benchmark/polyfill/benchmark.fill.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:fill', pkg ), function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = [ 1.0, 2.0, 3.0 ]; - arr = new Float16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.fill( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.fill.length.js b/benchmark/polyfill/benchmark.fill.length.js deleted file mode 100644 index 6e72c6a..0000000 --- a/benchmark/polyfill/benchmark.fill.length.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var values; - var out; - var i; - - values = [ 1.0, 2.0, 3.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.fill( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s::polyfill:fill:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.filter.js b/benchmark/polyfill/benchmark.filter.js deleted file mode 100644 index 328c3d1..0000000 --- a/benchmark/polyfill/benchmark.filter.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:filter', pkg ), function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0.0; - } -}); - -bench( format( '%s::polyfill::this_context:filter', pkg ), function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0.0; - } -}); diff --git a/benchmark/polyfill/benchmark.filter.length.js b/benchmark/polyfill/benchmark.filter.length.js deleted file mode 100644 index 8673396..0000000 --- a/benchmark/polyfill/benchmark.filter.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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 = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s::polyfill:filter:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.find.js b/benchmark/polyfill/benchmark.find.js deleted file mode 100644 index aef5da9..0000000 --- a/benchmark/polyfill/benchmark.find.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:find', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); - -bench( format( '%s::polyfill::this_context:find', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); diff --git a/benchmark/polyfill/benchmark.find.length.js b/benchmark/polyfill/benchmark.find.length.js deleted file mode 100644 index 0059567..0000000 --- a/benchmark/polyfill/benchmark.find.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value < 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - 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( format( '%s::polyfill:find:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.find_index.js b/benchmark/polyfill/benchmark.find_index.js deleted file mode 100644 index 183c1e4..0000000 --- a/benchmark/polyfill/benchmark.find_index.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:findIndex', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); - -bench( format( '%s::polyfill::this_context:findIndex', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); diff --git a/benchmark/polyfill/benchmark.find_index.length.js b/benchmark/polyfill/benchmark.find_index.length.js deleted file mode 100644 index c9d2887..0000000 --- a/benchmark/polyfill/benchmark.find_index.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value < 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - 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( format( '%s::polyfill:findIndex:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.find_last.js b/benchmark/polyfill/benchmark.find_last.js deleted file mode 100644 index 1d79bb8..0000000 --- a/benchmark/polyfill/benchmark.find_last.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:findLast', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findLast( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); - -bench( format( '%s::polyfill::this_context:findLast', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findLast( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); diff --git a/benchmark/polyfill/benchmark.find_last.length.js b/benchmark/polyfill/benchmark.find_last.length.js deleted file mode 100644 index 5abddac..0000000 --- a/benchmark/polyfill/benchmark.find_last.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value < 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.findLast( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - 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( format( '%s::polyfill:findLast:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.find_last_index.js b/benchmark/polyfill/benchmark.find_last_index.js deleted file mode 100644 index 9fc8543..0000000 --- a/benchmark/polyfill/benchmark.find_last_index.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:findLastIndex', pkg ), function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findLastIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -bench( format( '%s::polyfill::this_context:findLastIndex', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findLastIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); diff --git a/benchmark/polyfill/benchmark.find_last_index.length.js b/benchmark/polyfill/benchmark.find_last_index.length.js deleted file mode 100644 index cd49c40..0000000 --- a/benchmark/polyfill/benchmark.find_last_index.length.js +++ /dev/null @@ -1,110 +0,0 @@ -/** - * @license Apache-2.0 -* -* Copyright (c) 2026 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. -*/ - -/* eslint-disable stdlib/jsdoc-typedef-typos */ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {boolean} value - array element -* @param {NonNegativeInteger} idx - array element index -* @param {Float16Array} arr - array instance -* @returns {boolean} boolean indicating whether a value passes a test -*/ -function predicate( value ) { - return value < 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.findLastIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - 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( format( '%s::polyfill:findLastIndex:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.for_each.js b/benchmark/polyfill/benchmark.for_each.js deleted file mode 100644 index d16383b..0000000 --- a/benchmark/polyfill/benchmark.for_each.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:forEach', pkg ), function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( format( '%s::polyfill::this_context:forEach', pkg ), function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/benchmark/polyfill/benchmark.for_each.length.js b/benchmark/polyfill/benchmark.for_each.length.js deleted file mode 100644 index 5b4f977..0000000 --- a/benchmark/polyfill/benchmark.for_each.length.js +++ /dev/null @@ -1,108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// 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( format( '%s::polyfill:forEach:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.from.js b/benchmark/polyfill/benchmark.from.js deleted file mode 100644 index 8af766a..0000000 --- a/benchmark/polyfill/benchmark.from.js +++ /dev/null @@ -1,238 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( format( '%s::polyfill::typed_array:from', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::typed_array,clbk:from', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1.0; - } -}); - -bench( format( '%s::polyfill::array:from', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1.0, 2.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::array,clbk:from', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1.0, 2.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1.0; - } -}); - -bench( format( '%s::polyfill::iterable:from', pkg ), opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0.0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( format( '%s::polyfill::iterable,clbk:from:', pkg ), opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1.0, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1.0; - } -}); diff --git a/benchmark/polyfill/benchmark.get.js b/benchmark/polyfill/benchmark.get.js deleted file mode 100644 index 2bc111b..0000000 --- a/benchmark/polyfill/benchmark.get.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:get', pkg ), function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float16Array( uniform( 10, 0.0, 10.0 ) ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( typeof v !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNumber( v ) ) { - b.fail( 'should return a number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.includes.js b/benchmark/polyfill/benchmark.includes.js deleted file mode 100644 index 30fc8c4..0000000 --- a/benchmark/polyfill/benchmark.includes.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:includes', pkg ), function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Float16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1.0; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.includes.length.js b/benchmark/polyfill/benchmark.includes.length.js deleted file mode 100644 index 8ac1374..0000000 --- a/benchmark/polyfill/benchmark.includes.length.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1.0; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - 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( format( '%s::polyfill:includes:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.index_of.js b/benchmark/polyfill/benchmark.index_of.js deleted file mode 100644 index c11797c..0000000 --- a/benchmark/polyfill/benchmark.index_of.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:indexOf', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.indexOf( 11.0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( out ) ) { - b.fail( 'should return an integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.index_of.length.js b/benchmark/polyfill/benchmark.index_of.length.js deleted file mode 100644 index 96dfe78..0000000 --- a/benchmark/polyfill/benchmark.index_of.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.indexOf( 11.0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( out ) ) { - b.fail( 'should return an integer' ); - } - 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( format( '%s::polyfill:indexOf:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.join.js b/benchmark/polyfill/benchmark.join.js deleted file mode 100644 index d3d5a47..0000000 --- a/benchmark/polyfill/benchmark.join.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:join', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.join.length.js b/benchmark/polyfill/benchmark.join.length.js deleted file mode 100644 index ca50459..0000000 --- a/benchmark/polyfill/benchmark.join.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - 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( format( '%s::polyfill:join:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.js b/benchmark/polyfill/benchmark.js deleted file mode 100644 index 7c38bae..0000000 --- a/benchmark/polyfill/benchmark.js +++ /dev/null @@ -1,338 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( format( '%s::polyfill::instantiation,new', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array(); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::instantiation,no_new', pkg ), function benchmark( b ) { - var ctor; - var arr; - var i; - - ctor = Float16Array; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = ctor(); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::instantiation,length', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::instantiation,typed_array', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::instantiation,array', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = []; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::instantiation,iterable', pkg ), opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( createIterable() ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - return { - 'done': true - }; - } - } -}); - -bench( format( '%s::polyfill::instantiation,arraybuffer', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::instantiation,arraybuffer,byte_offset', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 8 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( buf, 8 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::instantiation,arraybuffer,byte_offset,length', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 8 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( buf, 8, 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::get:buffer', pkg ), function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float16Array(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::get:byteLength', pkg ), function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float16Array(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::get:byteOffset', pkg ), function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float16Array(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::get:length', pkg ), function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float16Array(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.keys.js b/benchmark/polyfill/benchmark.keys.js deleted file mode 100644 index b51d241..0000000 --- a/benchmark/polyfill/benchmark.keys.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:keys', pkg ), function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.keys.length.js b/benchmark/polyfill/benchmark.keys.length.js deleted file mode 100644 index c6ac13c..0000000 --- a/benchmark/polyfill/benchmark.keys.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var iter; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isIteratorLike( iter ) ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - 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( format( '%s::polyfill:keys:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.last_index_of.js b/benchmark/polyfill/benchmark.last_index_of.js deleted file mode 100644 index 950c98b..0000000 --- a/benchmark/polyfill/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:lastIndexOf', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.lastIndexOf( 11.0 ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.last_index_of.length.js b/benchmark/polyfill/benchmark.last_index_of.length.js deleted file mode 100644 index bf069bb..0000000 --- a/benchmark/polyfill/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.lastIndexOf( 11.0 ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - 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( format( '%s::polyfill:lastIndexOf:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.length.js b/benchmark/polyfill/benchmark.length.js deleted file mode 100644 index 488b91b..0000000 --- a/benchmark/polyfill/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s::polyfill:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.map.js b/benchmark/polyfill/benchmark.map.js deleted file mode 100644 index 810ce41..0000000 --- a/benchmark/polyfill/benchmark.map.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:map', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1.0; - } -}); - -bench( format( '%s::polyfill::this_context:map', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1.0; - } -}); diff --git a/benchmark/polyfill/benchmark.map.length.js b/benchmark/polyfill/benchmark.map.length.js deleted file mode 100644 index 6156472..0000000 --- a/benchmark/polyfill/benchmark.map.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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 = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s::polyfill:map:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.of.js b/benchmark/polyfill/benchmark.of.js deleted file mode 100644 index 165e244..0000000 --- a/benchmark/polyfill/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:of', pkg ), function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.of( i, 2.0 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.reduce.js b/benchmark/polyfill/benchmark.reduce.js deleted file mode 100644 index b8215bd..0000000 --- a/benchmark/polyfill/benchmark.reduce.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:reduce', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1.0; - } -}); - -bench( format( '%s::polyfill::initial_value:reduce', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3.14 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1.0; - } -}); diff --git a/benchmark/polyfill/benchmark.reduce.length.js b/benchmark/polyfill/benchmark.reduce.length.js deleted file mode 100644 index 6d74ccc..0000000 --- a/benchmark/polyfill/benchmark.reduce.length.js +++ /dev/null @@ -1,107 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - 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( format( '%s::polyfill:reduce:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.reduce_right.js b/benchmark/polyfill/benchmark.reduce_right.js deleted file mode 100644 index f2686f6..0000000 --- a/benchmark/polyfill/benchmark.reduce_right.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:reduceRight', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1.0; - } -}); - -bench( format( '%s::polyfill::initial_value:reduceRight', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3.14 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1.0; - } -}); diff --git a/benchmark/polyfill/benchmark.reduce_right.length.js b/benchmark/polyfill/benchmark.reduce_right.length.js deleted file mode 100644 index 62948e3..0000000 --- a/benchmark/polyfill/benchmark.reduce_right.length.js +++ /dev/null @@ -1,107 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - 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( format( '%s::polyfill:reduceRight:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.reverse.js b/benchmark/polyfill/benchmark.reverse.js deleted file mode 100644 index 386b361..0000000 --- a/benchmark/polyfill/benchmark.reverse.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:reverse', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.reverse.length.js b/benchmark/polyfill/benchmark.reverse.length.js deleted file mode 100644 index 5f051b7..0000000 --- a/benchmark/polyfill/benchmark.reverse.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s::polyfill:reverse:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.set.js b/benchmark/polyfill/benchmark.set.js deleted file mode 100644 index e2394cf..0000000 --- a/benchmark/polyfill/benchmark.set.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill::array:set', pkg ), function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Float16Array( 2 ); - buf = [ 0.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::typed_array:set', pkg ), function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Float16Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Float16Array( 2 ); - buf = new Float16Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.set.length.js b/benchmark/polyfill/benchmark.set.length.js deleted file mode 100644 index 72a56e7..0000000 --- a/benchmark/polyfill/benchmark.set.length.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - - arr1 = uniform( len, 0.0, 10.0 ); - arr2 = uniform( len, 0.0, 10.0 ); - arr = new Float16Array( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - 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( format( '%s::polyfill:set:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.slice.js b/benchmark/polyfill/benchmark.slice.js deleted file mode 100644 index 8ee2df0..0000000 --- a/benchmark/polyfill/benchmark.slice.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:slice', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.slice.length.js b/benchmark/polyfill/benchmark.slice.length.js deleted file mode 100644 index 232cff3..0000000 --- a/benchmark/polyfill/benchmark.slice.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s::polyfill:slice:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.some.js b/benchmark/polyfill/benchmark.some.js deleted file mode 100644 index c987ef3..0000000 --- a/benchmark/polyfill/benchmark.some.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:some', pkg ), function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); - -bench( format( '%s::polyfill::this_context:some', pkg ), function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); diff --git a/benchmark/polyfill/benchmark.some.length.js b/benchmark/polyfill/benchmark.some.length.js deleted file mode 100644 index fb689b5..0000000 --- a/benchmark/polyfill/benchmark.some.length.js +++ /dev/null @@ -1,107 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value < 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - 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( format( '%s::polyfill:some:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.sort.js b/benchmark/polyfill/benchmark.sort.js deleted file mode 100644 index 1ffaac3..0000000 --- a/benchmark/polyfill/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:sort', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.sort.length.js b/benchmark/polyfill/benchmark.sort.length.js deleted file mode 100644 index ec66cc2..0000000 --- a/benchmark/polyfill/benchmark.sort.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ i%len ] = i; - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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 = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s::polyfill:sort:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.subarray.js b/benchmark/polyfill/benchmark.subarray.js deleted file mode 100644 index b07f552..0000000 --- a/benchmark/polyfill/benchmark.subarray.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:subarray', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.subarray.length.js b/benchmark/polyfill/benchmark.subarray.length.js deleted file mode 100644 index 7313db0..0000000 --- a/benchmark/polyfill/benchmark.subarray.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s::polyfill:subarray:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.to_locale_string.js b/benchmark/polyfill/benchmark.to_locale_string.js deleted file mode 100644 index 7add18e..0000000 --- a/benchmark/polyfill/benchmark.to_locale_string.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:toLocaleString', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.to_locale_string.length.js b/benchmark/polyfill/benchmark.to_locale_string.length.js deleted file mode 100644 index 3f98d03..0000000 --- a/benchmark/polyfill/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - 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 = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s::polyfill:toLocaleString:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.to_reversed.js b/benchmark/polyfill/benchmark.to_reversed.js deleted file mode 100644 index ca7d6b5..0000000 --- a/benchmark/polyfill/benchmark.to_reversed.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:toReversed', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - 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 ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.to_reversed.length.js b/benchmark/polyfill/benchmark.to_reversed.length.js deleted file mode 100644 index e9fee39..0000000 --- a/benchmark/polyfill/benchmark.to_reversed.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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 ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s::polyfill:toReversed:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.to_sorted.js b/benchmark/polyfill/benchmark.to_sorted.js deleted file mode 100644 index 736fcf1..0000000 --- a/benchmark/polyfill/benchmark.to_sorted.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:toSorted', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toSorted(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.to_sorted.length.js b/benchmark/polyfill/benchmark.to_sorted.length.js deleted file mode 100644 index 32884b3..0000000 --- a/benchmark/polyfill/benchmark.to_sorted.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ i%len ] = i; - out = arr.toSorted(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a isFloat16Array' ); - } - 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( format( '%s::polyfill:toSorted:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.to_string.js b/benchmark/polyfill/benchmark.to_string.js deleted file mode 100644 index a2f7647..0000000 --- a/benchmark/polyfill/benchmark.to_string.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:toString', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.to_string.length.js b/benchmark/polyfill/benchmark.to_string.length.js deleted file mode 100644 index a772983..0000000 --- a/benchmark/polyfill/benchmark.to_string.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - 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 = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s::polyfill:toString:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.values.js b/benchmark/polyfill/benchmark.values.js deleted file mode 100644 index 59a4470..0000000 --- a/benchmark/polyfill/benchmark.values.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:values', pkg ), function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.values.length.js b/benchmark/polyfill/benchmark.values.length.js deleted file mode 100644 index f300b23..0000000 --- a/benchmark/polyfill/benchmark.values.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var iter; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isIteratorLike( iter ) ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - 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( format( '%s::polyfill:values:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.with.js b/benchmark/polyfill/benchmark.with.js deleted file mode 100644 index 05edb05..0000000 --- a/benchmark/polyfill/benchmark.with.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:with', pkg ), function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = uniform( 2, 0.0, 1.0 ); - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.with( i%arr.length, values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.with.length.js b/benchmark/polyfill/benchmark.with.length.js deleted file mode 100644 index cf76a7d..0000000 --- a/benchmark/polyfill/benchmark.with.length.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var values; - var out; - var i; - - values = uniform( 2, 0.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.with( i%len, values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s::polyfill:with:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 62eb7f0..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/float16" -%% click B href "https://github.com/stdlib-js/array-float16/tree/main" -%% click C href "https://github.com/stdlib-js/array-float16/tree/production" -%% click D href "https://github.com/stdlib-js/array-float16/tree/esm" -%% click E href "https://github.com/stdlib-js/array-float16/tree/deno" -%% click F href "https://github.com/stdlib-js/array-float16/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/float16 -[production-url]: https://github.com/stdlib-js/array-float16/tree/production -[deno-url]: https://github.com/stdlib-js/array-float16/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-float16/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-float16/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-float16/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-float16/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-float16/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 0b44231..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ctor from '../docs/types/index'; -export = ctor; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 8ef619b..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var T=function(o,r){return function(){return r||o((r={exports:{}}).exports,r),r.exports}};var O=T(function(pr,R){"use strict";var D=require("@stdlib/number-float64-base-to-float16"),J=require("@stdlib/number-float16-base-to-word");function K(o,r){var t,i;for(t=r.length,i=0;it.byteLength-o)throw new RangeError(s("invalid arguments. ArrayBuffer has insufficient capacity. Either decrease the array length or provide a bigger buffer. Minimum capacity: `%u`.",i*w));t=new b(t,o,i)}}for(f(this,"_buffer",t),f(this,"_length",t.length),n=0;n1){if(e=arguments[1],!p(e))throw new TypeError(s("invalid argument. Second argument must be a function. Value: `%s`.",e));i>2&&(t=arguments[2])}if(S(r)){if(e){for(h=r.length,n=new this(h),a=n._buffer,y=0;y=this._length))return g(this._buffer[r])});F(u.prototype,"buffer",function(){return this._buffer.buffer});F(u.prototype,"byteLength",function(){return this._buffer.byteLength});F(u.prototype,"byteOffset",function(){return this._buffer.byteOffset});f(u.prototype,"BYTES_PER_ELEMENT",u.BYTES_PER_ELEMENT);f(u.prototype,"copyWithin",function(r,t){if(!v(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");return arguments.length===2?this._buffer.copyWithin(r,t):this._buffer.copyWithin(r,t,arguments[2]),this});f(u.prototype,"entries",function(){var r,t,i,e,n,a;if(!v(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");return r=this,e=this._buffer,i=this._length,a=-1,t={},f(t,"next",l),f(t,"return",h),c&&f(t,c,y),t;function l(){return a+=1,n||a>=i?{done:!0}:{value:[a,g(e[a])],done:!1}}function h(q){return n=!0,arguments.length?{value:q,done:!0}:{done:!0}}function y(){return r.entries()}});f(u.prototype,"every",function(r,t){var i,e;if(!v(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!p(r))throw new TypeError(s("invalid argument. First argument must be a function. Value: `%s`.",r));for(i=this._buffer,e=0;e1){if(!m(t))throw new TypeError(s("invalid argument. Second argument must be an integer. Value: `%s`.",t));if(t<0&&(t+=n,t<0&&(t=0)),arguments.length>2){if(!m(i))throw new TypeError(s("invalid argument. Third argument must be an integer. Value: `%s`.",i));i<0&&(i+=n,i<0&&(i=0)),i>n&&(i=n)}else i=n}else t=0,i=n;for(l=E(r),a=t;a=0;n--)if(e=g(i[n]),r.call(t,e,n,this))return e});f(u.prototype,"findLastIndex",function(r,t){var i,e,n;if(!v(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!p(r))throw new TypeError(s("invalid argument. First argument must be a function. Value: `%s`.",r));for(i=this._buffer,n=this._length-1;n>=0;n--)if(e=g(i[n]),r.call(t,e,n,this))return n;return-1});f(u.prototype,"forEach",function(r,t){var i,e;if(!v(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!p(r))throw new TypeError(s("invalid argument. First argument must be a function. Value: `%s`.",r));for(i=this._buffer,e=0;e=this._length))return g(this._buffer[r])});f(u.prototype,"includes",function(r,t){var i,e,n;if(!v(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!d(r))throw new TypeError(s("invalid argument. First argument must be a number. Value: `%s`.",r));if(arguments.length>1){if(!m(t))throw new TypeError(s("invalid argument. Second argument must be an integer. Value: `%s`.",t));t<0&&(t+=this._length,t<0&&(t=0))}else t=0;for(i=this._buffer,n=E(r),e=t;e1){if(!m(t))throw new TypeError(s("invalid argument. Second argument must be an integer. Value: `%s`.",t));t<0&&(t+=this._length,t<0&&(t=0))}else t=0;for(i=this._buffer,n=E(r),e=t;e0){if(!P(r))throw new TypeError(s("invalid argument. First argument must be a string. Value: `%s`.",r))}else r=",";for(t=this._buffer,i=[],e=0;e=i?{done:!0}:{value:n,done:!1}}function l(y){return e=!0,arguments.length?{value:y,done:!0}:{done:!0}}function h(){return r.keys()}});f(u.prototype,"lastIndexOf",function(r,t){var i,e,n;if(!v(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!d(r))throw new TypeError(s("invalid argument. First argument must be a number. Value: `%s`.",r));if(arguments.length>1){if(!m(t))throw new TypeError(s("invalid argument. Second argument must be an integer. Value: `%s`.",t));t>=this._length?t=this._length-1:t<0&&(t+=this._length)}else t=this._length-1;for(i=this._buffer,n=E(r),e=t;e>=0;e--)if(n===i[e])return e;return-1});F(u.prototype,"length",function(){return this._length});f(u.prototype,"map",function(r,t){var i,e,n,a;if(!v(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!p(r))throw new TypeError("invalid argument. First argument must be a function. Value: `%s`.",r);for(n=this._buffer,e=new this.constructor(this._length),i=e._buffer,a=0;a1)n=t,a=0;else{if(e===0)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");n=g(i[0]),a=1}for(;a1)n=t,a=e-1;else{if(e===0)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");n=g(i[e-1]),a=e-2}for(;a>=0;a--)n=r(n,g(i[a]),a,this);return n});f(u.prototype,"reverse",function(){var r,t,i,e,n,a;if(!v(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");for(r=this._buffer,i=this._length,e=ir(i/2),n=0;n1){if(i=arguments[1],!_(i))throw new TypeError(s("invalid argument. Index argument must be a nonnegative integer. Value: `%s`.",i))}else i=0;if(l=r.length,i+l>this._length)throw new RangeError("invalid arguments. Target array lacks sufficient storage to accommodate source values.");if(v(r)?(t=r._buffer,a=!0):(t=r,a=!1),y=e.byteOffset+i*w,t.buffer===e.buffer&&t.byteOffsety){for(n=new b(t.length),h=0;hl&&(t=l)}}for(rh?1:0}function e(n,a){return r(g(n),g(a))}});f(u.prototype,"subarray",function(r,t){var i,e,n;if(!v(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(e=this._buffer,n=this._length,arguments.length===0)r=0,t=n;else{if(!m(r))throw new TypeError(s("invalid argument. First argument must be an integer. Value: `%s`.",r));if(r<0&&(r+=n,r<0&&(r=0)),arguments.length===1)t=n;else{if(!m(t))throw new TypeError(s("invalid argument. Second argument must be an integer. Value: `%s`.",t));t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n)}}return r>=n?(n=0,i=e.byteLength):r>=t?(n=0,i=e.byteOffset+r*w):(n=t-r,i=e.byteOffset+r*w),new this.constructor(e.buffer,i,n<0?0:n)});f(u.prototype,"toLocaleString",function(r,t){var i,e,n,a,l;if(!v(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(arguments.length===0)e=[];else if(P(r)||tr(r))e=r;else throw new TypeError(s("invalid argument. First argument must be a string or an array of strings. Value: `%s`.",r));if(arguments.length<2)i={};else if(A(t))i=t;else throw new TypeError(s("invalid argument. Options argument must be an object. Value: `%s`.",t));for(a=this._buffer,n=[],l=0;l=i?{done:!0}:{value:g(n[a]),done:!1}}function h(q){return e=!0,arguments.length?{value:q,done:!0}:{done:!0}}function y(){return t.values()}});f(u.prototype,"with",function(r,t){var i,e;if(!v(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!m(r))throw new TypeError(s("invalid argument. First argument must be an integer. Value: `%s`.",r));if(e=this._length,r<0&&(r+=e),r<0||r>=e)throw new RangeError(s("invalid argument. Index argument is out-of-bounds. Value: `%s`.",r));if(!d(t))throw new TypeError(s("invalid argument. Second argument must be a number. Value: `%s`.",t));return i=new this.constructor(this),i[r]=t,i});G.exports=u});var z=T(function(cr,U){"use strict";var lr=typeof Float16Array=="function"?Float16Array:void 0;U.exports=lr});var hr=require("@stdlib/assert-has-float16array-support"),vr=H(),gr=z(),L;hr()?L=gr:L=vr;module.exports=L; -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 00e84dc..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/polyfill/from_array.js", "../lib/polyfill/from_iterator.js", "../lib/polyfill/from_iterator_map.js", "../lib/polyfill/index.js", "../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar f16 = require( '@stdlib/number-float64-base-to-float16' );\nvar toWord = require( '@stdlib/number-float16-base-to-word' );\n\n\n// MAIN //\n\n/**\n* Fills an output array with unsigned 16-bit integers corresponding to the IEEE 754 binary representation of respective half-precision floating-point numbers.\n*\n* @private\n* @param {Uint16Array} buf - output array\n* @param {Array} arr - input array\n* @returns {Uint16Array} output array\n*/\nfunction fromArray( buf, arr ) {\n\tvar len;\n\tvar i;\n\n\tlen = arr.length;\n\tfor ( i = 0; i < len; i++ ) {\n\t\tbuf[ i ] = toWord( f16( arr[ i ] ) );\n\t}\n\treturn buf;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fromArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar f16 = require( '@stdlib/number-float64-base-to-float16' );\nvar toWord = require( '@stdlib/number-float16-base-to-word' );\n\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @returns {Array} output array\n*/\nfunction fromIterator( it ) {\n\tvar out;\n\tvar v;\n\n\tout = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tout.push( toWord( f16( v.value ) ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fromIterator;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar f16 = require( '@stdlib/number-float64-base-to-float16' );\nvar toWord = require( '@stdlib/number-float16-base-to-word' );\n\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @param {Function} clbk - callback to invoke for each iterated value\n* @param {*} thisArg - invocation context\n* @returns {Array} output array\n*/\nfunction fromIteratorMap( it, clbk, thisArg ) {\n\tvar out;\n\tvar v;\n\tvar i;\n\n\tout = [];\n\ti = -1;\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\ti += 1;\n\t\tout.push( toWord( f16( clbk.call( thisArg, v.value, i ) ) ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fromIteratorMap;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this, stdlib/jsdoc-typedef-typos, max-lines */\n\n'use strict';\n\n// MODULES //\n\nvar hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' );\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar isStringArray = require( '@stdlib/assert-is-string-array' ).primitives;\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isObject = require( '@stdlib/assert-is-object' );\nvar isnan = require( '@stdlib/math-base-assert-is-nan' );\nvar ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' );\nvar floor = require( '@stdlib/math-base-special-floor' );\nvar format = require( '@stdlib/string-format' );\nvar Uint16Array = require( '@stdlib/array-uint16' );\nvar f16 = require( '@stdlib/number-float64-base-to-float16' );\nvar toWord = require( '@stdlib/number-float16-base-to-word' );\nvar fromWord = require( '@stdlib/number-float16-base-from-word' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar fromArray = require( './from_array.js' );\nvar fromIterator = require( './from_iterator.js' );\nvar fromIteratorMap = require( './from_iterator_map.js' );\n\n\n// VARIABLES //\n\nvar BYTES_PER_ELEMENT = Uint16Array.BYTES_PER_ELEMENT;\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\n\n\n// FUNCTIONS //\n\n/**\n* Returns a boolean indicating if a value is a `Float16Array`.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `Float16Array`\n*/\nfunction isFloat16Array( value ) {\n\treturn (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\tvalue.constructor.name === 'Float16Array' &&\n\t\tvalue.BYTES_PER_ELEMENT === BYTES_PER_ELEMENT\n\t);\n}\n\n/**\n* Returns a boolean indicating if a value is a floating-point typed array constructor.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a floating-point typed array constructor\n*/\nfunction isFloatingPointArrayConstructor( value ) { // eslint-disable-line id-length\n\treturn ( value === Float16Array );\n}\n\n/**\n* Returns a getter.\n*\n* @private\n* @param {Float16Array} ctx - typed array instance\n* @param {NonNegativeInteger} idx - element index\n* @returns {Function} getter\n*/\nfunction getter( ctx, idx ) {\n\treturn get;\n\n\t/**\n\t* Returns an array element.\n\t*\n\t* @private\n\t* @returns {(number|void)} array element\n\t*/\n\tfunction get() {\n\t\treturn ctx._get( idx ); // eslint-disable-line no-underscore-dangle\n\t}\n}\n\n/**\n* Returns a setter.\n*\n* @private\n* @param {Float16Array} ctx - typed array instance\n* @param {NonNegativeInteger} idx - element index\n* @returns {Function} setter\n*/\nfunction setter( ctx, idx ) {\n\treturn set;\n\n\t/**\n\t* Sets an array element.\n\t*\n\t* @private\n\t* @param {number} value - value to set\n\t*/\n\tfunction set( value ) {\n\t\tctx.set( [ value ], idx );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* 16-bit floating-point number array constructor.\n*\n* @constructor\n* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable\n* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n* @param {NonNegativeInteger} [length] - view length\n* @throws {RangeError} ArrayBuffer byte length must be a multiple of `2`\n* @throws {TypeError} if provided only a single argument, must provide a valid argument\n* @throws {TypeError} byte offset must be a nonnegative integer\n* @throws {RangeError} byte offset must be a multiple of `2`\n* @throws {TypeError} view length must be a positive multiple of `2`\n* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n* @returns {Float16Array} half-precision floating-point number array\n*\n* @example\n* var arr = new Float16Array();\n* // returns \n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var arr = new Float16Array( 5 );\n* // returns \n*\n* var len = arr.length;\n* // returns 5\n*\n* @example\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 5\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float16Array( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 8\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float16Array( buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 4\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Float16Array( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nfunction Float16Array() {\n\tvar byteOffset;\n\tvar nargs;\n\tvar buf;\n\tvar len;\n\tvar arg;\n\tvar i;\n\n\tnargs = arguments.length;\n\tif ( !(this instanceof Float16Array) ) {\n\t\tif ( nargs === 0 ) {\n\t\t\treturn new Float16Array();\n\t\t}\n\t\tif ( nargs === 1 ) {\n\t\t\treturn new Float16Array( arguments[0] );\n\t\t}\n\t\tif ( nargs === 2 ) {\n\t\t\treturn new Float16Array( arguments[0], arguments[1] );\n\t\t}\n\t\treturn new Float16Array( arguments[0], arguments[1], arguments[2] );\n\t}\n\t// Create the underlying data buffer...\n\tif ( nargs === 0 ) {\n\t\tbuf = new Uint16Array( 0 ); // backward-compatibility\n\t} else if ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\t\tif ( isNonNegativeInteger( arg ) ) {\n\t\t\tbuf = new Uint16Array( arg );\n\t\t} else if ( isCollection( arg ) ) {\n\t\t\tif ( isFloat16Array( arg ) ) {\n\t\t\t\tbuf = new Uint16Array( arg.length );\n\t\t\t\tgcopy.ndarray( arg.length, new Uint16Array( arg.buffer, arg.byteOffset, arg.length ), 1, 0, buf, 1, 0 ); // eslint-disable-line max-len\n\t\t\t} else {\n\t\t\t\tbuf = fromArray( new Uint16Array( arg.length ), arg );\n\t\t\t}\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tif ( !isInteger( arg.byteLength/BYTES_PER_ELEMENT ) ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer byte length must be a multiple of %u. Byte length: `%u`.', BYTES_PER_ELEMENT, arg.byteLength ) );\n\t\t\t}\n\t\t\tbuf = new Uint16Array( arg );\n\t\t} else if ( isObject( arg ) ) {\n\t\t\tif ( HAS_ITERATOR_SYMBOL === false ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, ArrayBuffer, typed array, or array-like object. Value: `%s`.', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t\t}\n\t\t\tbuf = arg[ ITERATOR_SYMBOL ]();\n\t\t\tif ( !isFunction( buf.next ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t\t}\n\t\t\tbuf = new Uint16Array( fromIterator( buf ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t}\n\t} else {\n\t\tbuf = arguments[ 0 ];\n\t\tif ( !isArrayBuffer( buf ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', buf ) );\n\t\t}\n\t\tbyteOffset = arguments[ 1 ];\n\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) );\n\t\t}\n\t\tif ( !isInteger( byteOffset/BYTES_PER_ELEMENT ) ) {\n\t\t\tthrow new RangeError( format( 'invalid argument. Byte offset must be a multiple of %u. Value: `%u`.', BYTES_PER_ELEMENT, byteOffset ) );\n\t\t}\n\t\tif ( nargs === 2 ) {\n\t\t\tlen = buf.byteLength - byteOffset;\n\t\t\tif ( !isInteger( len/BYTES_PER_ELEMENT ) ) {\n\t\t\t\tthrow new RangeError( format( 'invalid arguments. ArrayBuffer view byte length must be a multiple of %u. View byte length: `%u`.', BYTES_PER_ELEMENT, len ) );\n\t\t\t}\n\t\t\tbuf = new Uint16Array( buf, byteOffset );\n\t\t} else {\n\t\t\tlen = arguments[ 2 ];\n\t\t\tif ( !isNonNegativeInteger( len ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', len ) );\n\t\t\t}\n\t\t\tif ( (len*BYTES_PER_ELEMENT) > (buf.byteLength-byteOffset) ) {\n\t\t\t\tthrow new RangeError( format( 'invalid arguments. ArrayBuffer has insufficient capacity. Either decrease the array length or provide a bigger buffer. Minimum capacity: `%u`.', len*BYTES_PER_ELEMENT ) );\n\t\t\t}\n\t\t\tbuf = new Uint16Array( buf, byteOffset, len );\n\t\t}\n\t}\n\tsetReadOnly( this, '_buffer', buf );\n\tsetReadOnly( this, '_length', buf.length );\n\tfor ( i = 0; i < buf.length; i++ ) {\n\t\tsetReadWriteAccessor( this, i, getter( this, i ), setter( this, i ) );\n\t}\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each array element.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Float16Array\n* @readonly\n* @type {PositiveInteger}\n* @default 2\n*\n* @example\n* var nbytes = Float16Array.BYTES_PER_ELEMENT;\n* // returns 2\n*/\nsetReadOnly( Float16Array, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT );\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof Float16Array\n* @readonly\n* @type {string}\n* @default 'Float16Array'\n*\n* @example\n* var str = Float16Array.name;\n* // returns 'Float16Array'\n*/\nsetReadOnly( Float16Array, 'name', 'Float16Array' );\n\n/**\n* Creates a new 16-bit floating-point number array from an array-like object or an iterable.\n*\n* @name from\n* @memberof Float16Array\n* @type {Function}\n* @param {(Collection|Iterable)} src - array-like object or iterable\n* @param {Function} [clbk] - callback to invoke for each source element\n* @param {*} [thisArg] - context\n* @throws {TypeError} `this` context must be a constructor\n* @throws {TypeError} `this` must be a floating-point array\n* @throws {TypeError} first argument must be an array-like object or an iterable\n* @throws {TypeError} second argument must be a function\n* @returns {Float16Array} half-precision floating-point number array\n*\n* @example\n* var arr = Float16Array.from( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* function clbk( v ) {\n* return v * 2.0;\n* }\n*\n* var arr = Float16Array.from( [ 1.0, 2.0 ], clbk );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nsetReadOnly( Float16Array, 'from', function from( src ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar clbk;\n\tvar out;\n\tvar buf;\n\tvar tmp;\n\tvar len;\n\tvar i;\n\tif ( !isFunction( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` context must be a constructor.' );\n\t}\n\tif ( !isFloatingPointArrayConstructor( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs > 1 ) {\n\t\tclbk = arguments[ 1 ];\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t\tif ( nargs > 2 ) {\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( isCollection( src ) ) {\n\t\tif ( clbk ) {\n\t\t\tlen = src.length;\n\t\t\tout = new this( len );\n\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tbuf[ i ] = toWord( f16( clbk.call( thisArg, src[ i ], i ) ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\treturn new this( src );\n\t}\n\tif ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) { // eslint-disable-line max-len\n\t\tbuf = src[ ITERATOR_SYMBOL ]();\n\t\tif ( !isFunction( buf.next ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) );\n\t\t}\n\t\tif ( clbk ) {\n\t\t\ttmp = fromIteratorMap( buf, clbk, thisArg );\n\t\t} else {\n\t\t\ttmp = fromIterator( buf );\n\t\t}\n\t\tif ( tmp instanceof Error ) {\n\t\t\tthrow tmp;\n\t\t}\n\t\tlen = tmp.length;\n\t\tout = new this( len );\n\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tbuf[ i ] = tmp[ i ];\n\t\t}\n\t\treturn out;\n\t}\n\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) );\n});\n\n/**\n* Creates a new 16-bit floating-point number array from a variable number of arguments.\n*\n* @name of\n* @memberof Float16Array\n* @type {Function}\n* @param {...*} element - array elements\n* @throws {TypeError} `this` context must be a constructor\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Float16Array} half-precision floating-point number array\n*\n* @example\n* var arr = Float16Array.of( 1.0, 1.0, 1.0, 1.0 );\n* // returns \n*\n* var x = arr[ 0 ];\n* // returns 1.0\n*\n* var len = arr.length;\n* // returns 4\n*/\nsetReadOnly( Float16Array, 'of', function of() {\n\tvar args;\n\tvar i;\n\tif ( !isFunction( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` context must be a constructor.' );\n\t}\n\tif ( !isFloatingPointArrayConstructor( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\targs = [];\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\targs.push( arguments[ i ] );\n\t}\n\treturn new this( args );\n});\n\n/**\n* Returns an array element with support for both nonnegative and negative integer indices.\n*\n* @name at\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} must provide an integer\n* @returns {(number|void)} array element\n*\n* @example\n* var arr = new Float16Array( [ 10.0, 20.0, 30.0 ] );\n*\n* var v = arr.at( 0 );\n* // returns 10.0\n*\n* v = arr.at( -1 );\n* // returns 30.0\n*\n* v = arr.at( 100 );\n* // returns undefined\n*/\nsetReadOnly( Float16Array.prototype, 'at', function at( idx ) {\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += this._length;\n\t}\n\tif ( idx < 0 || idx >= this._length ) {\n\t\treturn;\n\t}\n\treturn fromWord( this._buffer[ idx ] );\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name buffer\n* @memberof Float16Array.prototype\n* @readonly\n* @type {ArrayBuffer}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var buf = arr.buffer;\n* // returns \n*/\nsetReadOnlyAccessor( Float16Array.prototype, 'buffer', function get() {\n\treturn this._buffer.buffer;\n});\n\n/**\n* Size (in bytes) of the array.\n*\n* @name byteLength\n* @memberof Float16Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var byteLength = arr.byteLength;\n* // returns 20\n*/\nsetReadOnlyAccessor( Float16Array.prototype, 'byteLength', function get() {\n\treturn this._buffer.byteLength;\n});\n\n/**\n* Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`.\n*\n* @name byteOffset\n* @memberof Float16Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var byteOffset = arr.byteOffset;\n* // returns 0\n*/\nsetReadOnlyAccessor( Float16Array.prototype, 'byteOffset', function get() {\n\treturn this._buffer.byteOffset;\n});\n\n/**\n* Size (in bytes) of each array element.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Float16Array.prototype\n* @readonly\n* @type {PositiveInteger}\n* @default 2\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var nbytes = arr.BYTES_PER_ELEMENT;\n* // returns 2\n*/\nsetReadOnly( Float16Array.prototype, 'BYTES_PER_ELEMENT', Float16Array.BYTES_PER_ELEMENT );\n\n/**\n* Copies a sequence of elements within the array to the position starting at `target`.\n*\n* @name copyWithin\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} target - index at which to start copying elements\n* @param {integer} start - source index at which to copy elements from\n* @param {integer} [end] - source index at which to stop copying elements from\n* @throws {TypeError} `this` must be a floating-point array\n* @returns {Float16Array} modified array\n*\n* @example\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0 ] );\n*\n* // Copy the first two elements to the last two elements:\n* arr.copyWithin( 2, 0, 2 );\n*\n* var v = arr[ 2 ];\n* // returns 1.0\n*\n* v = arr[ 3 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'copyWithin', function copyWithin( target, start ) {\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\t// FIXME: prefer a functional `copyWithin` implementation which addresses lack of universal browser support (e.g., IE11 and Safari) or ensure that typed arrays are polyfilled\n\tif ( arguments.length === 2 ) {\n\t\tthis._buffer.copyWithin( target, start );\n\t} else {\n\t\tthis._buffer.copyWithin( target, start, arguments[2] );\n\t}\n\treturn this;\n});\n\n/**\n* Returns an iterator for iterating over array key-value pairs.\n*\n* @name entries\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] );\n*\n* var it = arr.entries();\n*\n* var v = it.next().value;\n* // returns [ 0, 1.0 ]\n*\n* v = it.next().value;\n* // returns [ 1, 2.0 ]\n*\n* v = it.next().value;\n* // returns [ 2, 3.0 ]\n*\n* var bool = it.next().done;\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'entries', function entries() {\n\tvar self;\n\tvar iter;\n\tvar len;\n\tvar buf;\n\tvar FLG;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tself = this;\n\tbuf = this._buffer;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': [ i, fromWord( buf[ i ] ) ],\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.entries();\n\t}\n});\n\n/**\n* Tests whether all elements in an array pass a test implemented by a predicate function.\n*\n* @name every\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {boolean} boolean indicating whether all elements pass a test\n*\n* @example\n* function predicate( v ) {\n* return v === 0.0;\n* }\n*\n* var arr = new Float16Array( 3 );\n*\n* var bool = arr.every( predicate );\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'every', function every( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( !predicate.call( thisArg, fromWord( buf[ i ] ), i, this ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n});\n\n/**\n* Returns a modified typed array filled with a fill value.\n*\n* @name fill\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {number} value - fill value\n* @param {integer} [start=0] - starting index (inclusive)\n* @param {integer} [end] - ending index (exclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a floating-point number\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be an integer\n* @returns {Float16Array} modified array\n*\n* @example\n* var arr = new Float16Array( 3 );\n*\n* arr.fill( 1.0, 1 );\n*\n* var v = arr[ 0 ];\n* // returns 0.0\n*\n* v = arr[ 1 ];\n* // returns 1.0\n*\n* v = arr[ 2 ];\n* // returns 1.0\n*/\nsetReadOnly( Float16Array.prototype, 'fill', function fill( value, start, end ) {\n\tvar buf;\n\tvar len;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNumber( value ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a number. Value: `%s`.', value ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( start ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', start ) );\n\t\t}\n\t\tif ( start < 0 ) {\n\t\t\tstart += len;\n\t\t\tif ( start < 0 ) {\n\t\t\t\tstart = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length > 2 ) {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t} else {\n\t\t\tend = len;\n\t\t}\n\t} else {\n\t\tstart = 0;\n\t\tend = len;\n\t}\n\tv = toWord( value );\n\tfor ( i = start; i < end; i++ ) {\n\t\tbuf[ i ] = v;\n\t}\n\treturn this;\n});\n\n/**\n* Returns a new array containing the elements of an array which pass a test implemented by a predicate function.\n*\n* @name filter\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {Float16Array} floating-point number array\n*\n* @example\n* function predicate( v ) {\n* return ( v === 0.0 );\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] );\n*\n* var out = arr.filter( predicate );\n* // returns \n*\n* var len = out.length;\n* // returns 2\n*\n* var v = out[ 0 ];\n* // returns 0.0\n*\n* v = out[ 1 ];\n* // returns 0.0\n*/\nsetReadOnly( Float16Array.prototype, 'filter', function filter( predicate, thisArg ) {\n\tvar buf;\n\tvar out;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\tout.push( v );\n\t\t}\n\t}\n\treturn new this.constructor( out );\n});\n\n/**\n* Returns the first element in an array for which a predicate function returns a truthy value.\n*\n* @name find\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {(boolean|void)} array element or undefined\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] );\n*\n* var v = arr.find( predicate );\n* // returns 1.0\n*/\nsetReadOnly( Float16Array.prototype, 'find', function find( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn v;\n\t\t}\n\t}\n});\n\n/**\n* Returns the index of the first element in an array for which a predicate function returns a truthy value.\n*\n* @name findIndex\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {integer} index or -1\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var v = arr.findIndex( predicate );\n* // returns 1\n*/\nsetReadOnly( Float16Array.prototype, 'findIndex', function findIndex( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Returns the last element in an array for which a predicate function returns a truthy value.\n*\n* @name findLast\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {(boolean|void)} array element or undefined\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] );\n*\n* var v = arr.findLast( predicate );\n* // returns 1.0\n*/\nsetReadOnly( Float16Array.prototype, 'findLast', function findLast( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = this._length-1; i >= 0; i-- ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn v;\n\t\t}\n\t}\n});\n\n/**\n* Returns the index of the last element in an array for which a predicate function returns a truthy value.\n*\n* @name findLastIndex\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {integer} index or -1\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] );\n*\n* var v = arr.findLastIndex( predicate );\n* // returns 1\n*/\nsetReadOnly( Float16Array.prototype, 'findLastIndex', function findLastIndex( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = this._length-1; i >= 0; i-- ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Invokes a function once for each array element.\n*\n* @name forEach\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} fcn - function to invoke\n* @param {*} [thisArg] - function invocation context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n*\n* @example\n* function log( v, i ) {\n* console.log( '%s: %s', i, v.toString() );\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* arr.forEach( log );\n*/\nsetReadOnly( Float16Array.prototype, 'forEach', function forEach( fcn, thisArg ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( fcn ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tfcn.call( thisArg, fromWord( buf[ i ] ), i, this );\n\t}\n});\n\n/**\n* Returns an array element.\n*\n* @private\n* @name _get\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {NonNegativeInteger} idx - element index\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} must provide a nonnegative integer\n* @returns {(number|void)} array element\n*/\nsetReadOnly( Float16Array.prototype, '_get', function get( idx ) {\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNonNegativeInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a nonnegative integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx >= this._length ) {\n\t\treturn;\n\t}\n\treturn fromWord( this._buffer[ idx ] );\n});\n\n/**\n* Returns a boolean indicating whether an array includes a provided value.\n*\n* @name includes\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {number} searchElement - search element\n* @param {integer} [fromIndex=0] - starting index (inclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a floating-point number\n* @throws {TypeError} second argument must be an integer\n* @returns {boolean} boolean indicating whether an array includes a value\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] );\n*\n* var bool = arr.includes( 1.0 );\n* // returns true\n*\n* bool = arr.includes( 1.0, 2 );\n* // returns false\n*\n* bool = arr.includes( 5.0 );\n* // returns false\n*/\nsetReadOnly( Float16Array.prototype, 'includes', function includes( searchElement, fromIndex ) {\n\tvar buf;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNumber( searchElement ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a number. Value: `%s`.', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\tfromIndex = 0;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfromIndex = 0;\n\t}\n\tbuf = this._buffer;\n\tv = toWord( searchElement );\n\tfor ( i = fromIndex; i < this._length; i++ ) {\n\t\tif ( v === buf[ i ] ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n});\n\n/**\n* Returns the first index at which a given element can be found.\n*\n* @name indexOf\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {float16} searchElement - element to find\n* @param {integer} [fromIndex=0] - starting index (inclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a floating-point number\n* @throws {TypeError} second argument must be an integer\n* @returns {integer} index or -1\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] );\n*\n* var idx = arr.indexOf( 2.0 );\n* // returns 2\n*\n* idx = arr.indexOf( 2.0, 3 );\n* // returns -1\n*\n* idx = arr.indexOf( 3.0, 3 );\n* // returns 3\n*/\nsetReadOnly( Float16Array.prototype, 'indexOf', function indexOf( searchElement, fromIndex ) {\n\tvar buf;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNumber( searchElement ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a number. Value: `%s`.', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\tfromIndex = 0;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfromIndex = 0;\n\t}\n\tbuf = this._buffer;\n\tv = toWord( searchElement );\n\tfor ( i = fromIndex; i < this._length; i++ ) {\n\t\tif ( v === buf[ i ] ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Returns a new string by concatenating all array elements.\n*\n* @name join\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {string} [separator=','] - element separator\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a string\n* @returns {string} string representation\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var str = arr.join();\n* // returns '0,1,2'\n*\n* str = arr.join( '|' );\n* // returns '0|1|2'\n*/\nsetReadOnly( Float16Array.prototype, 'join', function join( separator ) {\n\tvar buf;\n\tvar out;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( arguments.length > 0 ) {\n\t\tif ( !isString( separator ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', separator ) );\n\t\t}\n\t} else {\n\t\tseparator = ',';\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( fromWord( buf[ i ] ) );\n\t}\n\treturn out.join( separator );\n});\n\n/**\n* Returns an iterator for iterating over each index key in a typed array.\n*\n* @name keys\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new Float16Array( [ 1.0, 2.0 ] );\n*\n* var iter = arr.keys();\n*\n* var v = iter.next().value;\n* // returns 0\n*\n* v = iter.next().value;\n* // returns 1\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'keys', function keys() {\n\tvar self;\n\tvar iter;\n\tvar len;\n\tvar FLG;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tself = this;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': i,\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.keys();\n\t}\n});\n\n/**\n* Returns the last index at which a given element can be found.\n*\n* @name lastIndexOf\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {number} searchElement - element to find\n* @param {integer} [fromIndex] - starting index (inclusive)\n* @throws {TypeError} `this` must be a floating-point number\n* @throws {TypeError} first argument must be a numeric value\n* @throws {TypeError} second argument must be an integer\n* @returns {integer} index or -1\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 2.0 ] );\n*\n* var idx = arr.lastIndexOf( 2.0 );\n* // returns 4\n*\n* idx = arr.lastIndexOf( 2.0, 3 );\n* // returns 2\n*\n* idx = arr.lastIndexOf( 4.0, 3 );\n* // returns -1\n*\n* idx = arr.lastIndexOf( 1.0, -3 );\n* // returns 1\n*/\nsetReadOnly( Float16Array.prototype, 'lastIndexOf', function lastIndexOf( searchElement, fromIndex ) {\n\tvar buf;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNumber( searchElement ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a number. Value: `%s`.', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex >= this._length ) {\n\t\t\tfromIndex = this._length - 1;\n\t\t} else if ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t}\n\t} else {\n\t\tfromIndex = this._length - 1;\n\t}\n\tbuf = this._buffer;\n\tv = toWord( searchElement );\n\tfor ( i = fromIndex; i >= 0; i-- ) {\n\t\tif ( v === buf[ i ] ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Number of array elements.\n*\n* @name length\n* @memberof Float16Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var len = arr.length;\n* // returns 10\n*/\nsetReadOnlyAccessor( Float16Array.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Returns a new array with each element being the result of a provided callback function.\n*\n* @name map\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} fcn - callback function\n* @param {*} [thisArg] - callback function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {Float16Array} new floating-point number array\n*\n* @example\n* function scale( v ) {\n* return v * 2.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var out = arr.map( scale );\n* // returns \n*\n* var z = out[ 0 ];\n* // returns 0.0\n*\n* z = out[ 1 ];\n* // returns 2.0\n*\n* z = out[ 2 ];\n* // returns 4.0\n*/\nsetReadOnly( Float16Array.prototype, 'map', function map( fcn, thisArg ) {\n\tvar outbuf;\n\tvar out;\n\tvar buf;\n\tvar i;\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( fcn ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be a function. Value: `%s`.', fcn );\n\t}\n\tbuf = this._buffer;\n\tout = new this.constructor( this._length );\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\toutbuf[ i ] = toWord( fcn.call( thisArg, fromWord( buf[ i ] ), i, this ) ); // eslint-disable-line max-len\n\t}\n\treturn out;\n});\n\n/**\n* Applies a provided callback function to each element of the array, in order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion.\n*\n* @name reduce\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} reducer - callback function\n* @param {*} [initialValue] - initial value\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {Error} if not provided an initial value, the array must have at least one element\n* @returns {*} accumulated result\n*\n* @example\n* function add( acc, v ) {\n* return acc + v;\n* }\n*\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] );\n*\n* var out = arr.reduce( add, 0 );\n* // returns 6.0\n*/\nsetReadOnly( Float16Array.prototype, 'reduce', function reduce( reducer, initialValue ) {\n\tvar buf;\n\tvar len;\n\tvar acc;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( reducer ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', reducer ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tacc = initialValue;\n\t\ti = 0;\n\t} else {\n\t\tif ( len === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' );\n\t\t}\n\t\tacc = fromWord( buf[ 0 ] );\n\t\ti = 1;\n\t}\n\tfor ( ; i < len; i++ ) {\n\t\tacc = reducer( acc, fromWord( buf[ i ] ), i, this );\n\t}\n\treturn acc;\n});\n\n/**\n* Applies a provided callback function to each element of the array, in reverse order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion.\n*\n* @name reduceRight\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} reducer - callback function\n* @param {*} [initialValue] - initial value\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {Error} if not provided an initial value, the array must have at least one element\n* @returns {*} accumulated result\n*\n* @example\n* function add( acc, v ) {\n* return acc + v;\n* }\n*\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] );\n*\n* var out = arr.reduceRight( add, 0 );\n* // returns 6.0\n*/\nsetReadOnly( Float16Array.prototype, 'reduceRight', function reduceRight( reducer, initialValue ) {\n\tvar buf;\n\tvar len;\n\tvar acc;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( reducer ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', reducer ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tacc = initialValue;\n\t\ti = len - 1;\n\t} else {\n\t\tif ( len === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' );\n\t\t}\n\t\tacc = fromWord( buf[ len-1 ] );\n\t\ti = len - 2;\n\t}\n\tfor ( ; i >= 0; i-- ) {\n\t\tacc = reducer( acc, fromWord( buf[ i ] ), i, this );\n\t}\n\treturn acc;\n});\n\n/**\n* Reverses an array in-place.\n*\n* @name reverse\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Float16Array} reversed array\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var out = arr.reverse();\n* // returns \n*\n* var v = out[ 0 ];\n* // returns 2.0\n*\n* v = out[ 1 ];\n* // returns 1.0\n*\n* v = out[ 2 ];\n* // returns 0.0\n*/\nsetReadOnly( Float16Array.prototype, 'reverse', function reverse() {\n\tvar buf;\n\tvar tmp;\n\tvar len;\n\tvar N;\n\tvar i;\n\tvar j;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tN = floor( len / 2 );\n\tfor ( i = 0; i < N; i++ ) {\n\t\tj = len - i - 1;\n\t\ttmp = buf[ i ];\n\t\tbuf[ i ] = buf[ j ];\n\t\tbuf[ j ] = tmp;\n\t}\n\treturn this;\n});\n\n/**\n* Sets one or more array elements.\n*\n* ## Notes\n*\n* - When provided a typed array, we must check whether the source array shares the same buffer as the target array and whether the underlying memory overlaps. In particular, we are concerned with the following scenario:\n*\n* ```text\n* buf: ---------------------\n* src: ---------------------\n* ```\n*\n* In the above, as we copy values from `src`, we will overwrite values in the `src` view, resulting in duplicated values copied into the end of `buf`, which is not intended. Hence, to avoid overwriting source values, we must **copy** source values to a temporary array.\n*\n* In the other overlapping scenario,\n*\n* ```text\n* buf: ---------------------\n* src: ---------------------\n* ```\n*\n* by the time we begin copying into the overlapping region, we are copying from the end of `src`, a non-overlapping region, which means we don't run the risk of copying copied values, rather than the original `src` values, as intended.\n*\n* @name set\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {(Collection|Float16Array)} value - value(s)\n* @param {NonNegativeInteger} [i=0] - element index at which to start writing values\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a collection\n* @throws {TypeError} index argument must be a nonnegative integer\n* @throws {RangeError} index argument is out-of-bounds\n* @throws {RangeError} target array lacks sufficient storage to accommodate source values\n* @returns {void}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var v = arr[ 0 ];\n* // returns 0.0\n*\n* arr.set( [ 1.0, 2.0 ], 0 );\n*\n* v = arr[ 0 ];\n* // returns 1.0\n*/\nsetReadOnly( Float16Array.prototype, 'set', function set( value ) {\n\tvar sbuf;\n\tvar idx;\n\tvar buf;\n\tvar tmp;\n\tvar flg;\n\tvar N;\n\tvar i;\n\tvar j;\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isCollection( value ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', value ) );\n\t}\n\tbuf = this._buffer;\n\tif ( arguments.length > 1 ) {\n\t\tidx = arguments[ 1 ];\n\t\tif ( !isNonNegativeInteger( idx ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Index argument must be a nonnegative integer. Value: `%s`.', idx ) );\n\t\t}\n\t} else {\n\t\tidx = 0;\n\t}\n\tN = value.length;\n\tif ( idx+N > this._length ) {\n\t\tthrow new RangeError( 'invalid arguments. Target array lacks sufficient storage to accommodate source values.' );\n\t}\n\tif ( isFloat16Array( value ) ) {\n\t\tsbuf = value._buffer; // eslint-disable-line no-underscore-dangle\n\t\tflg = true;\n\t} else {\n\t\tsbuf = value;\n\t\tflg = false;\n\t}\n\t// Check for overlapping memory...\n\tj = buf.byteOffset + (idx*BYTES_PER_ELEMENT);\n\tif (\n\t\tsbuf.buffer === buf.buffer &&\n\t\t(\n\t\t\tsbuf.byteOffset < j &&\n\t\t\tsbuf.byteOffset+sbuf.byteLength > j\n\t\t)\n\t) {\n\t\t// We need to copy source values...\n\t\ttmp = new Uint16Array( sbuf.length );\n\t\tfor ( i = 0; i < sbuf.length; i++ ) {\n\t\t\ttmp[ i ] = sbuf[ i ];\n\t\t}\n\t\tsbuf = tmp;\n\t}\n\tif ( flg ) {\n\t\tfor ( i = 0; i < N; idx++, i++ ) {\n\t\t\tbuf[ idx ] = sbuf[ i ];\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < N; idx++, i++ ) {\n\t\t\tbuf[ idx ] = toWord( sbuf[ i ] );\n\t\t}\n\t}\n});\n\n/**\n* Copies a portion of a typed array to a new typed array.\n*\n* @name slice\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} [begin] - start index (inclusive)\n* @param {integer} [end] - end index (exclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be integer\n* @throws {TypeError} second argument must be integer\n* @returns {Float16Array} floating-point number array\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] );\n*\n* var out = arr.slice();\n* // returns \n*\n* var len = out.length;\n* // returns 5\n*\n* var v = out[ 0 ];\n* // returns 0.0\n*\n* v = out[ len-1 ];\n* // returns 4.0\n*\n* out = arr.slice( 1, -2 );\n* // returns \n*\n* len = out.length;\n* // returns 2\n*\n* v = out[ 0 ];\n* // returns 1.0\n*\n* v = out[ len-1 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'slice', function slice( begin, end ) {\n\tvar outlen;\n\tvar outbuf;\n\tvar out;\n\tvar buf;\n\tvar len;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length === 0 ) {\n\t\tbegin = 0;\n\t\tend = len;\n\t} else {\n\t\tif ( !isInteger( begin ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', begin ) );\n\t\t}\n\t\tif ( begin < 0 ) {\n\t\t\tbegin += len;\n\t\t\tif ( begin < 0 ) {\n\t\t\t\tbegin = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\tend = len;\n\t\t} else {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t} else if ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t}\n\t}\n\tif ( begin < end ) {\n\t\toutlen = end - begin;\n\t} else {\n\t\toutlen = 0;\n\t}\n\tout = new this.constructor( outlen );\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < outlen; i++ ) {\n\t\toutbuf[ i ] = buf[ i+begin ];\n\t}\n\treturn out;\n});\n\n/**\n* Tests whether at least one element in an array passes a test implemented by a predicate function.\n*\n* @name some\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {boolean} boolean indicating whether at least one element passes a test\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var bool = arr.some( predicate );\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'some', function some( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( predicate.call( thisArg, fromWord( buf[ i ] ), i, this ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n});\n\n/**\n* Sorts an array in-place.\n*\n* @name sort\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} [compareFcn] - comparison function\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {Float16Array} sorted array\n*\n* @example\n* function compare( a, b ) {\n* if ( a < b ) {\n* return -1;\n* }\n* if ( a > b ) {\n* return 1;\n* }\n* return 0;\n* }\n*\n* var arr = new Float16Array( [ 1.0, 0.0, 2.0 ] );\n*\n* arr.sort( compare );\n*\n* var v = arr[ 0 ];\n* // returns 0.0\n*\n* v = arr[ 1 ];\n* // returns 1.0\n*\n* v = arr[ 2 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'sort', function sort( compareFcn ) {\n\tvar buf;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tif ( arguments.length === 0 ) {\n\t\tbuf.sort( defaultCompare );\n\t\treturn this;\n\t}\n\tif ( !isFunction( compareFcn ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', compareFcn ) );\n\t}\n\tbuf.sort( compare );\n\treturn this;\n\n\t/**\n\t* Default comparison function for float16 values.\n\t*\n\t* @private\n\t* @param {unsigned16} a - unsigned 16-bit integer for comparison\n\t* @param {unsigned16} b - unsigned 16-bit integer for comparison\n\t* @returns {number} comparison result\n\t*/\n\tfunction defaultCompare( a, b ) { // eslint-disable-line stdlib/no-unnecessary-nested-functions\n\t\tvar x = fromWord( a );\n\t\tvar y = fromWord( b );\n\n\t\t// Handle NaN...\n\t\tif ( isnan( x ) && isnan( y ) ) {\n\t\t\treturn 0;\n\t\t}\n\t\tif ( isnan( x ) ) {\n\t\t\treturn 1;\n\t\t}\n\t\tif ( isnan( y ) ) {\n\t\t\treturn -1;\n\t\t}\n\t\t// Normal comparison\n\t\tif ( x < y ) {\n\t\t\treturn -1;\n\t\t}\n\t\tif ( x > y ) {\n\t\t\treturn 1;\n\t\t}\n\t\treturn 0;\n\t}\n\n\t/**\n\t* Comparison function wrapper.\n\t*\n\t* @private\n\t* @param {unsigned16} a - unsigned 16-bit integer for comparison\n\t* @param {unsigned16} b - unsigned 16-bit integer for comparison\n\t* @returns {number} comparison result\n\t*/\n\tfunction compare( a, b ) {\n\t\treturn compareFcn( fromWord( a ), fromWord( b ) );\n\t}\n});\n\n/**\n* Creates a new typed array view over the same underlying `ArrayBuffer` and with the same underlying data type as the host array.\n*\n* @name subarray\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} [begin] - start index (inclusive)\n* @param {integer} [end] - end index (exclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be an integer\n* @throws {TypeError} second argument must be an integer\n* @returns {Float16Array} subarray\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] );\n*\n* var subarr = arr.subarray();\n* // returns \n*\n* var len = subarr.length;\n* // returns 5\n*\n* var bool = subarr[ 0 ];\n* // returns 0.0\n*\n* bool = subarr[ len-1 ];\n* // returns 4.0\n*\n* subarr = arr.subarray( 1, -2 );\n* // returns \n*\n* len = subarr.length;\n* // returns 2\n*\n* bool = subarr[ 0 ];\n* // returns 1.0\n*\n* bool = subarr[ len-1 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'subarray', function subarray( begin, end ) {\n\tvar offset;\n\tvar buf;\n\tvar len;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length === 0 ) {\n\t\tbegin = 0;\n\t\tend = len;\n\t} else {\n\t\tif ( !isInteger( begin ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', begin ) );\n\t\t}\n\t\tif ( begin < 0 ) {\n\t\t\tbegin += len;\n\t\t\tif ( begin < 0 ) {\n\t\t\t\tbegin = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\tend = len;\n\t\t} else {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t} else if ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t}\n\t}\n\tif ( begin >= len ) {\n\t\tlen = 0;\n\t\toffset = buf.byteLength;\n\t} else if ( begin >= end ) {\n\t\tlen = 0;\n\t\toffset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT );\n\t} else {\n\t\tlen = end - begin;\n\t\toffset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT );\n\t}\n\treturn new this.constructor( buf.buffer, offset, ( len < 0 ) ? 0 : len );\n});\n\n/**\n* Serializes an array as a locale-specific string.\n*\n* @name toLocaleString\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {(string|Array)} [locales] - locale identifier(s)\n* @param {Object} [options] - configuration options\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a string or an array of strings\n* @throws {TypeError} options argument must be an object\n* @returns {string} string representation\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var str = arr.toLocaleString();\n* // returns '0,1,2'\n*/\nsetReadOnly( Float16Array.prototype, 'toLocaleString', function toLocaleString( locales, options ) {\n\tvar opts;\n\tvar loc;\n\tvar out;\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( arguments.length === 0 ) {\n\t\tloc = [];\n\t} else if ( isString( locales ) || isStringArray( locales ) ) {\n\t\tloc = locales;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a string or an array of strings. Value: `%s`.', locales ) );\n\t}\n\tif ( arguments.length < 2 ) {\n\t\topts = {};\n\t} else if ( isObject( options ) ) {\n\t\topts = options;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( fromWord( buf[ i ] ) );\n\t}\n\treturn out.toLocaleString( loc, opts );\n});\n\n/**\n* Returns a new typed array containing the elements in reversed order.\n*\n* @name toReversed\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Float16Array} reversed array\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var out = arr.toReversed();\n* // returns \n*\n* var v = out[ 0 ];\n* // returns 2.0\n*\n* v = out[ 1 ];\n* // returns 1.0\n*\n* v = out[ 2 ];\n* // returns 0.0\n*/\nsetReadOnly( Float16Array.prototype, 'toReversed', function toReversed() {\n\tvar outbuf;\n\tvar out;\n\tvar len;\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tlen = this._length;\n\tout = new this.constructor( len );\n\tbuf = this._buffer;\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < len; i++ ) {\n\t\toutbuf[ i ] = buf[ len - i - 1 ];\n\t}\n\treturn out;\n});\n\n/**\n* Returns a new typed array containing the elements in sorted order.\n*\n* @name toSorted\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} [compareFcn] - comparison function\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {Float16Array} sorted array\n*\n* @example\n* function compare( a, b ) {\n* if ( a > b ) {\n* return 1;\n* }\n* if ( a < b ) {\n* return -1;\n* }\n* return 0;\n* }\n*\n* var arr = new Float16Array( [ 2.0, 0.0, 1.0 ] );\n*\n* var out = arr.toSorted( compare );\n* // returns \n*\n* var v = out[ 0 ];\n* // returns 0.0\n*\n* v = out[ 1 ];\n* // returns 1.0\n*\n* v = out[ 2 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'toSorted', function toSorted( compareFcn ) {\n\tvar out;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tout = new this.constructor( this );\n\tif ( arguments.length === 0 ) {\n\t\treturn out.sort();\n\t}\n\treturn out.sort( compareFcn );\n});\n\n/**\n* Serializes an array as a string.\n*\n* @name toString\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {string} string representation\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var str = arr.toString();\n* // returns '0,1,2'\n*/\nsetReadOnly( Float16Array.prototype, 'toString', function toString() {\n\tvar out;\n\tvar buf;\n\tvar i;\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( fromWord( buf[ i ] ) );\n\t}\n\treturn out.join( ',' );\n});\n\n/**\n* Returns an iterator for iterating over each value in a typed array.\n*\n* @name values\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0 ] );\n*\n* var iter = arr.values();\n*\n* var v = iter.next().value;\n* // returns 0.0\n*\n* v = iter.next().value;\n* // returns 1.0\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'values', function values() {\n\tvar iter;\n\tvar self;\n\tvar len;\n\tvar FLG;\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tself = this;\n\tbuf = this._buffer;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': fromWord( buf[ i ] ),\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.values();\n\t}\n});\n\n/**\n* Returns a new typed array with the element at a provided index replaced with a provided value.\n*\n* @name with\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} index - element index\n* @param {number} value - new value\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be an integer\n* @throws {RangeError} index argument is out-of-bounds\n* @throws {TypeError} second argument must be a floating-point number\n* @returns {Float16Array} new typed array\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var out = arr.with( 0, 3.0 );\n* // returns \n*\n* var v = out[ 0 ];\n* // returns 3.0\n*/\nsetReadOnly( Float16Array.prototype, 'with', function copyWith( index, value ) {\n\tvar out;\n\tvar len;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isInteger( index ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', index ) );\n\t}\n\tlen = this._length;\n\tif ( index < 0 ) {\n\t\tindex += len;\n\t}\n\tif ( index < 0 || index >= len ) {\n\t\tthrow new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%s`.', index ) );\n\t}\n\tif ( !isNumber( value ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a number. Value: `%s`.', value ) );\n\t}\n\tout = new this.constructor( this );\n\tout[ index ] = value;\n\treturn out;\n});\n\n\n// EXPORTS //\n\nmodule.exports = Float16Array;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Float16Array === 'function' ) ? Float16Array : void 0; // eslint-disable-line no-undef, stdlib/require-globals\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* 16-bit floating-point number array constructor.\n*\n* @module @stdlib/array-float16\n*\n* @example\n* var Float16Array = require( '@stdlib/array-float16' );\n*\n* var arr = new Float16Array();\n* // returns \n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var Float16Array = require( '@stdlib/array-float16' );\n*\n* var arr = new Float16Array( 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var Float16Array = require( '@stdlib/array-float16' );\n*\n* var arr = new Float16Array( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var Float16Array = require( '@stdlib/array-float16' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float16Array( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 8\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var Float16Array = require( '@stdlib/array-float16' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float16Array( buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 4\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var Float16Array = require( '@stdlib/array-float16' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Float16Array( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\n\n// MODULES //\n\nvar hasFloat16ArraySupport = require( '@stdlib/assert-has-float16array-support' );\nvar polyfill = require( './polyfill' );\nvar builtin = require( './main.js' );\n\n\n// MAIN //\n\nvar ctor;\nif ( hasFloat16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n"], - "mappings": "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", - "names": ["require_from_array", "__commonJSMin", "exports", "module", "f16", "toWord", "fromArray", "buf", "arr", "len", "require_from_iterator", "__commonJSMin", "exports", "module", "f16", "toWord", "fromIterator", "it", "out", "v", "require_from_iterator_map", "__commonJSMin", "exports", "module", "f16", "toWord", "fromIteratorMap", "it", "clbk", "thisArg", "out", "v", "i", "require_polyfill", "__commonJSMin", "exports", "module", "hasIteratorSymbolSupport", "isNonNegativeInteger", "isStringArray", "isCollection", "isArrayBuffer", "isFunction", "isInteger", "isNumber", "isString", "isObject", "isnan", "ITERATOR_SYMBOL", "setReadOnlyAccessor", "setReadOnly", "setReadWriteAccessor", "floor", "format", "Uint16Array", "f16", "toWord", "fromWord", "gcopy", "fromArray", "fromIterator", "fromIteratorMap", "BYTES_PER_ELEMENT", "HAS_ITERATOR_SYMBOL", "isFloat16Array", "value", "isFloatingPointArrayConstructor", "Float16Array", "getter", "ctx", "idx", "get", "setter", "set", "byteOffset", "nargs", "buf", "len", "arg", "i", "src", "thisArg", "clbk", "out", "tmp", "args", "target", "start", "self", "iter", "FLG", "next", "end", "factory", "predicate", "v", "fcn", "searchElement", "fromIndex", "separator", "outbuf", "reducer", "initialValue", "acc", "N", "j", "sbuf", "flg", "begin", "outlen", "compareFcn", "defaultCompare", "compare", "a", "b", "x", "y", "offset", "locales", "options", "opts", "loc", "index", "require_main", "__commonJSMin", "exports", "module", "ctor", "hasFloat16ArraySupport", "polyfill", "builtin", "ctor"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index e311742..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,1222 +0,0 @@ - -{{alias}}() - A 16-bit half-precision floating-point number array. - - Returns - ------- - out: Float16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Creates a half-precision floating-point number array having a specified - length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: Float16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - - > var len = arr.length - 5 - - -{{alias}}( typedarray ) - Creates a half-precision floating-point number array from a typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate a half-precision floating-point - number array. - - Returns - ------- - out: Float16Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/float64}}( [ 0.5, 0.5, 0.5 ] ) - - > var arr = new {{alias}}( buf ) - - > var len = arr.length - 3 - - -{{alias}}( obj ) - Creates a half-precision floating-point number array from an array-like - object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a half-precision - floating-point number array. - - Returns - ------- - out: Float16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( [ 0.5, 0.5, 0.5 ] ) - - > var len = arr.length - 3 - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a half-precision floating-point number array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - Returns - ------- - out: Float16Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 8 ); - > var arr1 = new {{alias}}( buf ) - - > var len = arr1.length - 4 - > var arr2 = new {{alias}}( buf, 2 ) - - > len = arr2.length - 3 - > var arr3 = new {{alias}}( buf, 2, 2 ) - - > len = arr3.length - 2 - - -{{alias}}.from( src[, clbk[, thisArg]] ) - Creates a new half-precision floating-point number array from an array-like - object or an iterable. - - A callback function is provided two arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - clbk: Function (optional) - Callback to invoke for each source element. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Float16Array - A typed array. - - Examples - -------- - > function clbkFcn( v ) { return v * 2.0 }; - > var arr = {{alias}}.from( [ 1.0, -1.0 ], clbkFcn ) - - > var len = arr.length - 2 - > var v = arr[ 0 ] - 2.0 - > v = arr[ 1 ] - -2.0 - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new half-precision floating-point number array from a variable - number of arguments. - - Parameters - ---------- - element0: number - Array element. - - element1: number (optional) - Array element. - - elementN: ...number (optional) - Array elements. - - Returns - ------- - out: Float16Array - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( 1.0, -1.0 ) - - > var len = arr.length - 2 - > var v = arr[ 0 ] - 1.0 - > v = arr[ 1 ] - -1.0 - - -{{alias}}.BYTES_PER_ELEMENT - The size of each array element in bytes. - - Examples - -------- - > var nbytes = {{alias}}.BYTES_PER_ELEMENT - 2 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > var str = {{alias}}.name - 'Float16Array' - - -{{alias}}.prototype.buffer - Pointer to the underlying data buffer. - - Examples - -------- - > var arr = new {{alias}}( 2 ) - - > var buf = arr.buffer - - - -{{alias}}.prototype.byteLength - Length of the array in bytes. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - - > var nbytes = arr.byteLength - 10 - - -{{alias}}.prototype.byteOffset - Offset (in bytes) of the array from the start of its underlying ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - - > var offset = arr.byteOffset - 0 - > var buf = new {{alias:@stdlib/array/buffer}}( 20 ); - > arr = new {{alias}}( buf, 10 ) - - > offset = arr.byteOffset - 10 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each array element. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - - > arr.BYTES_PER_ELEMENT - 2 - - -{{alias}}.prototype.length - The number of array elements. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - - > var len = arr.length - 5 - - -{{alias}}.prototype.at( i ) - Returns an array element located at integer position (index) `i`, with - support for both nonnegative and negative integer positions. - - If provided an index outside the array index range, the method returns - `undefined`. - - Parameters - ---------- - i: integer - Element index. - - Returns - ------- - out: float|void - An array element. - - Examples - -------- - > var arr = new {{alias}}( [ 10.0, 20.0, 30.0 ] ) - - > var v = arr.at( 0 ) - 10.0 - > v = arr.at( -1 ) - 30.0 - - -{{alias}}.prototype.copyWithin( target, start[, end] ) - Copies a sequence of elements within the array starting at `start` and - ending at `end` (non-inclusive) to the position starting at `target`. - - Parameters - ---------- - target: integer - Target start index position. - - start: integer - Source start index position. - - end: integer (optional) - Source end index position. Default: out.length. - - Returns - ------- - out: Float16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ) - - > arr.copyWithin( 0, 3 ) - - > var v = arr[ 0 ] - 4.0 - > v = arr[ 1 ] - 5.0 - - -{{alias}}.prototype.entries() - Returns an iterator for iterating over array key-value pairs. - - Returns - ------- - iterator: Iterator - Iterator for iterating over array key-value pairs. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var it = arr.entries(); - > var v = it.next().value - [ 0, 1.0 ] - > v = it.next().value - [ 1, 2.0 ] - > v = it.next().value - [ 2, 3.0 ] - > var bool = it.next().done - true - - -{{alias}}.prototype.every( predicate[, thisArg] ) - Returns a boolean indicating whether all elements in the array pass a test. - - A predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether all elements pass the test. - - Examples - -------- - > function predicate( v ) { return ( v > 0.0 ); }; - > var arr = new {{alias}}( [ 1.0, 2.0 ] ) - - > var bool = arr.every( predicate ) - true - - -{{alias}}.prototype.fill( value[, start[, end]] ) - Returns a modified typed array filled with a fill value. - - Parameters - ---------- - value: number - Fill value. - - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Float16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( 3 ) - - > arr.fill( 2.0 ); - > var v = arr[ 0 ] - 2.0 - > v = arr[ 1 ] - 2.0 - > v = arr[ 2 ] - 2.0 - - -{{alias}}.prototype.filter( predicate[, thisArg] ) - Returns a new array containing the elements of an array which pass a test - implemented by a predicate function. - - A predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - The returned array has the same data type as the host array. - - Parameters - ---------- - predicate: Function - Predicate function which filters array elements. If a predicate function - returns a truthy value, an array element is included in the output - array; otherwise, an array element is not included in the output array. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - out: Float16Array - A new typed array. - - Examples - -------- - > function predicate( v ) { return ( v > 1.0 ); }; - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var out = arr.filter( predicate ) - - > var len = out.length - 2 - > var v = out[ 0 ] - 2.0 - > v = out[ 1 ] - 3.0 - - -{{alias}}.prototype.find( predicate[, thisArg] ) - Returns the first element in an array for which a predicate function - returns a truthy value. - - A predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - out: number|void - Array element or `undefined`. - - Examples - -------- - > function predicate( v ) { return ( v > 1.0 ); }; - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var v = arr.find( predicate ) - 2.0 - - -{{alias}}.prototype.findIndex( predicate[, thisArg] ) - Returns the index of the first element in an array for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - out: integer - Array index or `-1`. - - Examples - -------- - > function predicate( v ) { return ( v > 2.0 ); }; - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var idx = arr.findIndex( predicate ) - 2 - - -{{alias}}.prototype.findLast( predicate[, thisArg] ) - Returns the last element in an array for which a predicate function returns - a truthy value. - - A predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - out: number|void - Array element or `undefined`. - - Examples - -------- - > function predicate( v ) { return ( v > 1.0 ); }; - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var v = arr.findLast( predicate ) - 3.0 - - -{{alias}}.prototype.findLastIndex( predicate[, thisArg] ) - Returns the index of the last element in an array for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - out: integer - Array index or `-1`. - - Examples - -------- - > function predicate( v ) { return ( v > 1.0 ); }; - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var idx = arr.findLastIndex( predicate ) - 2 - - -{{alias}}.prototype.forEach( clbk[, thisArg] ) - Invokes a function once for each array element. - - A callback function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - Parameters - ---------- - clbk: Function - Function to invoke for each array element. - - thisArg: Any (optional) - Execution context. - - Examples - -------- - > var str = '%'; - > function clbk( v ) { str += v.toString() + '%'; }; - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > arr.forEach( clbk ); - > str - '%1%2%3%' - - -{{alias}}.prototype.includes( searchElement[, fromIndex] ) - Returns a boolean indicating whether an array includes a provided value. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index at which to start the search. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - bool: boolean - Boolean indicating whether an array includes a search element. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var bool = arr.includes( 3.0 ) - true - > bool = arr.includes( 3.0, 3 ) - false - - -{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) - Returns the first index at which a given element can be found. - - If method does not find a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index at which to start the search. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - out: integer - Array index or `-1`. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var idx = arr.indexOf( 2.0 ) - 1 - > idx = arr.indexOf( 2.0, 2 ) - -1 - - -{{alias}}.prototype.join( [separator] ) - Returns a new string by concatenating all array elements separated by a - separator string. - - Parameters - ---------- - separator: string (optional) - Separator string. Default: ','. - - Returns - ------- - out: string - Array serialized as a string. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var str = arr.join() - '1,2,3' - > str = arr.join( '|' ) - '1|2|3' - - -{{alias}}.prototype.keys() - Returns an iterator for iterating over each index key in a typed array. - - Returns - ------- - iterator: Iterator - Iterator for iterating over array index keys. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0 ] ) - - > var it = arr.keys(); - > var v = it.next().value - 0 - > v = it.next().value - 1 - > v = it.next().done - true - - -{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) - Returns the last index at which a given element can be found. - - If method does not find a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index at which to start the search. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: out.length-1. - - Returns - ------- - out: integer - Array index or `-1`. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0, 1.0 ] ) - - > var idx = arr.lastIndexOf( 1.0 ) - 3 - > idx = arr.lastIndexOf( 1.0, 2 ) - 0 - - -{{alias}}.prototype.map( clbk[, thisArg] ) - Returns a new array with each element being the result of a provided - callback function. - - A callback function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - The returned array has the same data type as the host array. - - Parameters - ---------- - clbk: Function - Function which maps array elements to elements in the new array. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - out: Float16Array - A new typed array. - - Examples - -------- - > function clbk( v ) { return v * 2.0; }; - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var out = arr.map( clbk ) - - > var v = out[ 0 ] - 2.0 - > v = out[ 1 ] - 4.0 - > v = out[ 2 ] - 6.0 - - -{{alias}}.prototype.reduce( reducerFn[, initialValue] ) - Applies a provided function to each element of the array, in order, passing - in the return value from the calculation on the preceding element and - returning the accumulated result upon completion. - - A reducer function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the first array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the first array element as the first argument and the second array - element as the second argument. - - Parameters - ---------- - reducerFn: Function - Function to apply to each array element. - - initialValue: any (optional) - Initial accumulation value. - - Returns - ------- - out: any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > function reducerFn( acc, v ) { return acc + v; }; - > var v = arr.reduce( reducerFn, 0.0 ) - 6.0 - - -{{alias}}.prototype.reduceRight( reducerFn[, initialValue] ) - Applies a provided function to each element of the array, in reverse order, - passing in the return value from the calculation on the preceding element - and returning the accumulated result upon completion. - - A reducer function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the last array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the last array element as the first argument and the second-to-last - array element as the second argument. - - Parameters - ---------- - reducerFn: Function - Function to apply to each array element. - - initialValue: any (optional) - Initial accumulation value. - - Returns - ------- - out: any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > function reducerFn( acc, v ) { return acc + v; }; - > var v = arr.reduceRight( reducerFn, 0.0 ) - 6.0 - - -{{alias}}.prototype.reverse() - Reverses the array *in-place*. - - This method mutates the array on which the method is invoked. - - Returns - ------- - out: Float16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > arr.reverse(); - > var v = arr[ 0 ] - 3.0 - > v = arr[ 1 ] - 2.0 - > v = arr[ 2 ] - 1.0 - - -{{alias}}.prototype.set( arr[, offset] ) - Sets one or more array elements. - - If provided a single argument, the method sets array elements starting at - position (index) `i = 0`. To set elements starting elsewhere in the array, - provide an offset argument. - - Parameters - ---------- - arr: ArrayLike - Source array containing array values to set. - - offset: integer (optional) - Array index at which to start writing values. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > arr.set( [ 4.0, 5.0 ], 1 ); - > var v = arr[ 0 ] - 1.0 - > v = arr[ 1 ] - 4.0 - > v = arr[ 2 ] - 5.0 - - -{{alias}}.prototype.slice( [start[, end]] ) - Copies a portion of a typed array to a new typed array. - - Parameters - ---------- - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Float16Array - New typed array. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var out = arr.slice( 1 ) - - > var len = out.length - 2 - > var v = out[ 0 ] - 2.0 - > v = out[ 1 ] - 3.0 - - -{{alias}}.prototype.some( predicate[, thisArg] ) - Returns a boolean indicating whether at least one element passes a test. - - A predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether at least one element passes the test. - - Examples - -------- - > function predicate( v ) { return ( v > 2.0 ); }; - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var bool = arr.some( predicate ) - true - - -{{alias}}.prototype.sort( [compareFunction] ) - Sorts an array in-place. - - A comparison function determines the order of the array elements. The - function is provided two arguments: - - - a: first element for comparison. - - b: second element for comparison. - - The function should return a value less than zero if `a` comes before `b`, - a value greater than zero if `a` comes after `b`, and zero if `a` and `b` - are equivalent. - - Parameters - ---------- - compareFunction: Function (optional) - Comparison function. - - Returns - ------- - out: Float16Array - Modified array. - - Examples - -------- - > function compare( a, b ) { return a - b; }; - > var arr = new {{alias}}( [ 2.0, 3.0, 1.0 ] ) - - > arr.sort( compare ); - > var v = arr[ 0 ] - 1.0 - > v = arr[ 1 ] - 2.0 - > v = arr[ 2 ] - 3.0 - - -{{alias}}.prototype.subarray( [begin[, end]] ) - Creates a new typed array view over the same underlying `ArrayBuffer` and - with the same underlying data type as the host array. - - Parameters - ---------- - begin: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Float16Array - New typed array view. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ) - - > var out = arr.subarray( 1, 3 ) - - > var len = out.length - 2 - > var v = out[ 0 ] - 2.0 - > v = out[ 1 ] - 3.0 - - -{{alias}}.prototype.toLocaleString( [locales[, options]] ) - Serializes an array as a locale-specific string. - - Parameters - ---------- - locales: string|Array (optional) - Locale identifier(s). - - options: Object (optional) - An object containing serialization options. - - Returns - ------- - str: string - Local-specific string. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var str = arr.toLocaleString() - '1,2,3' - - -{{alias}}.prototype.toReversed() - Returns a new typed array containing the elements in reversed order. - - Returns - ------- - out: Float16Array - New typed array. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var out = arr.toReversed() - - > var v = out[ 0 ] - 3.0 - > v = out[ 1 ] - 2.0 - > v = out[ 2 ] - 1.0 - - -{{alias}}.prototype.toSorted( [compareFcn] ) - Returns a new typed array containing the elements in sorted order. - - A comparison function determines the order of the array elements. The - function is provided two arguments: - - - a: first element for comparison. - - b: second element for comparison. - - The function should return a value less than zero if `a` comes before `b`, - a value greater than zero if `a` comes after `b`, and zero if `a` and `b` - are equivalent. - - Parameters - ---------- - compareFcn: Function (optional) - Comparison function. - - Returns - ------- - out: Float16Array - New typed array. - - Examples - -------- - > function compare( a, b ) { return a - b; }; - > var arr = new {{alias}}( [ 2.0, 3.0, 1.0 ] ) - - > var out = arr.toSorted( compare ); - > var v = out[ 0 ] - 1.0 - > v = out[ 1 ] - 2.0 - > v = out[ 2 ] - 3.0 - - -{{alias}}.prototype.toString() - Serializes an array as a string. - - Returns - ------- - str: string - String serialization of the array. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var str = arr.toString() - '1,2,3' - - -{{alias}}.prototype.values() - Returns an iterator for iterating over each value in a typed array. - - Returns - ------- - iterator: Iterator - Iterator for iterating over array values. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0 ] ) - - > var it = arr.values(); - > var v = it.next().value - 1.0 - > v = it.next().value - 2.0 - > var bool = it.next().done - true - - -{{alias}}.prototype.with( index, value ) - Returns a new typed array with the element at a provided index replaced with - a provided value. - - Parameters - ---------- - index: integer - Element index. - - value: number - Element value. - - Returns - ------- - out: Float16Array - New typed array. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var out = arr.with( 1, 4.0 ) - - > var v = out[ 1 ] - 4.0 - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 033057e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,129 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2026 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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ArrayBuffer = require( '@stdlib/array-buffer' ); -import Float16Array = require( './index' ); - -/** -* Callback function. -* -* @param v - value -* @returns input value -*/ -function clbk( v: number ): number { - return v; -} - - -// TESTS // - -// The function returns a half-precision floating-point number array... -{ - new Float16Array(); // $ExpectType Float16Array - new Float16Array( 2 ); // $ExpectType Float16Array - new Float16Array( [ 1.0, -1.0 ] ); // $ExpectType Float16Array - - const buf = new ArrayBuffer( 16 ); - new Float16Array( buf ); // $ExpectType Float16Array - new Float16Array( buf, 8 ); // $ExpectType Float16Array - new Float16Array( buf, 8, 2 ); // $ExpectType Float16Array -} - -// The compiler throws an error if the function is provided a first argument that is not a number, typed array, array-like object, or array buffer... -{ - new Float16Array( true ); // $ExpectError - new Float16Array( false ); // $ExpectError - new Float16Array( null ); // $ExpectError - new Float16Array( 'abc' ); // $ExpectError - new Float16Array( {} ); // $ExpectError - new Float16Array( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument that is not a number... -{ - const buf = new ArrayBuffer( 16 ); - new Float16Array( buf, true ); // $ExpectError - new Float16Array( buf, false ); // $ExpectError - new Float16Array( buf, null ); // $ExpectError - new Float16Array( buf, 'abc' ); // $ExpectError - new Float16Array( buf, {} ); // $ExpectError - new Float16Array( buf, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument that is not a number... -{ - const buf = new ArrayBuffer( 16 ); - new Float16Array( buf, 8, true ); // $ExpectError - new Float16Array( buf, 8, false ); // $ExpectError - new Float16Array( buf, 8, null ); // $ExpectError - new Float16Array( buf, 8, 'abc' ); // $ExpectError - new Float16Array( buf, 8, {} ); // $ExpectError - new Float16Array( buf, 8, ( x: number ): number => x ); // $ExpectError -} - -// The `from` method returns a half-precision floating-point number array... -{ - Float16Array.from( [ 1.0, 1.0 ] ); // $ExpectType Float16Array - Float16Array.from( [ 1.0, 1.0 ], ( x: number ): number => x * x ); // $ExpectType Float16Array - Float16Array.from( [ 1.0 ], clbk, {} ); // $ExpectType Float16Array -} - -// The compiler throws an error if the `from` method is provided a first argument which is not array-like or iterable... -{ - Float16Array.from( true ); // $ExpectError - Float16Array.from( false ); // $ExpectError - Float16Array.from( 123 ); // $ExpectError - Float16Array.from( null ); // $ExpectError - Float16Array.from( {} ); // $ExpectError - - Float16Array.from( true, clbk ); // $ExpectError - Float16Array.from( false, clbk ); // $ExpectError - Float16Array.from( 123, clbk ); // $ExpectError - Float16Array.from( null, clbk ); // $ExpectError - Float16Array.from( {}, clbk ); // $ExpectError - - Float16Array.from( true, clbk, {} ); // $ExpectError - Float16Array.from( false, clbk, {} ); // $ExpectError - Float16Array.from( 123, clbk, {} ); // $ExpectError - Float16Array.from( null, clbk, {} ); // $ExpectError - Float16Array.from( {}, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the `from` method is provided a second argument which is not a function with a supported signature... -{ - Float16Array.from( [ 1.0, 1.0 ], true ); // $ExpectError - Float16Array.from( [ 1.0, 1.0 ], false ); // $ExpectError - Float16Array.from( [ 1.0, 1.0 ], 123 ); // $ExpectError - Float16Array.from( [ 1.0, 1.0 ], null ); // $ExpectError - Float16Array.from( [ 1.0, 1.0 ], {} ); // $ExpectError -} - -// The `of` method returns a half-precision floating-point number array... -{ - Float16Array.of( 1.0, 1.0, 1.0, 1.0 ); // $ExpectType Float16Array -} - -// The compiler throws an error if the `of` method is provided arguments that are not numbers... -{ - Float16Array.of( 'abc', 'def' ); // $ExpectError - Float16Array.of( true, false ); // $ExpectError - Float16Array.of( {}, [] ); // $ExpectError - Float16Array.of( null, null ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a5c84ca..0000000 --- a/examples/index.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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'; - -var Uint16Array = require( '@stdlib/array-uint16' ); -var logEach = require( '@stdlib/console-log-each' ); -var Float16Array = require( './../lib' ); - -// Create a half-precision floating-point number array by specifying a length: -var out = new Float16Array( 3 ); -logEach( '%s', out ); - -// Create a half-precision floating-point number array from an array of numbers: -var arr = [ 1.05, 2.05, 3.05 ]; -out = new Float16Array( arr ); -logEach( '%s', out ); - -// Create a half-precision floating-point number array from an array buffer: -arr = new Uint16Array( [ 1000, 2000, 3000, 4000 ] ); -out = new Float16Array( arr.buffer ); -logEach( '%s', out ); - -// Create a half-precision floating-point number array from an array buffer view: -arr = new Uint16Array( [ 1000, 2000, 3000, 4000 ] ); -out = new Float16Array( arr.buffer, 2, 2 ); -logEach( '%s', out ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 001159c..ed52b06 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { Iterator as Iter, IterableIterator, TypedIterator } from '@stdlib/types/iter'; import { ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..e1ce965 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-float16array-support@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.3-esm/index.mjs";import{isPrimitive as n}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.3-esm/index.mjs";import{primitives as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string-array@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.3-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.3-esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.3-esm/index.mjs";import{isPrimitive as h}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.3-esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.3-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-assert-is-nan@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.4-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.3-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@v0.2.4-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint16@v0.2.3-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-float16@v0.1.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float16-base-to-word@v0.1.1-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float16-base-from-word@v0.2.1-esm/index.mjs";import T from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-base-gcopy@v0.2.3-esm/index.mjs";function _(t){var r,n;for(r=[];!(n=t.next()).done;)r.push(b(m(n.value)));return r}var j=g.BYTES_PER_ELEMENT,x=r();function L(t){return"object"==typeof t&&null!==t&&"Float16Array"===t.constructor.name&&t.BYTES_PER_ELEMENT===j}function R(t){return t===P}function O(t,r){return function(){return t._get(r)}}function A(t,r){return function(n){t.set([n],r)}}function P(){var t,r,i,h,l,u;if(r=arguments.length,!(this instanceof P))return 0===r?new P:1===r?new P(arguments[0]):2===r?new P(arguments[0],arguments[1]):new P(arguments[0],arguments[1],arguments[2]);if(0===r)i=new g(0);else if(1===r)if(n(l=arguments[0]))i=new g(l);else if(e(l))L(l)?(i=new g(l.length),T.ndarray(l.length,new g(l.buffer,l.byteOffset,l.length),1,0,i,1,0)):i=function(t,r){var n,i;for(n=r.length,i=0;ii.byteLength-t)throw new RangeError(d("null2G",h*j));i=new g(i,t,h)}}for(y(this,"_buffer",i),y(this,"_length",i.length),u=0;u1){if(!s(i=arguments[1]))throw new TypeError(d("null2H",i));n>2&&(r=arguments[2])}if(e(t)){if(i){for(f=(o=new this(l=t.length))._buffer,u=0;u=this._length))return E(this._buffer[t])})),w(P.prototype,"buffer",(function(){return this._buffer.buffer})),w(P.prototype,"byteLength",(function(){return this._buffer.byteLength})),w(P.prototype,"byteOffset",(function(){return this._buffer.byteOffset})),y(P.prototype,"BYTES_PER_ELEMENT",P.BYTES_PER_ELEMENT),y(P.prototype,"copyWithin",(function(t,r){if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");return 2===arguments.length?this._buffer.copyWithin(t,r):this._buffer.copyWithin(t,r,arguments[2]),this})),y(P.prototype,"entries",(function(){var t,r,n,i,e,o;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");return t=this,i=this._buffer,n=this._length,o=-1,y(r={},"next",(function(){if(o+=1,e||o>=n)return{done:!0};return{value:[o,E(i[o])],done:!1}})),y(r,"return",(function(t){if(e=!0,arguments.length)return{value:t,done:!0};return{done:!0}})),p&&y(r,p,(function(){return t.entries()})),r})),y(P.prototype,"every",(function(t,r){var n,i;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!s(t))throw new TypeError(d("null3c",t));for(n=this._buffer,i=0;i1){if(!f(r))throw new TypeError(d("null7f",r));if(r<0&&(r+=e)<0&&(r=0),arguments.length>2){if(!f(n))throw new TypeError(d("null2z",n));n<0&&(n+=e)<0&&(n=0),n>e&&(n=e)}else n=e}else r=0,n=e;for(s=b(t),o=r;o=0;e--)if(i=E(n[e]),t.call(r,i,e,this))return i})),y(P.prototype,"findLastIndex",(function(t,r){var n,i,e;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!s(t))throw new TypeError(d("null3c",t));for(n=this._buffer,e=this._length-1;e>=0;e--)if(i=E(n[e]),t.call(r,i,e,this))return e;return-1})),y(P.prototype,"forEach",(function(t,r){var n,i;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!s(t))throw new TypeError(d("null3c",t));for(n=this._buffer,i=0;i=this._length))return E(this._buffer[t])})),y(P.prototype,"includes",(function(t,r){var n,i,e;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!h(t))throw new TypeError(d("null49",t));if(arguments.length>1){if(!f(r))throw new TypeError(d("null7f",r));r<0&&(r+=this._length)<0&&(r=0)}else r=0;for(n=this._buffer,e=b(t),i=r;i1){if(!f(r))throw new TypeError(d("null7f",r));r<0&&(r+=this._length)<0&&(r=0)}else r=0;for(n=this._buffer,e=b(t),i=r;i0){if(!l(t))throw new TypeError(d("null3F",t))}else t=",";for(r=this._buffer,n=[],i=0;i=n)return{done:!0};return{value:e,done:!1}})),y(r,"return",(function(t){if(i=!0,arguments.length)return{value:t,done:!0};return{done:!0}})),p&&y(r,p,(function(){return t.keys()})),r})),y(P.prototype,"lastIndexOf",(function(t,r){var n,i,e;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!h(t))throw new TypeError(d("null49",t));if(arguments.length>1){if(!f(r))throw new TypeError(d("null7f",r));r>=this._length?r=this._length-1:r<0&&(r+=this._length)}else r=this._length-1;for(n=this._buffer,e=b(t),i=r;i>=0;i--)if(e===n[i])return i;return-1})),w(P.prototype,"length",(function(){return this._length})),y(P.prototype,"map",(function(t,r){var n,i,e,o;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!s(t))throw new TypeError(d("null3c"),t);for(e=this._buffer,n=(i=new this.constructor(this._length))._buffer,o=0;o1)e=r,o=0;else{if(0===i)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");e=E(n[0]),o=1}for(;o1)e=r,o=i-1;else{if(0===i)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");e=E(n[i-1]),o=i-2}for(;o>=0;o--)e=t(e,E(n[o]),o,this);return e})),y(P.prototype,"reverse",(function(){var t,r,n,i,e,o;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");for(t=this._buffer,n=this._length,i=v(n/2),e=0;e1){if(!n(i=arguments[1]))throw new TypeError(d("null2L",i))}else i=0;if(i+(h=t.length)>this._length)throw new RangeError(d("null03"));if(L(t)?(r=t._buffer,f=!0):(r=t,f=!1),a=o.byteOffset+i*j,r.buffer===o.buffer&&r.byteOffseta){for(s=new g(r.length),l=0;ls&&(r=s)}}for(n=ti)return 1;return 0})),this;if(!s(t))throw new TypeError(d("null3c",t));return r.sort((function(r,n){return t(E(r),E(n))})),this})),y(P.prototype,"subarray",(function(t,r){var n,i,e;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(i=this._buffer,e=this._length,0===arguments.length)t=0,r=e;else{if(!f(t))throw new TypeError(d("null7e",t));if(t<0&&(t+=e)<0&&(t=0),1===arguments.length)r=e;else{if(!f(r))throw new TypeError(d("null7f",r));r<0?(r+=e)<0&&(r=0):r>e&&(r=e)}}return t>=e?(e=0,n=i.byteLength):t>=r?(e=0,n=i.byteOffset+t*j):(e=r-t,n=i.byteOffset+t*j),new this.constructor(i.buffer,n,e<0?0:e)})),y(P.prototype,"toLocaleString",(function(t,r){var n,e,o,s,f;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(0===arguments.length)e=[];else{if(!l(t)&&!i(t))throw new TypeError(d("invalid argument. First argument must be a string or an array of strings. Value: `%s`.",t));e=t}if(arguments.length<2)n={};else{if(!a(r))throw new TypeError(d("null2V",r));n=r}for(s=this._buffer,o=[],f=0;f=n)return{done:!0};return{value:E(e[o]),done:!1}})),y(t,"return",(function(t){if(i=!0,arguments.length)return{value:t,done:!0};return{done:!0}})),p&&y(t,p,(function(){return r.values()})),t})),y(P.prototype,"with",(function(t,r){var n,i;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!f(t))throw new TypeError(d("null7e",t));if(i=this._length,t<0&&(t+=i),t<0||t>=i)throw new RangeError(d("nullFP",t));if(!h(r))throw new TypeError(d("null4A",r));return(n=new this.constructor(this))[t]=r,n}));var S="function"==typeof Float16Array?Float16Array:void 0,F=t()?S:P;export{F as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..1b08c57 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/polyfill/from_iterator.js","../lib/polyfill/index.js","../lib/polyfill/from_array.js","../lib/polyfill/from_iterator_map.js","../lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport f16 from '@stdlib/number-float64-base-to-float16';\nimport toWord from '@stdlib/number-float16-base-to-word';\n\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @returns {Array} output array\n*/\nfunction fromIterator( it ) {\n\tvar out;\n\tvar v;\n\n\tout = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tout.push( toWord( f16( v.value ) ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIterator;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this, stdlib/jsdoc-typedef-typos, max-lines */\n\n'use strict';\n\n// MODULES //\n\nimport hasIteratorSymbolSupport from '@stdlib/assert-has-iterator-symbol-support';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport { primitives as isStringArray } from '@stdlib/assert-is-string-array';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isFunction from '@stdlib/assert-is-function';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isObject from '@stdlib/assert-is-object';\nimport isnan from '@stdlib/math-base-assert-is-nan';\nimport ITERATOR_SYMBOL from '@stdlib/symbol-iterator';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadWriteAccessor from '@stdlib/utils-define-read-write-accessor';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport Uint16Array from '@stdlib/array-uint16';\nimport f16 from '@stdlib/number-float64-base-to-float16';\nimport toWord from '@stdlib/number-float16-base-to-word';\nimport fromWord from '@stdlib/number-float16-base-from-word';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport fromArray from './from_array.js';\nimport fromIterator from './from_iterator.js';\nimport fromIteratorMap from './from_iterator_map.js';\n\n\n// VARIABLES //\n\nvar BYTES_PER_ELEMENT = Uint16Array.BYTES_PER_ELEMENT;\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\n\n\n// FUNCTIONS //\n\n/**\n* Returns a boolean indicating if a value is a `Float16Array`.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `Float16Array`\n*/\nfunction isFloat16Array( value ) {\n\treturn (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\tvalue.constructor.name === 'Float16Array' &&\n\t\tvalue.BYTES_PER_ELEMENT === BYTES_PER_ELEMENT\n\t);\n}\n\n/**\n* Returns a boolean indicating if a value is a floating-point typed array constructor.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a floating-point typed array constructor\n*/\nfunction isFloatingPointArrayConstructor( value ) { // eslint-disable-line id-length\n\treturn ( value === Float16Array );\n}\n\n/**\n* Returns a getter.\n*\n* @private\n* @param {Float16Array} ctx - typed array instance\n* @param {NonNegativeInteger} idx - element index\n* @returns {Function} getter\n*/\nfunction getter( ctx, idx ) {\n\treturn get;\n\n\t/**\n\t* Returns an array element.\n\t*\n\t* @private\n\t* @returns {(number|void)} array element\n\t*/\n\tfunction get() {\n\t\treturn ctx._get( idx ); // eslint-disable-line no-underscore-dangle\n\t}\n}\n\n/**\n* Returns a setter.\n*\n* @private\n* @param {Float16Array} ctx - typed array instance\n* @param {NonNegativeInteger} idx - element index\n* @returns {Function} setter\n*/\nfunction setter( ctx, idx ) {\n\treturn set;\n\n\t/**\n\t* Sets an array element.\n\t*\n\t* @private\n\t* @param {number} value - value to set\n\t*/\n\tfunction set( value ) {\n\t\tctx.set( [ value ], idx );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* 16-bit floating-point number array constructor.\n*\n* @constructor\n* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable\n* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n* @param {NonNegativeInteger} [length] - view length\n* @throws {RangeError} ArrayBuffer byte length must be a multiple of `2`\n* @throws {TypeError} if provided only a single argument, must provide a valid argument\n* @throws {TypeError} byte offset must be a nonnegative integer\n* @throws {RangeError} byte offset must be a multiple of `2`\n* @throws {TypeError} view length must be a positive multiple of `2`\n* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n* @returns {Float16Array} half-precision floating-point number array\n*\n* @example\n* var arr = new Float16Array();\n* // returns \n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var arr = new Float16Array( 5 );\n* // returns \n*\n* var len = arr.length;\n* // returns 5\n*\n* @example\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 5\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float16Array( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 8\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float16Array( buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 4\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Float16Array( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nfunction Float16Array() {\n\tvar byteOffset;\n\tvar nargs;\n\tvar buf;\n\tvar len;\n\tvar arg;\n\tvar i;\n\n\tnargs = arguments.length;\n\tif ( !(this instanceof Float16Array) ) {\n\t\tif ( nargs === 0 ) {\n\t\t\treturn new Float16Array();\n\t\t}\n\t\tif ( nargs === 1 ) {\n\t\t\treturn new Float16Array( arguments[0] );\n\t\t}\n\t\tif ( nargs === 2 ) {\n\t\t\treturn new Float16Array( arguments[0], arguments[1] );\n\t\t}\n\t\treturn new Float16Array( arguments[0], arguments[1], arguments[2] );\n\t}\n\t// Create the underlying data buffer...\n\tif ( nargs === 0 ) {\n\t\tbuf = new Uint16Array( 0 ); // backward-compatibility\n\t} else if ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\t\tif ( isNonNegativeInteger( arg ) ) {\n\t\t\tbuf = new Uint16Array( arg );\n\t\t} else if ( isCollection( arg ) ) {\n\t\t\tif ( isFloat16Array( arg ) ) {\n\t\t\t\tbuf = new Uint16Array( arg.length );\n\t\t\t\tgcopy.ndarray( arg.length, new Uint16Array( arg.buffer, arg.byteOffset, arg.length ), 1, 0, buf, 1, 0 ); // eslint-disable-line max-len\n\t\t\t} else {\n\t\t\t\tbuf = fromArray( new Uint16Array( arg.length ), arg );\n\t\t\t}\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tif ( !isInteger( arg.byteLength/BYTES_PER_ELEMENT ) ) {\n\t\t\t\tthrow new RangeError( format( 'nullE9', BYTES_PER_ELEMENT, arg.byteLength ) );\n\t\t\t}\n\t\t\tbuf = new Uint16Array( arg );\n\t\t} else if ( isObject( arg ) ) {\n\t\t\tif ( HAS_ITERATOR_SYMBOL === false ) {\n\t\t\t\tthrow new TypeError( format( 'null29', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2A', arg ) );\n\t\t\t}\n\t\t\tbuf = arg[ ITERATOR_SYMBOL ]();\n\t\t\tif ( !isFunction( buf.next ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2A', arg ) );\n\t\t\t}\n\t\t\tbuf = new Uint16Array( fromIterator( buf ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( 'null2A', arg ) );\n\t\t}\n\t} else {\n\t\tbuf = arguments[ 0 ];\n\t\tif ( !isArrayBuffer( buf ) ) {\n\t\t\tthrow new TypeError( format( 'null2B', buf ) );\n\t\t}\n\t\tbyteOffset = arguments[ 1 ];\n\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\tthrow new TypeError( format( 'null2C', byteOffset ) );\n\t\t}\n\t\tif ( !isInteger( byteOffset/BYTES_PER_ELEMENT ) ) {\n\t\t\tthrow new RangeError( format( 'nullEA', BYTES_PER_ELEMENT, byteOffset ) );\n\t\t}\n\t\tif ( nargs === 2 ) {\n\t\t\tlen = buf.byteLength - byteOffset;\n\t\t\tif ( !isInteger( len/BYTES_PER_ELEMENT ) ) {\n\t\t\t\tthrow new RangeError( format( 'null2E', BYTES_PER_ELEMENT, len ) );\n\t\t\t}\n\t\t\tbuf = new Uint16Array( buf, byteOffset );\n\t\t} else {\n\t\t\tlen = arguments[ 2 ];\n\t\t\tif ( !isNonNegativeInteger( len ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2F', len ) );\n\t\t\t}\n\t\t\tif ( (len*BYTES_PER_ELEMENT) > (buf.byteLength-byteOffset) ) {\n\t\t\t\tthrow new RangeError( format( 'null2G', len*BYTES_PER_ELEMENT ) );\n\t\t\t}\n\t\t\tbuf = new Uint16Array( buf, byteOffset, len );\n\t\t}\n\t}\n\tsetReadOnly( this, '_buffer', buf );\n\tsetReadOnly( this, '_length', buf.length );\n\tfor ( i = 0; i < buf.length; i++ ) {\n\t\tsetReadWriteAccessor( this, i, getter( this, i ), setter( this, i ) );\n\t}\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each array element.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Float16Array\n* @readonly\n* @type {PositiveInteger}\n* @default 2\n*\n* @example\n* var nbytes = Float16Array.BYTES_PER_ELEMENT;\n* // returns 2\n*/\nsetReadOnly( Float16Array, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT );\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof Float16Array\n* @readonly\n* @type {string}\n* @default 'Float16Array'\n*\n* @example\n* var str = Float16Array.name;\n* // returns 'Float16Array'\n*/\nsetReadOnly( Float16Array, 'name', 'Float16Array' );\n\n/**\n* Creates a new 16-bit floating-point number array from an array-like object or an iterable.\n*\n* @name from\n* @memberof Float16Array\n* @type {Function}\n* @param {(Collection|Iterable)} src - array-like object or iterable\n* @param {Function} [clbk] - callback to invoke for each source element\n* @param {*} [thisArg] - context\n* @throws {TypeError} `this` context must be a constructor\n* @throws {TypeError} `this` must be a floating-point array\n* @throws {TypeError} first argument must be an array-like object or an iterable\n* @throws {TypeError} second argument must be a function\n* @returns {Float16Array} half-precision floating-point number array\n*\n* @example\n* var arr = Float16Array.from( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* function clbk( v ) {\n* return v * 2.0;\n* }\n*\n* var arr = Float16Array.from( [ 1.0, 2.0 ], clbk );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nsetReadOnly( Float16Array, 'from', function from( src ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar clbk;\n\tvar out;\n\tvar buf;\n\tvar tmp;\n\tvar len;\n\tvar i;\n\tif ( !isFunction( this ) ) {\n\t\tthrow new TypeError( format('null01') );\n\t}\n\tif ( !isFloatingPointArrayConstructor( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs > 1 ) {\n\t\tclbk = arguments[ 1 ];\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'null2H', clbk ) );\n\t\t}\n\t\tif ( nargs > 2 ) {\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( isCollection( src ) ) {\n\t\tif ( clbk ) {\n\t\t\tlen = src.length;\n\t\t\tout = new this( len );\n\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tbuf[ i ] = toWord( f16( clbk.call( thisArg, src[ i ], i ) ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\treturn new this( src );\n\t}\n\tif ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) { // eslint-disable-line max-len\n\t\tbuf = src[ ITERATOR_SYMBOL ]();\n\t\tif ( !isFunction( buf.next ) ) {\n\t\t\tthrow new TypeError( format( 'null2J', src ) );\n\t\t}\n\t\tif ( clbk ) {\n\t\t\ttmp = fromIteratorMap( buf, clbk, thisArg );\n\t\t} else {\n\t\t\ttmp = fromIterator( buf );\n\t\t}\n\t\tif ( tmp instanceof Error ) {\n\t\t\tthrow tmp;\n\t\t}\n\t\tlen = tmp.length;\n\t\tout = new this( len );\n\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tbuf[ i ] = tmp[ i ];\n\t\t}\n\t\treturn out;\n\t}\n\tthrow new TypeError( format( 'null2J', src ) );\n});\n\n/**\n* Creates a new 16-bit floating-point number array from a variable number of arguments.\n*\n* @name of\n* @memberof Float16Array\n* @type {Function}\n* @param {...*} element - array elements\n* @throws {TypeError} `this` context must be a constructor\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Float16Array} half-precision floating-point number array\n*\n* @example\n* var arr = Float16Array.of( 1.0, 1.0, 1.0, 1.0 );\n* // returns \n*\n* var x = arr[ 0 ];\n* // returns 1.0\n*\n* var len = arr.length;\n* // returns 4\n*/\nsetReadOnly( Float16Array, 'of', function of() {\n\tvar args;\n\tvar i;\n\tif ( !isFunction( this ) ) {\n\t\tthrow new TypeError( format('null01') );\n\t}\n\tif ( !isFloatingPointArrayConstructor( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\targs = [];\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\targs.push( arguments[ i ] );\n\t}\n\treturn new this( args );\n});\n\n/**\n* Returns an array element with support for both nonnegative and negative integer indices.\n*\n* @name at\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} must provide an integer\n* @returns {(number|void)} array element\n*\n* @example\n* var arr = new Float16Array( [ 10.0, 20.0, 30.0 ] );\n*\n* var v = arr.at( 0 );\n* // returns 10.0\n*\n* v = arr.at( -1 );\n* // returns 30.0\n*\n* v = arr.at( 100 );\n* // returns undefined\n*/\nsetReadOnly( Float16Array.prototype, 'at', function at( idx ) {\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'null8A', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += this._length;\n\t}\n\tif ( idx < 0 || idx >= this._length ) {\n\t\treturn;\n\t}\n\treturn fromWord( this._buffer[ idx ] );\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name buffer\n* @memberof Float16Array.prototype\n* @readonly\n* @type {ArrayBuffer}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var buf = arr.buffer;\n* // returns \n*/\nsetReadOnlyAccessor( Float16Array.prototype, 'buffer', function get() {\n\treturn this._buffer.buffer;\n});\n\n/**\n* Size (in bytes) of the array.\n*\n* @name byteLength\n* @memberof Float16Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var byteLength = arr.byteLength;\n* // returns 20\n*/\nsetReadOnlyAccessor( Float16Array.prototype, 'byteLength', function get() {\n\treturn this._buffer.byteLength;\n});\n\n/**\n* Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`.\n*\n* @name byteOffset\n* @memberof Float16Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var byteOffset = arr.byteOffset;\n* // returns 0\n*/\nsetReadOnlyAccessor( Float16Array.prototype, 'byteOffset', function get() {\n\treturn this._buffer.byteOffset;\n});\n\n/**\n* Size (in bytes) of each array element.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Float16Array.prototype\n* @readonly\n* @type {PositiveInteger}\n* @default 2\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var nbytes = arr.BYTES_PER_ELEMENT;\n* // returns 2\n*/\nsetReadOnly( Float16Array.prototype, 'BYTES_PER_ELEMENT', Float16Array.BYTES_PER_ELEMENT );\n\n/**\n* Copies a sequence of elements within the array to the position starting at `target`.\n*\n* @name copyWithin\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} target - index at which to start copying elements\n* @param {integer} start - source index at which to copy elements from\n* @param {integer} [end] - source index at which to stop copying elements from\n* @throws {TypeError} `this` must be a floating-point array\n* @returns {Float16Array} modified array\n*\n* @example\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0 ] );\n*\n* // Copy the first two elements to the last two elements:\n* arr.copyWithin( 2, 0, 2 );\n*\n* var v = arr[ 2 ];\n* // returns 1.0\n*\n* v = arr[ 3 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'copyWithin', function copyWithin( target, start ) {\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\t// FIXME: prefer a functional `copyWithin` implementation which addresses lack of universal browser support (e.g., IE11 and Safari) or ensure that typed arrays are polyfilled\n\tif ( arguments.length === 2 ) {\n\t\tthis._buffer.copyWithin( target, start );\n\t} else {\n\t\tthis._buffer.copyWithin( target, start, arguments[2] );\n\t}\n\treturn this;\n});\n\n/**\n* Returns an iterator for iterating over array key-value pairs.\n*\n* @name entries\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] );\n*\n* var it = arr.entries();\n*\n* var v = it.next().value;\n* // returns [ 0, 1.0 ]\n*\n* v = it.next().value;\n* // returns [ 1, 2.0 ]\n*\n* v = it.next().value;\n* // returns [ 2, 3.0 ]\n*\n* var bool = it.next().done;\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'entries', function entries() {\n\tvar self;\n\tvar iter;\n\tvar len;\n\tvar buf;\n\tvar FLG;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tself = this;\n\tbuf = this._buffer;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': [ i, fromWord( buf[ i ] ) ],\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.entries();\n\t}\n});\n\n/**\n* Tests whether all elements in an array pass a test implemented by a predicate function.\n*\n* @name every\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {boolean} boolean indicating whether all elements pass a test\n*\n* @example\n* function predicate( v ) {\n* return v === 0.0;\n* }\n*\n* var arr = new Float16Array( 3 );\n*\n* var bool = arr.every( predicate );\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'every', function every( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( !predicate.call( thisArg, fromWord( buf[ i ] ), i, this ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n});\n\n/**\n* Returns a modified typed array filled with a fill value.\n*\n* @name fill\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {number} value - fill value\n* @param {integer} [start=0] - starting index (inclusive)\n* @param {integer} [end] - ending index (exclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a floating-point number\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be an integer\n* @returns {Float16Array} modified array\n*\n* @example\n* var arr = new Float16Array( 3 );\n*\n* arr.fill( 1.0, 1 );\n*\n* var v = arr[ 0 ];\n* // returns 0.0\n*\n* v = arr[ 1 ];\n* // returns 1.0\n*\n* v = arr[ 2 ];\n* // returns 1.0\n*/\nsetReadOnly( Float16Array.prototype, 'fill', function fill( value, start, end ) {\n\tvar buf;\n\tvar len;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNumber( value ) ) {\n\t\tthrow new TypeError( format( 'null49', value ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( start ) ) {\n\t\t\tthrow new TypeError( format( 'null7f', start ) );\n\t\t}\n\t\tif ( start < 0 ) {\n\t\t\tstart += len;\n\t\t\tif ( start < 0 ) {\n\t\t\t\tstart = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length > 2 ) {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2z', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t} else {\n\t\t\tend = len;\n\t\t}\n\t} else {\n\t\tstart = 0;\n\t\tend = len;\n\t}\n\tv = toWord( value );\n\tfor ( i = start; i < end; i++ ) {\n\t\tbuf[ i ] = v;\n\t}\n\treturn this;\n});\n\n/**\n* Returns a new array containing the elements of an array which pass a test implemented by a predicate function.\n*\n* @name filter\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {Float16Array} floating-point number array\n*\n* @example\n* function predicate( v ) {\n* return ( v === 0.0 );\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] );\n*\n* var out = arr.filter( predicate );\n* // returns \n*\n* var len = out.length;\n* // returns 2\n*\n* var v = out[ 0 ];\n* // returns 0.0\n*\n* v = out[ 1 ];\n* // returns 0.0\n*/\nsetReadOnly( Float16Array.prototype, 'filter', function filter( predicate, thisArg ) {\n\tvar buf;\n\tvar out;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\tout.push( v );\n\t\t}\n\t}\n\treturn new this.constructor( out );\n});\n\n/**\n* Returns the first element in an array for which a predicate function returns a truthy value.\n*\n* @name find\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {(boolean|void)} array element or undefined\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] );\n*\n* var v = arr.find( predicate );\n* // returns 1.0\n*/\nsetReadOnly( Float16Array.prototype, 'find', function find( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn v;\n\t\t}\n\t}\n});\n\n/**\n* Returns the index of the first element in an array for which a predicate function returns a truthy value.\n*\n* @name findIndex\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {integer} index or -1\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var v = arr.findIndex( predicate );\n* // returns 1\n*/\nsetReadOnly( Float16Array.prototype, 'findIndex', function findIndex( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Returns the last element in an array for which a predicate function returns a truthy value.\n*\n* @name findLast\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {(boolean|void)} array element or undefined\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] );\n*\n* var v = arr.findLast( predicate );\n* // returns 1.0\n*/\nsetReadOnly( Float16Array.prototype, 'findLast', function findLast( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = this._length-1; i >= 0; i-- ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn v;\n\t\t}\n\t}\n});\n\n/**\n* Returns the index of the last element in an array for which a predicate function returns a truthy value.\n*\n* @name findLastIndex\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {integer} index or -1\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] );\n*\n* var v = arr.findLastIndex( predicate );\n* // returns 1\n*/\nsetReadOnly( Float16Array.prototype, 'findLastIndex', function findLastIndex( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = this._length-1; i >= 0; i-- ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Invokes a function once for each array element.\n*\n* @name forEach\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} fcn - function to invoke\n* @param {*} [thisArg] - function invocation context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n*\n* @example\n* function log( v, i ) {\n* console.log( '%s: %s', i, v.toString() );\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* arr.forEach( log );\n*/\nsetReadOnly( Float16Array.prototype, 'forEach', function forEach( fcn, thisArg ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( fcn ) ) {\n\t\tthrow new TypeError( format( 'null3c', fcn ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tfcn.call( thisArg, fromWord( buf[ i ] ), i, this );\n\t}\n});\n\n/**\n* Returns an array element.\n*\n* @private\n* @name _get\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {NonNegativeInteger} idx - element index\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} must provide a nonnegative integer\n* @returns {(number|void)} array element\n*/\nsetReadOnly( Float16Array.prototype, '_get', function get( idx ) {\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNonNegativeInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'null2K', idx ) );\n\t}\n\tif ( idx >= this._length ) {\n\t\treturn;\n\t}\n\treturn fromWord( this._buffer[ idx ] );\n});\n\n/**\n* Returns a boolean indicating whether an array includes a provided value.\n*\n* @name includes\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {number} searchElement - search element\n* @param {integer} [fromIndex=0] - starting index (inclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a floating-point number\n* @throws {TypeError} second argument must be an integer\n* @returns {boolean} boolean indicating whether an array includes a value\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] );\n*\n* var bool = arr.includes( 1.0 );\n* // returns true\n*\n* bool = arr.includes( 1.0, 2 );\n* // returns false\n*\n* bool = arr.includes( 5.0 );\n* // returns false\n*/\nsetReadOnly( Float16Array.prototype, 'includes', function includes( searchElement, fromIndex ) {\n\tvar buf;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNumber( searchElement ) ) {\n\t\tthrow new TypeError( format( 'null49', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'null7f', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\tfromIndex = 0;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfromIndex = 0;\n\t}\n\tbuf = this._buffer;\n\tv = toWord( searchElement );\n\tfor ( i = fromIndex; i < this._length; i++ ) {\n\t\tif ( v === buf[ i ] ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n});\n\n/**\n* Returns the first index at which a given element can be found.\n*\n* @name indexOf\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {float16} searchElement - element to find\n* @param {integer} [fromIndex=0] - starting index (inclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a floating-point number\n* @throws {TypeError} second argument must be an integer\n* @returns {integer} index or -1\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] );\n*\n* var idx = arr.indexOf( 2.0 );\n* // returns 2\n*\n* idx = arr.indexOf( 2.0, 3 );\n* // returns -1\n*\n* idx = arr.indexOf( 3.0, 3 );\n* // returns 3\n*/\nsetReadOnly( Float16Array.prototype, 'indexOf', function indexOf( searchElement, fromIndex ) {\n\tvar buf;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNumber( searchElement ) ) {\n\t\tthrow new TypeError( format( 'null49', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'null7f', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\tfromIndex = 0;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfromIndex = 0;\n\t}\n\tbuf = this._buffer;\n\tv = toWord( searchElement );\n\tfor ( i = fromIndex; i < this._length; i++ ) {\n\t\tif ( v === buf[ i ] ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Returns a new string by concatenating all array elements.\n*\n* @name join\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {string} [separator=','] - element separator\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a string\n* @returns {string} string representation\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var str = arr.join();\n* // returns '0,1,2'\n*\n* str = arr.join( '|' );\n* // returns '0|1|2'\n*/\nsetReadOnly( Float16Array.prototype, 'join', function join( separator ) {\n\tvar buf;\n\tvar out;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( arguments.length > 0 ) {\n\t\tif ( !isString( separator ) ) {\n\t\t\tthrow new TypeError( format( 'null3F', separator ) );\n\t\t}\n\t} else {\n\t\tseparator = ',';\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( fromWord( buf[ i ] ) );\n\t}\n\treturn out.join( separator );\n});\n\n/**\n* Returns an iterator for iterating over each index key in a typed array.\n*\n* @name keys\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new Float16Array( [ 1.0, 2.0 ] );\n*\n* var iter = arr.keys();\n*\n* var v = iter.next().value;\n* // returns 0\n*\n* v = iter.next().value;\n* // returns 1\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'keys', function keys() {\n\tvar self;\n\tvar iter;\n\tvar len;\n\tvar FLG;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tself = this;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': i,\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.keys();\n\t}\n});\n\n/**\n* Returns the last index at which a given element can be found.\n*\n* @name lastIndexOf\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {number} searchElement - element to find\n* @param {integer} [fromIndex] - starting index (inclusive)\n* @throws {TypeError} `this` must be a floating-point number\n* @throws {TypeError} first argument must be a numeric value\n* @throws {TypeError} second argument must be an integer\n* @returns {integer} index or -1\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 2.0 ] );\n*\n* var idx = arr.lastIndexOf( 2.0 );\n* // returns 4\n*\n* idx = arr.lastIndexOf( 2.0, 3 );\n* // returns 2\n*\n* idx = arr.lastIndexOf( 4.0, 3 );\n* // returns -1\n*\n* idx = arr.lastIndexOf( 1.0, -3 );\n* // returns 1\n*/\nsetReadOnly( Float16Array.prototype, 'lastIndexOf', function lastIndexOf( searchElement, fromIndex ) {\n\tvar buf;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNumber( searchElement ) ) {\n\t\tthrow new TypeError( format( 'null49', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'null7f', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex >= this._length ) {\n\t\t\tfromIndex = this._length - 1;\n\t\t} else if ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t}\n\t} else {\n\t\tfromIndex = this._length - 1;\n\t}\n\tbuf = this._buffer;\n\tv = toWord( searchElement );\n\tfor ( i = fromIndex; i >= 0; i-- ) {\n\t\tif ( v === buf[ i ] ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Number of array elements.\n*\n* @name length\n* @memberof Float16Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var len = arr.length;\n* // returns 10\n*/\nsetReadOnlyAccessor( Float16Array.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Returns a new array with each element being the result of a provided callback function.\n*\n* @name map\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} fcn - callback function\n* @param {*} [thisArg] - callback function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {Float16Array} new floating-point number array\n*\n* @example\n* function scale( v ) {\n* return v * 2.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var out = arr.map( scale );\n* // returns \n*\n* var z = out[ 0 ];\n* // returns 0.0\n*\n* z = out[ 1 ];\n* // returns 2.0\n*\n* z = out[ 2 ];\n* // returns 4.0\n*/\nsetReadOnly( Float16Array.prototype, 'map', function map( fcn, thisArg ) {\n\tvar outbuf;\n\tvar out;\n\tvar buf;\n\tvar i;\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( fcn ) ) {\n\t\tthrow new TypeError( format('null3c'), fcn );\n\t}\n\tbuf = this._buffer;\n\tout = new this.constructor( this._length );\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\toutbuf[ i ] = toWord( fcn.call( thisArg, fromWord( buf[ i ] ), i, this ) ); // eslint-disable-line max-len\n\t}\n\treturn out;\n});\n\n/**\n* Applies a provided callback function to each element of the array, in order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion.\n*\n* @name reduce\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} reducer - callback function\n* @param {*} [initialValue] - initial value\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {Error} if not provided an initial value, the array must have at least one element\n* @returns {*} accumulated result\n*\n* @example\n* function add( acc, v ) {\n* return acc + v;\n* }\n*\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] );\n*\n* var out = arr.reduce( add, 0 );\n* // returns 6.0\n*/\nsetReadOnly( Float16Array.prototype, 'reduce', function reduce( reducer, initialValue ) {\n\tvar buf;\n\tvar len;\n\tvar acc;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( reducer ) ) {\n\t\tthrow new TypeError( format( 'null3c', reducer ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tacc = initialValue;\n\t\ti = 0;\n\t} else {\n\t\tif ( len === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' );\n\t\t}\n\t\tacc = fromWord( buf[ 0 ] );\n\t\ti = 1;\n\t}\n\tfor ( ; i < len; i++ ) {\n\t\tacc = reducer( acc, fromWord( buf[ i ] ), i, this );\n\t}\n\treturn acc;\n});\n\n/**\n* Applies a provided callback function to each element of the array, in reverse order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion.\n*\n* @name reduceRight\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} reducer - callback function\n* @param {*} [initialValue] - initial value\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {Error} if not provided an initial value, the array must have at least one element\n* @returns {*} accumulated result\n*\n* @example\n* function add( acc, v ) {\n* return acc + v;\n* }\n*\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] );\n*\n* var out = arr.reduceRight( add, 0 );\n* // returns 6.0\n*/\nsetReadOnly( Float16Array.prototype, 'reduceRight', function reduceRight( reducer, initialValue ) {\n\tvar buf;\n\tvar len;\n\tvar acc;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( reducer ) ) {\n\t\tthrow new TypeError( format( 'null3c', reducer ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tacc = initialValue;\n\t\ti = len - 1;\n\t} else {\n\t\tif ( len === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' );\n\t\t}\n\t\tacc = fromWord( buf[ len-1 ] );\n\t\ti = len - 2;\n\t}\n\tfor ( ; i >= 0; i-- ) {\n\t\tacc = reducer( acc, fromWord( buf[ i ] ), i, this );\n\t}\n\treturn acc;\n});\n\n/**\n* Reverses an array in-place.\n*\n* @name reverse\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Float16Array} reversed array\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var out = arr.reverse();\n* // returns \n*\n* var v = out[ 0 ];\n* // returns 2.0\n*\n* v = out[ 1 ];\n* // returns 1.0\n*\n* v = out[ 2 ];\n* // returns 0.0\n*/\nsetReadOnly( Float16Array.prototype, 'reverse', function reverse() {\n\tvar buf;\n\tvar tmp;\n\tvar len;\n\tvar N;\n\tvar i;\n\tvar j;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tN = floor( len / 2 );\n\tfor ( i = 0; i < N; i++ ) {\n\t\tj = len - i - 1;\n\t\ttmp = buf[ i ];\n\t\tbuf[ i ] = buf[ j ];\n\t\tbuf[ j ] = tmp;\n\t}\n\treturn this;\n});\n\n/**\n* Sets one or more array elements.\n*\n* ## Notes\n*\n* - When provided a typed array, we must check whether the source array shares the same buffer as the target array and whether the underlying memory overlaps. In particular, we are concerned with the following scenario:\n*\n* ```text\n* buf: ---------------------\n* src: ---------------------\n* ```\n*\n* In the above, as we copy values from `src`, we will overwrite values in the `src` view, resulting in duplicated values copied into the end of `buf`, which is not intended. Hence, to avoid overwriting source values, we must **copy** source values to a temporary array.\n*\n* In the other overlapping scenario,\n*\n* ```text\n* buf: ---------------------\n* src: ---------------------\n* ```\n*\n* by the time we begin copying into the overlapping region, we are copying from the end of `src`, a non-overlapping region, which means we don't run the risk of copying copied values, rather than the original `src` values, as intended.\n*\n* @name set\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {(Collection|Float16Array)} value - value(s)\n* @param {NonNegativeInteger} [i=0] - element index at which to start writing values\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a collection\n* @throws {TypeError} index argument must be a nonnegative integer\n* @throws {RangeError} index argument is out-of-bounds\n* @throws {RangeError} target array lacks sufficient storage to accommodate source values\n* @returns {void}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var v = arr[ 0 ];\n* // returns 0.0\n*\n* arr.set( [ 1.0, 2.0 ], 0 );\n*\n* v = arr[ 0 ];\n* // returns 1.0\n*/\nsetReadOnly( Float16Array.prototype, 'set', function set( value ) {\n\tvar sbuf;\n\tvar idx;\n\tvar buf;\n\tvar tmp;\n\tvar flg;\n\tvar N;\n\tvar i;\n\tvar j;\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isCollection( value ) ) {\n\t\tthrow new TypeError( format( 'null2O', value ) );\n\t}\n\tbuf = this._buffer;\n\tif ( arguments.length > 1 ) {\n\t\tidx = arguments[ 1 ];\n\t\tif ( !isNonNegativeInteger( idx ) ) {\n\t\t\tthrow new TypeError( format( 'null2L', idx ) );\n\t\t}\n\t} else {\n\t\tidx = 0;\n\t}\n\tN = value.length;\n\tif ( idx+N > this._length ) {\n\t\tthrow new RangeError( format('null03') );\n\t}\n\tif ( isFloat16Array( value ) ) {\n\t\tsbuf = value._buffer; // eslint-disable-line no-underscore-dangle\n\t\tflg = true;\n\t} else {\n\t\tsbuf = value;\n\t\tflg = false;\n\t}\n\t// Check for overlapping memory...\n\tj = buf.byteOffset + (idx*BYTES_PER_ELEMENT);\n\tif (\n\t\tsbuf.buffer === buf.buffer &&\n\t\t(\n\t\t\tsbuf.byteOffset < j &&\n\t\t\tsbuf.byteOffset+sbuf.byteLength > j\n\t\t)\n\t) {\n\t\t// We need to copy source values...\n\t\ttmp = new Uint16Array( sbuf.length );\n\t\tfor ( i = 0; i < sbuf.length; i++ ) {\n\t\t\ttmp[ i ] = sbuf[ i ];\n\t\t}\n\t\tsbuf = tmp;\n\t}\n\tif ( flg ) {\n\t\tfor ( i = 0; i < N; idx++, i++ ) {\n\t\t\tbuf[ idx ] = sbuf[ i ];\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < N; idx++, i++ ) {\n\t\t\tbuf[ idx ] = toWord( sbuf[ i ] );\n\t\t}\n\t}\n});\n\n/**\n* Copies a portion of a typed array to a new typed array.\n*\n* @name slice\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} [begin] - start index (inclusive)\n* @param {integer} [end] - end index (exclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be integer\n* @throws {TypeError} second argument must be integer\n* @returns {Float16Array} floating-point number array\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] );\n*\n* var out = arr.slice();\n* // returns \n*\n* var len = out.length;\n* // returns 5\n*\n* var v = out[ 0 ];\n* // returns 0.0\n*\n* v = out[ len-1 ];\n* // returns 4.0\n*\n* out = arr.slice( 1, -2 );\n* // returns \n*\n* len = out.length;\n* // returns 2\n*\n* v = out[ 0 ];\n* // returns 1.0\n*\n* v = out[ len-1 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'slice', function slice( begin, end ) {\n\tvar outlen;\n\tvar outbuf;\n\tvar out;\n\tvar buf;\n\tvar len;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length === 0 ) {\n\t\tbegin = 0;\n\t\tend = len;\n\t} else {\n\t\tif ( !isInteger( begin ) ) {\n\t\t\tthrow new TypeError( format( 'null7e', begin ) );\n\t\t}\n\t\tif ( begin < 0 ) {\n\t\t\tbegin += len;\n\t\t\tif ( begin < 0 ) {\n\t\t\t\tbegin = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\tend = len;\n\t\t} else {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'null7f', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t} else if ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t}\n\t}\n\tif ( begin < end ) {\n\t\toutlen = end - begin;\n\t} else {\n\t\toutlen = 0;\n\t}\n\tout = new this.constructor( outlen );\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < outlen; i++ ) {\n\t\toutbuf[ i ] = buf[ i+begin ];\n\t}\n\treturn out;\n});\n\n/**\n* Tests whether at least one element in an array passes a test implemented by a predicate function.\n*\n* @name some\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {boolean} boolean indicating whether at least one element passes a test\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var bool = arr.some( predicate );\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'some', function some( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( predicate.call( thisArg, fromWord( buf[ i ] ), i, this ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n});\n\n/**\n* Sorts an array in-place.\n*\n* @name sort\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} [compareFcn] - comparison function\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {Float16Array} sorted array\n*\n* @example\n* function compare( a, b ) {\n* if ( a < b ) {\n* return -1;\n* }\n* if ( a > b ) {\n* return 1;\n* }\n* return 0;\n* }\n*\n* var arr = new Float16Array( [ 1.0, 0.0, 2.0 ] );\n*\n* arr.sort( compare );\n*\n* var v = arr[ 0 ];\n* // returns 0.0\n*\n* v = arr[ 1 ];\n* // returns 1.0\n*\n* v = arr[ 2 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'sort', function sort( compareFcn ) {\n\tvar buf;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tif ( arguments.length === 0 ) {\n\t\tbuf.sort( defaultCompare );\n\t\treturn this;\n\t}\n\tif ( !isFunction( compareFcn ) ) {\n\t\tthrow new TypeError( format( 'null3c', compareFcn ) );\n\t}\n\tbuf.sort( compare );\n\treturn this;\n\n\t/**\n\t* Default comparison function for float16 values.\n\t*\n\t* @private\n\t* @param {unsigned16} a - unsigned 16-bit integer for comparison\n\t* @param {unsigned16} b - unsigned 16-bit integer for comparison\n\t* @returns {number} comparison result\n\t*/\n\tfunction defaultCompare( a, b ) { // eslint-disable-line stdlib/no-unnecessary-nested-functions\n\t\tvar x = fromWord( a );\n\t\tvar y = fromWord( b );\n\n\t\t// Handle NaN...\n\t\tif ( isnan( x ) && isnan( y ) ) {\n\t\t\treturn 0;\n\t\t}\n\t\tif ( isnan( x ) ) {\n\t\t\treturn 1;\n\t\t}\n\t\tif ( isnan( y ) ) {\n\t\t\treturn -1;\n\t\t}\n\t\t// Normal comparison\n\t\tif ( x < y ) {\n\t\t\treturn -1;\n\t\t}\n\t\tif ( x > y ) {\n\t\t\treturn 1;\n\t\t}\n\t\treturn 0;\n\t}\n\n\t/**\n\t* Comparison function wrapper.\n\t*\n\t* @private\n\t* @param {unsigned16} a - unsigned 16-bit integer for comparison\n\t* @param {unsigned16} b - unsigned 16-bit integer for comparison\n\t* @returns {number} comparison result\n\t*/\n\tfunction compare( a, b ) {\n\t\treturn compareFcn( fromWord( a ), fromWord( b ) );\n\t}\n});\n\n/**\n* Creates a new typed array view over the same underlying `ArrayBuffer` and with the same underlying data type as the host array.\n*\n* @name subarray\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} [begin] - start index (inclusive)\n* @param {integer} [end] - end index (exclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be an integer\n* @throws {TypeError} second argument must be an integer\n* @returns {Float16Array} subarray\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] );\n*\n* var subarr = arr.subarray();\n* // returns \n*\n* var len = subarr.length;\n* // returns 5\n*\n* var bool = subarr[ 0 ];\n* // returns 0.0\n*\n* bool = subarr[ len-1 ];\n* // returns 4.0\n*\n* subarr = arr.subarray( 1, -2 );\n* // returns \n*\n* len = subarr.length;\n* // returns 2\n*\n* bool = subarr[ 0 ];\n* // returns 1.0\n*\n* bool = subarr[ len-1 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'subarray', function subarray( begin, end ) {\n\tvar offset;\n\tvar buf;\n\tvar len;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length === 0 ) {\n\t\tbegin = 0;\n\t\tend = len;\n\t} else {\n\t\tif ( !isInteger( begin ) ) {\n\t\t\tthrow new TypeError( format( 'null7e', begin ) );\n\t\t}\n\t\tif ( begin < 0 ) {\n\t\t\tbegin += len;\n\t\t\tif ( begin < 0 ) {\n\t\t\t\tbegin = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\tend = len;\n\t\t} else {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'null7f', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t} else if ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t}\n\t}\n\tif ( begin >= len ) {\n\t\tlen = 0;\n\t\toffset = buf.byteLength;\n\t} else if ( begin >= end ) {\n\t\tlen = 0;\n\t\toffset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT );\n\t} else {\n\t\tlen = end - begin;\n\t\toffset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT );\n\t}\n\treturn new this.constructor( buf.buffer, offset, ( len < 0 ) ? 0 : len );\n});\n\n/**\n* Serializes an array as a locale-specific string.\n*\n* @name toLocaleString\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {(string|Array)} [locales] - locale identifier(s)\n* @param {Object} [options] - configuration options\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a string or an array of strings\n* @throws {TypeError} options argument must be an object\n* @returns {string} string representation\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var str = arr.toLocaleString();\n* // returns '0,1,2'\n*/\nsetReadOnly( Float16Array.prototype, 'toLocaleString', function toLocaleString( locales, options ) {\n\tvar opts;\n\tvar loc;\n\tvar out;\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( arguments.length === 0 ) {\n\t\tloc = [];\n\t} else if ( isString( locales ) || isStringArray( locales ) ) {\n\t\tloc = locales;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a string or an array of strings. Value: `%s`.', locales ) );\n\t}\n\tif ( arguments.length < 2 ) {\n\t\topts = {};\n\t} else if ( isObject( options ) ) {\n\t\topts = options;\n\t} else {\n\t\tthrow new TypeError( format( 'null2V', options ) );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( fromWord( buf[ i ] ) );\n\t}\n\treturn out.toLocaleString( loc, opts );\n});\n\n/**\n* Returns a new typed array containing the elements in reversed order.\n*\n* @name toReversed\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Float16Array} reversed array\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var out = arr.toReversed();\n* // returns \n*\n* var v = out[ 0 ];\n* // returns 2.0\n*\n* v = out[ 1 ];\n* // returns 1.0\n*\n* v = out[ 2 ];\n* // returns 0.0\n*/\nsetReadOnly( Float16Array.prototype, 'toReversed', function toReversed() {\n\tvar outbuf;\n\tvar out;\n\tvar len;\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tlen = this._length;\n\tout = new this.constructor( len );\n\tbuf = this._buffer;\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < len; i++ ) {\n\t\toutbuf[ i ] = buf[ len - i - 1 ];\n\t}\n\treturn out;\n});\n\n/**\n* Returns a new typed array containing the elements in sorted order.\n*\n* @name toSorted\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} [compareFcn] - comparison function\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {Float16Array} sorted array\n*\n* @example\n* function compare( a, b ) {\n* if ( a > b ) {\n* return 1;\n* }\n* if ( a < b ) {\n* return -1;\n* }\n* return 0;\n* }\n*\n* var arr = new Float16Array( [ 2.0, 0.0, 1.0 ] );\n*\n* var out = arr.toSorted( compare );\n* // returns \n*\n* var v = out[ 0 ];\n* // returns 0.0\n*\n* v = out[ 1 ];\n* // returns 1.0\n*\n* v = out[ 2 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'toSorted', function toSorted( compareFcn ) {\n\tvar out;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tout = new this.constructor( this );\n\tif ( arguments.length === 0 ) {\n\t\treturn out.sort();\n\t}\n\treturn out.sort( compareFcn );\n});\n\n/**\n* Serializes an array as a string.\n*\n* @name toString\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {string} string representation\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var str = arr.toString();\n* // returns '0,1,2'\n*/\nsetReadOnly( Float16Array.prototype, 'toString', function toString() {\n\tvar out;\n\tvar buf;\n\tvar i;\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( fromWord( buf[ i ] ) );\n\t}\n\treturn out.join( ',' );\n});\n\n/**\n* Returns an iterator for iterating over each value in a typed array.\n*\n* @name values\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0 ] );\n*\n* var iter = arr.values();\n*\n* var v = iter.next().value;\n* // returns 0.0\n*\n* v = iter.next().value;\n* // returns 1.0\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'values', function values() {\n\tvar iter;\n\tvar self;\n\tvar len;\n\tvar FLG;\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tself = this;\n\tbuf = this._buffer;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': fromWord( buf[ i ] ),\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.values();\n\t}\n});\n\n/**\n* Returns a new typed array with the element at a provided index replaced with a provided value.\n*\n* @name with\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} index - element index\n* @param {number} value - new value\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be an integer\n* @throws {RangeError} index argument is out-of-bounds\n* @throws {TypeError} second argument must be a floating-point number\n* @returns {Float16Array} new typed array\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var out = arr.with( 0, 3.0 );\n* // returns \n*\n* var v = out[ 0 ];\n* // returns 3.0\n*/\nsetReadOnly( Float16Array.prototype, 'with', function copyWith( index, value ) {\n\tvar out;\n\tvar len;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isInteger( index ) ) {\n\t\tthrow new TypeError( format( 'null7e', index ) );\n\t}\n\tlen = this._length;\n\tif ( index < 0 ) {\n\t\tindex += len;\n\t}\n\tif ( index < 0 || index >= len ) {\n\t\tthrow new RangeError( format( 'nullFP', index ) );\n\t}\n\tif ( !isNumber( value ) ) {\n\t\tthrow new TypeError( format( 'null4A', value ) );\n\t}\n\tout = new this.constructor( this );\n\tout[ index ] = value;\n\treturn out;\n});\n\n\n// EXPORTS //\n\nexport default Float16Array;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport f16 from '@stdlib/number-float64-base-to-float16';\nimport toWord from '@stdlib/number-float16-base-to-word';\n\n\n// MAIN //\n\n/**\n* Fills an output array with unsigned 16-bit integers corresponding to the IEEE 754 binary representation of respective half-precision floating-point numbers.\n*\n* @private\n* @param {Uint16Array} buf - output array\n* @param {Array} arr - input array\n* @returns {Uint16Array} output array\n*/\nfunction fromArray( buf, arr ) {\n\tvar len;\n\tvar i;\n\n\tlen = arr.length;\n\tfor ( i = 0; i < len; i++ ) {\n\t\tbuf[ i ] = toWord( f16( arr[ i ] ) );\n\t}\n\treturn buf;\n}\n\n\n// EXPORTS //\n\nexport default fromArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport f16 from '@stdlib/number-float64-base-to-float16';\nimport toWord from '@stdlib/number-float16-base-to-word';\n\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @param {Function} clbk - callback to invoke for each iterated value\n* @param {*} thisArg - invocation context\n* @returns {Array} output array\n*/\nfunction fromIteratorMap( it, clbk, thisArg ) {\n\tvar out;\n\tvar v;\n\tvar i;\n\n\tout = [];\n\ti = -1;\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\ti += 1;\n\t\tout.push( toWord( f16( clbk.call( thisArg, v.value, i ) ) ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIteratorMap;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Float16Array === 'function' ) ? Float16Array : void 0; // eslint-disable-line no-undef, stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* 16-bit floating-point number array constructor.\n*\n* @module @stdlib/array-float16\n*\n* @example\n* import Float16Array from '@stdlib/array-float16';\n*\n* var arr = new Float16Array();\n* // returns \n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* import Float16Array from '@stdlib/array-float16';\n*\n* var arr = new Float16Array( 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import Float16Array from '@stdlib/array-float16';\n*\n* var arr = new Float16Array( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n* import Float16Array from '@stdlib/array-float16';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float16Array( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 8\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n* import Float16Array from '@stdlib/array-float16';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float16Array( buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 4\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n* import Float16Array from '@stdlib/array-float16';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Float16Array( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\n\n// MODULES //\n\nimport hasFloat16ArraySupport from '@stdlib/assert-has-float16array-support';\nimport polyfill from './polyfill';\nimport builtin from './main.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasFloat16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n"],"names":["fromIterator","it","out","v","next","done","push","toWord","f16","value","BYTES_PER_ELEMENT","Uint16Array","HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","isFloat16Array","constructor","name","isFloatingPointArrayConstructor","Float16Array","getter","ctx","idx","_get","setter","set","byteOffset","nargs","buf","len","arg","i","arguments","length","this","isNonNegativeInteger","isCollection","gcopy","ndarray","buffer","arr","fromArray","isArrayBuffer","isInteger","byteLength","RangeError","format","isObject","TypeError","isFunction","ITERATOR_SYMBOL","setReadOnly","setReadWriteAccessor","src","thisArg","clbk","tmp","_buffer","call","fromIteratorMap","Error","args","prototype","_length","fromWord","setReadOnlyAccessor","target","start","copyWithin","self","iter","FLG","entries","predicate","end","isNumber","fcn","searchElement","fromIndex","separator","isString","join","keys","outbuf","reducer","initialValue","acc","N","j","floor","sbuf","flg","begin","outlen","compareFcn","sort","a","b","x","y","isnan","offset","locales","options","opts","loc","isStringArray","toLocaleString","values","index","ctor","ctor$1","hasFloat16ArraySupport","builtin","polyfill"],"mappings":"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"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 662979c..0000000 --- a/lib/index.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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'; - -/** -* 16-bit floating-point number array constructor. -* -* @module @stdlib/array-float16 -* -* @example -* var Float16Array = require( '@stdlib/array-float16' ); -* -* var arr = new Float16Array(); -* // returns -* -* var len = arr.length; -* // returns 0 -* -* @example -* var Float16Array = require( '@stdlib/array-float16' ); -* -* var arr = new Float16Array( 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var Float16Array = require( '@stdlib/array-float16' ); -* -* var arr = new Float16Array( [ 1.0, 2.0 ] ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var Float16Array = require( '@stdlib/array-float16' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float16Array( buf ); -* // returns -* -* var len = arr.length; -* // returns 8 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var Float16Array = require( '@stdlib/array-float16' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float16Array( buf, 8 ); -* // returns -* -* var len = arr.length; -* // returns 4 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var Float16Array = require( '@stdlib/array-float16' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = new Float16Array( buf, 8, 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -*/ - -// MODULES // - -var hasFloat16ArraySupport = require( '@stdlib/assert-has-float16array-support' ); -var polyfill = require( './polyfill' ); -var builtin = require( './main.js' ); - - -// MAIN // - -var ctor; -if ( hasFloat16ArraySupport() ) { - ctor = builtin; -} else { - ctor = polyfill; -} - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 90c9924..0000000 --- a/lib/main.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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'; - -// MAIN // - -var ctor = ( typeof Float16Array === 'function' ) ? Float16Array : void 0; // eslint-disable-line no-undef, stdlib/require-globals - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/polyfill/from_array.js b/lib/polyfill/from_array.js deleted file mode 100644 index b5894dc..0000000 --- a/lib/polyfill/from_array.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 f16 = require( '@stdlib/number-float64-base-to-float16' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); - - -// MAIN // - -/** -* Fills an output array with unsigned 16-bit integers corresponding to the IEEE 754 binary representation of respective half-precision floating-point numbers. -* -* @private -* @param {Uint16Array} buf - output array -* @param {Array} arr - input array -* @returns {Uint16Array} output array -*/ -function fromArray( buf, arr ) { - var len; - var i; - - len = arr.length; - for ( i = 0; i < len; i++ ) { - buf[ i ] = toWord( f16( arr[ i ] ) ); - } - return buf; -} - - -// EXPORTS // - -module.exports = fromArray; diff --git a/lib/polyfill/from_iterator.js b/lib/polyfill/from_iterator.js deleted file mode 100644 index 37a2c7c..0000000 --- a/lib/polyfill/from_iterator.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 f16 = require( '@stdlib/number-float64-base-to-float16' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); - - -// MAIN // - -/** -* Returns an array of iterated values. -* -* @private -* @param {Object} it - iterator -* @returns {Array} output array -*/ -function fromIterator( it ) { - var out; - var v; - - out = []; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - out.push( toWord( f16( v.value ) ) ); - } - return out; -} - - -// EXPORTS // - -module.exports = fromIterator; diff --git a/lib/polyfill/from_iterator_map.js b/lib/polyfill/from_iterator_map.js deleted file mode 100644 index 265e59d..0000000 --- a/lib/polyfill/from_iterator_map.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 f16 = require( '@stdlib/number-float64-base-to-float16' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); - - -// MAIN // - -/** -* Returns an array of iterated values. -* -* @private -* @param {Object} it - iterator -* @param {Function} clbk - callback to invoke for each iterated value -* @param {*} thisArg - invocation context -* @returns {Array} output array -*/ -function fromIteratorMap( it, clbk, thisArg ) { - var out; - var v; - var i; - - out = []; - i = -1; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - i += 1; - out.push( toWord( f16( clbk.call( thisArg, v.value, i ) ) ) ); - } - return out; -} - - -// EXPORTS // - -module.exports = fromIteratorMap; diff --git a/lib/polyfill/index.js b/lib/polyfill/index.js deleted file mode 100644 index f4a1a8f..0000000 --- a/lib/polyfill/index.js +++ /dev/null @@ -1,2410 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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. -*/ - -/* eslint-disable no-restricted-syntax, no-invalid-this, stdlib/jsdoc-typedef-typos, max-lines */ - -'use strict'; - -// MODULES // - -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isObject = require( '@stdlib/assert-is-object' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var f16 = require( '@stdlib/number-float64-base-to-float16' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var fromWord = require( '@stdlib/number-float16-base-from-word' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var fromArray = require( './from_array.js' ); -var fromIterator = require( './from_iterator.js' ); -var fromIteratorMap = require( './from_iterator_map.js' ); - - -// VARIABLES // - -var BYTES_PER_ELEMENT = Uint16Array.BYTES_PER_ELEMENT; -var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport(); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating if a value is a `Float16Array`. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating if a value is a `Float16Array` -*/ -function isFloat16Array( value ) { - return ( - typeof value === 'object' && - value !== null && - value.constructor.name === 'Float16Array' && - value.BYTES_PER_ELEMENT === BYTES_PER_ELEMENT - ); -} - -/** -* Returns a boolean indicating if a value is a floating-point typed array constructor. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating if a value is a floating-point typed array constructor -*/ -function isFloatingPointArrayConstructor( value ) { // eslint-disable-line id-length - return ( value === Float16Array ); -} - -/** -* Returns a getter. -* -* @private -* @param {Float16Array} ctx - typed array instance -* @param {NonNegativeInteger} idx - element index -* @returns {Function} getter -*/ -function getter( ctx, idx ) { - return get; - - /** - * Returns an array element. - * - * @private - * @returns {(number|void)} array element - */ - function get() { - return ctx._get( idx ); // eslint-disable-line no-underscore-dangle - } -} - -/** -* Returns a setter. -* -* @private -* @param {Float16Array} ctx - typed array instance -* @param {NonNegativeInteger} idx - element index -* @returns {Function} setter -*/ -function setter( ctx, idx ) { - return set; - - /** - * Sets an array element. - * - * @private - * @param {number} value - value to set - */ - function set( value ) { - ctx.set( [ value ], idx ); - } -} - - -// MAIN // - -/** -* 16-bit floating-point number array constructor. -* -* @constructor -* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable -* @param {NonNegativeInteger} [byteOffset=0] - byte offset -* @param {NonNegativeInteger} [length] - view length -* @throws {RangeError} ArrayBuffer byte length must be a multiple of `2` -* @throws {TypeError} if provided only a single argument, must provide a valid argument -* @throws {TypeError} byte offset must be a nonnegative integer -* @throws {RangeError} byte offset must be a multiple of `2` -* @throws {TypeError} view length must be a positive multiple of `2` -* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements -* @returns {Float16Array} half-precision floating-point number array -* -* @example -* var arr = new Float16Array(); -* // returns -* -* var len = arr.length; -* // returns 0 -* -* @example -* var arr = new Float16Array( 5 ); -* // returns -* -* var len = arr.length; -* // returns 5 -* -* @example -* var arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns -* -* var len = arr.length; -* // returns 5 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float16Array( buf ); -* // returns -* -* var len = arr.length; -* // returns 8 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float16Array( buf, 8 ); -* // returns -* -* var len = arr.length; -* // returns 4 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = new Float16Array( buf, 8, 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -*/ -function Float16Array() { - var byteOffset; - var nargs; - var buf; - var len; - var arg; - var i; - - nargs = arguments.length; - if ( !(this instanceof Float16Array) ) { - if ( nargs === 0 ) { - return new Float16Array(); - } - if ( nargs === 1 ) { - return new Float16Array( arguments[0] ); - } - if ( nargs === 2 ) { - return new Float16Array( arguments[0], arguments[1] ); - } - return new Float16Array( arguments[0], arguments[1], arguments[2] ); - } - // Create the underlying data buffer... - if ( nargs === 0 ) { - buf = new Uint16Array( 0 ); // backward-compatibility - } else if ( nargs === 1 ) { - arg = arguments[ 0 ]; - if ( isNonNegativeInteger( arg ) ) { - buf = new Uint16Array( arg ); - } else if ( isCollection( arg ) ) { - if ( isFloat16Array( arg ) ) { - buf = new Uint16Array( arg.length ); - gcopy.ndarray( arg.length, new Uint16Array( arg.buffer, arg.byteOffset, arg.length ), 1, 0, buf, 1, 0 ); // eslint-disable-line max-len - } else { - buf = fromArray( new Uint16Array( arg.length ), arg ); - } - } else if ( isArrayBuffer( arg ) ) { - if ( !isInteger( arg.byteLength/BYTES_PER_ELEMENT ) ) { - throw new RangeError( format( 'nullE9', BYTES_PER_ELEMENT, arg.byteLength ) ); - } - buf = new Uint16Array( arg ); - } else if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'null29', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'null2A', arg ) ); - } - buf = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( buf.next ) ) { - throw new TypeError( format( 'null2A', arg ) ); - } - buf = new Uint16Array( fromIterator( buf ) ); - } else { - throw new TypeError( format( 'null2A', arg ) ); - } - } else { - buf = arguments[ 0 ]; - if ( !isArrayBuffer( buf ) ) { - throw new TypeError( format( 'null2B', buf ) ); - } - byteOffset = arguments[ 1 ]; - if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'null2C', byteOffset ) ); - } - if ( !isInteger( byteOffset/BYTES_PER_ELEMENT ) ) { - throw new RangeError( format( 'nullEA', BYTES_PER_ELEMENT, byteOffset ) ); - } - if ( nargs === 2 ) { - len = buf.byteLength - byteOffset; - if ( !isInteger( len/BYTES_PER_ELEMENT ) ) { - throw new RangeError( format( 'null2E', BYTES_PER_ELEMENT, len ) ); - } - buf = new Uint16Array( buf, byteOffset ); - } else { - len = arguments[ 2 ]; - if ( !isNonNegativeInteger( len ) ) { - throw new TypeError( format( 'null2F', len ) ); - } - if ( (len*BYTES_PER_ELEMENT) > (buf.byteLength-byteOffset) ) { - throw new RangeError( format( 'null2G', len*BYTES_PER_ELEMENT ) ); - } - buf = new Uint16Array( buf, byteOffset, len ); - } - } - setReadOnly( this, '_buffer', buf ); - setReadOnly( this, '_length', buf.length ); - for ( i = 0; i < buf.length; i++ ) { - setReadWriteAccessor( this, i, getter( this, i ), setter( this, i ) ); - } - return this; -} - -/** -* Size (in bytes) of each array element. -* -* @name BYTES_PER_ELEMENT -* @memberof Float16Array -* @readonly -* @type {PositiveInteger} -* @default 2 -* -* @example -* var nbytes = Float16Array.BYTES_PER_ELEMENT; -* // returns 2 -*/ -setReadOnly( Float16Array, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT ); - -/** -* Constructor name. -* -* @name name -* @memberof Float16Array -* @readonly -* @type {string} -* @default 'Float16Array' -* -* @example -* var str = Float16Array.name; -* // returns 'Float16Array' -*/ -setReadOnly( Float16Array, 'name', 'Float16Array' ); - -/** -* Creates a new 16-bit floating-point number array from an array-like object or an iterable. -* -* @name from -* @memberof Float16Array -* @type {Function} -* @param {(Collection|Iterable)} src - array-like object or iterable -* @param {Function} [clbk] - callback to invoke for each source element -* @param {*} [thisArg] - context -* @throws {TypeError} `this` context must be a constructor -* @throws {TypeError} `this` must be a floating-point array -* @throws {TypeError} first argument must be an array-like object or an iterable -* @throws {TypeError} second argument must be a function -* @returns {Float16Array} half-precision floating-point number array -* -* @example -* var arr = Float16Array.from( [ 1.0, 2.0 ] ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* function clbk( v ) { -* return v * 2.0; -* } -* -* var arr = Float16Array.from( [ 1.0, 2.0 ], clbk ); -* // returns -* -* var len = arr.length; -* // returns 2 -*/ -setReadOnly( Float16Array, 'from', function from( src ) { - var thisArg; - var nargs; - var clbk; - var out; - var buf; - var tmp; - var len; - var i; - if ( !isFunction( this ) ) { - throw new TypeError( format('null01') ); - } - if ( !isFloatingPointArrayConstructor( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - nargs = arguments.length; - if ( nargs > 1 ) { - clbk = arguments[ 1 ]; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'null2H', clbk ) ); - } - if ( nargs > 2 ) { - thisArg = arguments[ 2 ]; - } - } - if ( isCollection( src ) ) { - if ( clbk ) { - len = src.length; - out = new this( len ); - buf = out._buffer; // eslint-disable-line no-underscore-dangle - for ( i = 0; i < len; i++ ) { - buf[ i ] = toWord( f16( clbk.call( thisArg, src[ i ], i ) ) ); - } - return out; - } - return new this( src ); - } - if ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) { // eslint-disable-line max-len - buf = src[ ITERATOR_SYMBOL ](); - if ( !isFunction( buf.next ) ) { - throw new TypeError( format( 'null2J', src ) ); - } - if ( clbk ) { - tmp = fromIteratorMap( buf, clbk, thisArg ); - } else { - tmp = fromIterator( buf ); - } - if ( tmp instanceof Error ) { - throw tmp; - } - len = tmp.length; - out = new this( len ); - buf = out._buffer; // eslint-disable-line no-underscore-dangle - for ( i = 0; i < len; i++ ) { - buf[ i ] = tmp[ i ]; - } - return out; - } - throw new TypeError( format( 'null2J', src ) ); -}); - -/** -* Creates a new 16-bit floating-point number array from a variable number of arguments. -* -* @name of -* @memberof Float16Array -* @type {Function} -* @param {...*} element - array elements -* @throws {TypeError} `this` context must be a constructor -* @throws {TypeError} `this` must be a floating-point number array -* @returns {Float16Array} half-precision floating-point number array -* -* @example -* var arr = Float16Array.of( 1.0, 1.0, 1.0, 1.0 ); -* // returns -* -* var x = arr[ 0 ]; -* // returns 1.0 -* -* var len = arr.length; -* // returns 4 -*/ -setReadOnly( Float16Array, 'of', function of() { - var args; - var i; - if ( !isFunction( this ) ) { - throw new TypeError( format('null01') ); - } - if ( !isFloatingPointArrayConstructor( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - args = []; - for ( i = 0; i < arguments.length; i++ ) { - args.push( arguments[ i ] ); - } - return new this( args ); -}); - -/** -* Returns an array element with support for both nonnegative and negative integer indices. -* -* @name at -* @memberof Float16Array.prototype -* @type {Function} -* @param {integer} idx - element index -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} must provide an integer -* @returns {(number|void)} array element -* -* @example -* var arr = new Float16Array( [ 10.0, 20.0, 30.0 ] ); -* -* var v = arr.at( 0 ); -* // returns 10.0 -* -* v = arr.at( -1 ); -* // returns 30.0 -* -* v = arr.at( 100 ); -* // returns undefined -*/ -setReadOnly( Float16Array.prototype, 'at', function at( idx ) { - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isInteger( idx ) ) { - throw new TypeError( format( 'null8A', idx ) ); - } - if ( idx < 0 ) { - idx += this._length; - } - if ( idx < 0 || idx >= this._length ) { - return; - } - return fromWord( this._buffer[ idx ] ); -}); - -/** -* Pointer to the underlying data buffer. -* -* @name buffer -* @memberof Float16Array.prototype -* @readonly -* @type {ArrayBuffer} -* -* @example -* var arr = new Float16Array( 10 ); -* -* var buf = arr.buffer; -* // returns -*/ -setReadOnlyAccessor( Float16Array.prototype, 'buffer', function get() { - return this._buffer.buffer; -}); - -/** -* Size (in bytes) of the array. -* -* @name byteLength -* @memberof Float16Array.prototype -* @readonly -* @type {NonNegativeInteger} -* -* @example -* var arr = new Float16Array( 10 ); -* -* var byteLength = arr.byteLength; -* // returns 20 -*/ -setReadOnlyAccessor( Float16Array.prototype, 'byteLength', function get() { - return this._buffer.byteLength; -}); - -/** -* Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`. -* -* @name byteOffset -* @memberof Float16Array.prototype -* @readonly -* @type {NonNegativeInteger} -* -* @example -* var arr = new Float16Array( 10 ); -* -* var byteOffset = arr.byteOffset; -* // returns 0 -*/ -setReadOnlyAccessor( Float16Array.prototype, 'byteOffset', function get() { - return this._buffer.byteOffset; -}); - -/** -* Size (in bytes) of each array element. -* -* @name BYTES_PER_ELEMENT -* @memberof Float16Array.prototype -* @readonly -* @type {PositiveInteger} -* @default 2 -* -* @example -* var arr = new Float16Array( 10 ); -* -* var nbytes = arr.BYTES_PER_ELEMENT; -* // returns 2 -*/ -setReadOnly( Float16Array.prototype, 'BYTES_PER_ELEMENT', Float16Array.BYTES_PER_ELEMENT ); - -/** -* Copies a sequence of elements within the array to the position starting at `target`. -* -* @name copyWithin -* @memberof Float16Array.prototype -* @type {Function} -* @param {integer} target - index at which to start copying elements -* @param {integer} start - source index at which to copy elements from -* @param {integer} [end] - source index at which to stop copying elements from -* @throws {TypeError} `this` must be a floating-point array -* @returns {Float16Array} modified array -* -* @example -* var arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0 ] ); -* -* // Copy the first two elements to the last two elements: -* arr.copyWithin( 2, 0, 2 ); -* -* var v = arr[ 2 ]; -* // returns 1.0 -* -* v = arr[ 3 ]; -* // returns 2.0 -*/ -setReadOnly( Float16Array.prototype, 'copyWithin', function copyWithin( target, start ) { - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - // FIXME: prefer a functional `copyWithin` implementation which addresses lack of universal browser support (e.g., IE11 and Safari) or ensure that typed arrays are polyfilled - if ( arguments.length === 2 ) { - this._buffer.copyWithin( target, start ); - } else { - this._buffer.copyWithin( target, start, arguments[2] ); - } - return this; -}); - -/** -* Returns an iterator for iterating over array key-value pairs. -* -* @name entries -* @memberof Float16Array.prototype -* @type {Function} -* @throws {TypeError} `this` must be a floating-point number array -* @returns {Iterator} iterator -* -* @example -* var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); -* -* var it = arr.entries(); -* -* var v = it.next().value; -* // returns [ 0, 1.0 ] -* -* v = it.next().value; -* // returns [ 1, 2.0 ] -* -* v = it.next().value; -* // returns [ 2, 3.0 ] -* -* var bool = it.next().done; -* // returns true -*/ -setReadOnly( Float16Array.prototype, 'entries', function entries() { - var self; - var iter; - var len; - var buf; - var FLG; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - self = this; - buf = this._buffer; - len = this._length; - - // Initialize an iteration index: - i = -1; - - // Create an iterator protocol-compliant object: - iter = {}; - setReadOnly( iter, 'next', next ); - setReadOnly( iter, 'return', end ); - - if ( ITERATOR_SYMBOL ) { - setReadOnly( iter, ITERATOR_SYMBOL, factory ); - } - return iter; - - /** - * Returns an iterator protocol-compliant object containing the next iterated value. - * - * @private - * @returns {Object} iterator protocol-compliant object - */ - function next() { - i += 1; - if ( FLG || i >= len ) { - return { - 'done': true - }; - } - return { - 'value': [ i, fromWord( buf[ i ] ) ], - 'done': false - }; - } - - /** - * Finishes an iterator. - * - * @private - * @param {*} [value] - value to return - * @returns {Object} iterator protocol-compliant object - */ - function end( value ) { - FLG = true; - if ( arguments.length ) { - return { - 'value': value, - 'done': true - }; - } - return { - 'done': true - }; - } - - /** - * Returns a new iterator. - * - * @private - * @returns {Iterator} iterator - */ - function factory() { - return self.entries(); - } -}); - -/** -* Tests whether all elements in an array pass a test implemented by a predicate function. -* -* @name every -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - predicate function execution context -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a function -* @returns {boolean} boolean indicating whether all elements pass a test -* -* @example -* function predicate( v ) { -* return v === 0.0; -* } -* -* var arr = new Float16Array( 3 ); -* -* var bool = arr.every( predicate ); -* // returns true -*/ -setReadOnly( Float16Array.prototype, 'every', function every( predicate, thisArg ) { - var buf; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'null3c', predicate ) ); - } - buf = this._buffer; - for ( i = 0; i < this._length; i++ ) { - if ( !predicate.call( thisArg, fromWord( buf[ i ] ), i, this ) ) { - return false; - } - } - return true; -}); - -/** -* Returns a modified typed array filled with a fill value. -* -* @name fill -* @memberof Float16Array.prototype -* @type {Function} -* @param {number} value - fill value -* @param {integer} [start=0] - starting index (inclusive) -* @param {integer} [end] - ending index (exclusive) -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a floating-point number -* @throws {TypeError} second argument must be an integer -* @throws {TypeError} third argument must be an integer -* @returns {Float16Array} modified array -* -* @example -* var arr = new Float16Array( 3 ); -* -* arr.fill( 1.0, 1 ); -* -* var v = arr[ 0 ]; -* // returns 0.0 -* -* v = arr[ 1 ]; -* // returns 1.0 -* -* v = arr[ 2 ]; -* // returns 1.0 -*/ -setReadOnly( Float16Array.prototype, 'fill', function fill( value, start, end ) { - var buf; - var len; - var i; - var v; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isNumber( value ) ) { - throw new TypeError( format( 'null49', value ) ); - } - buf = this._buffer; - len = this._length; - if ( arguments.length > 1 ) { - if ( !isInteger( start ) ) { - throw new TypeError( format( 'null7f', start ) ); - } - if ( start < 0 ) { - start += len; - if ( start < 0 ) { - start = 0; - } - } - if ( arguments.length > 2 ) { - if ( !isInteger( end ) ) { - throw new TypeError( format( 'null2z', end ) ); - } - if ( end < 0 ) { - end += len; - if ( end < 0 ) { - end = 0; - } - } - if ( end > len ) { - end = len; - } - } else { - end = len; - } - } else { - start = 0; - end = len; - } - v = toWord( value ); - for ( i = start; i < end; i++ ) { - buf[ i ] = v; - } - return this; -}); - -/** -* Returns a new array containing the elements of an array which pass a test implemented by a predicate function. -* -* @name filter -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} predicate - test function -* @param {*} [thisArg] - predicate function execution context -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a function -* @returns {Float16Array} floating-point number array -* -* @example -* function predicate( v ) { -* return ( v === 0.0 ); -* } -* -* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] ); -* -* var out = arr.filter( predicate ); -* // returns -* -* var len = out.length; -* // returns 2 -* -* var v = out[ 0 ]; -* // returns 0.0 -* -* v = out[ 1 ]; -* // returns 0.0 -*/ -setReadOnly( Float16Array.prototype, 'filter', function filter( predicate, thisArg ) { - var buf; - var out; - var i; - var v; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'null3c', predicate ) ); - } - buf = this._buffer; - out = []; - for ( i = 0; i < this._length; i++ ) { - v = fromWord( buf[ i ] ); - if ( predicate.call( thisArg, v, i, this ) ) { - out.push( v ); - } - } - return new this.constructor( out ); -}); - -/** -* Returns the first element in an array for which a predicate function returns a truthy value. -* -* @name find -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - predicate function execution context -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a function -* @returns {(boolean|void)} array element or undefined -* -* @example -* function predicate( v ) { -* return v > 0.0; -* } -* -* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] ); -* -* var v = arr.find( predicate ); -* // returns 1.0 -*/ -setReadOnly( Float16Array.prototype, 'find', function find( predicate, thisArg ) { - var buf; - var v; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'null3c', predicate ) ); - } - buf = this._buffer; - for ( i = 0; i < this._length; i++ ) { - v = fromWord( buf[ i ] ); - if ( predicate.call( thisArg, v, i, this ) ) { - return v; - } - } -}); - -/** -* Returns the index of the first element in an array for which a predicate function returns a truthy value. -* -* @name findIndex -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - predicate function execution context -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a function -* @returns {integer} index or -1 -* -* @example -* function predicate( v ) { -* return v > 0.0; -* } -* -* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] ); -* -* var v = arr.findIndex( predicate ); -* // returns 1 -*/ -setReadOnly( Float16Array.prototype, 'findIndex', function findIndex( predicate, thisArg ) { - var buf; - var v; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'null3c', predicate ) ); - } - buf = this._buffer; - for ( i = 0; i < this._length; i++ ) { - v = fromWord( buf[ i ] ); - if ( predicate.call( thisArg, v, i, this ) ) { - return i; - } - } - return -1; -}); - -/** -* Returns the last element in an array for which a predicate function returns a truthy value. -* -* @name findLast -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - predicate function execution context -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a function -* @returns {(boolean|void)} array element or undefined -* -* @example -* function predicate( v ) { -* return v > 0.0; -* } -* -* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] ); -* -* var v = arr.findLast( predicate ); -* // returns 1.0 -*/ -setReadOnly( Float16Array.prototype, 'findLast', function findLast( predicate, thisArg ) { - var buf; - var v; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'null3c', predicate ) ); - } - buf = this._buffer; - for ( i = this._length-1; i >= 0; i-- ) { - v = fromWord( buf[ i ] ); - if ( predicate.call( thisArg, v, i, this ) ) { - return v; - } - } -}); - -/** -* Returns the index of the last element in an array for which a predicate function returns a truthy value. -* -* @name findLastIndex -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - predicate function execution context -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a function -* @returns {integer} index or -1 -* -* @example -* function predicate( v ) { -* return v > 0.0; -* } -* -* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] ); -* -* var v = arr.findLastIndex( predicate ); -* // returns 1 -*/ -setReadOnly( Float16Array.prototype, 'findLastIndex', function findLastIndex( predicate, thisArg ) { - var buf; - var v; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'null3c', predicate ) ); - } - buf = this._buffer; - for ( i = this._length-1; i >= 0; i-- ) { - v = fromWord( buf[ i ] ); - if ( predicate.call( thisArg, v, i, this ) ) { - return i; - } - } - return -1; -}); - -/** -* Invokes a function once for each array element. -* -* @name forEach -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} fcn - function to invoke -* @param {*} [thisArg] - function invocation context -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a function -* -* @example -* function log( v, i ) { -* console.log( '%s: %s', i, v.toString() ); -* } -* -* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] ); -* -* arr.forEach( log ); -*/ -setReadOnly( Float16Array.prototype, 'forEach', function forEach( fcn, thisArg ) { - var buf; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'null3c', fcn ) ); - } - buf = this._buffer; - for ( i = 0; i < this._length; i++ ) { - fcn.call( thisArg, fromWord( buf[ i ] ), i, this ); - } -}); - -/** -* Returns an array element. -* -* @private -* @name _get -* @memberof Float16Array.prototype -* @type {Function} -* @param {NonNegativeInteger} idx - element index -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} must provide a nonnegative integer -* @returns {(number|void)} array element -*/ -setReadOnly( Float16Array.prototype, '_get', function get( idx ) { - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isNonNegativeInteger( idx ) ) { - throw new TypeError( format( 'null2K', idx ) ); - } - if ( idx >= this._length ) { - return; - } - return fromWord( this._buffer[ idx ] ); -}); - -/** -* Returns a boolean indicating whether an array includes a provided value. -* -* @name includes -* @memberof Float16Array.prototype -* @type {Function} -* @param {number} searchElement - search element -* @param {integer} [fromIndex=0] - starting index (inclusive) -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a floating-point number -* @throws {TypeError} second argument must be an integer -* @returns {boolean} boolean indicating whether an array includes a value -* -* @example -* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] ); -* -* var bool = arr.includes( 1.0 ); -* // returns true -* -* bool = arr.includes( 1.0, 2 ); -* // returns false -* -* bool = arr.includes( 5.0 ); -* // returns false -*/ -setReadOnly( Float16Array.prototype, 'includes', function includes( searchElement, fromIndex ) { - var buf; - var i; - var v; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isNumber( searchElement ) ) { - throw new TypeError( format( 'null49', searchElement ) ); - } - if ( arguments.length > 1 ) { - if ( !isInteger( fromIndex ) ) { - throw new TypeError( format( 'null7f', fromIndex ) ); - } - if ( fromIndex < 0 ) { - fromIndex += this._length; - if ( fromIndex < 0 ) { - fromIndex = 0; - } - } - } else { - fromIndex = 0; - } - buf = this._buffer; - v = toWord( searchElement ); - for ( i = fromIndex; i < this._length; i++ ) { - if ( v === buf[ i ] ) { - return true; - } - } - return false; -}); - -/** -* Returns the first index at which a given element can be found. -* -* @name indexOf -* @memberof Float16Array.prototype -* @type {Function} -* @param {float16} searchElement - element to find -* @param {integer} [fromIndex=0] - starting index (inclusive) -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a floating-point number -* @throws {TypeError} second argument must be an integer -* @returns {integer} index or -1 -* -* @example -* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] ); -* -* var idx = arr.indexOf( 2.0 ); -* // returns 2 -* -* idx = arr.indexOf( 2.0, 3 ); -* // returns -1 -* -* idx = arr.indexOf( 3.0, 3 ); -* // returns 3 -*/ -setReadOnly( Float16Array.prototype, 'indexOf', function indexOf( searchElement, fromIndex ) { - var buf; - var i; - var v; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isNumber( searchElement ) ) { - throw new TypeError( format( 'null49', searchElement ) ); - } - if ( arguments.length > 1 ) { - if ( !isInteger( fromIndex ) ) { - throw new TypeError( format( 'null7f', fromIndex ) ); - } - if ( fromIndex < 0 ) { - fromIndex += this._length; - if ( fromIndex < 0 ) { - fromIndex = 0; - } - } - } else { - fromIndex = 0; - } - buf = this._buffer; - v = toWord( searchElement ); - for ( i = fromIndex; i < this._length; i++ ) { - if ( v === buf[ i ] ) { - return i; - } - } - return -1; -}); - -/** -* Returns a new string by concatenating all array elements. -* -* @name join -* @memberof Float16Array.prototype -* @type {Function} -* @param {string} [separator=','] - element separator -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a string -* @returns {string} string representation -* -* @example -* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] ); -* -* var str = arr.join(); -* // returns '0,1,2' -* -* str = arr.join( '|' ); -* // returns '0|1|2' -*/ -setReadOnly( Float16Array.prototype, 'join', function join( separator ) { - var buf; - var out; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( arguments.length > 0 ) { - if ( !isString( separator ) ) { - throw new TypeError( format( 'null3F', separator ) ); - } - } else { - separator = ','; - } - buf = this._buffer; - out = []; - for ( i = 0; i < this._length; i++ ) { - out.push( fromWord( buf[ i ] ) ); - } - return out.join( separator ); -}); - -/** -* Returns an iterator for iterating over each index key in a typed array. -* -* @name keys -* @memberof Float16Array.prototype -* @type {Function} -* @throws {TypeError} `this` must be a floating-point number array -* @returns {Iterator} iterator -* -* @example -* var arr = new Float16Array( [ 1.0, 2.0 ] ); -* -* var iter = arr.keys(); -* -* var v = iter.next().value; -* // returns 0 -* -* v = iter.next().value; -* // returns 1 -* -* var bool = iter.next().done; -* // returns true -*/ -setReadOnly( Float16Array.prototype, 'keys', function keys() { - var self; - var iter; - var len; - var FLG; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - self = this; - len = this._length; - - // Initialize an iteration index: - i = -1; - - // Create an iterator protocol-compliant object: - iter = {}; - setReadOnly( iter, 'next', next ); - setReadOnly( iter, 'return', end ); - - if ( ITERATOR_SYMBOL ) { - setReadOnly( iter, ITERATOR_SYMBOL, factory ); - } - return iter; - - /** - * Returns an iterator protocol-compliant object containing the next iterated value. - * - * @private - * @returns {Object} iterator protocol-compliant object - */ - function next() { - i += 1; - if ( FLG || i >= len ) { - return { - 'done': true - }; - } - return { - 'value': i, - 'done': false - }; - } - - /** - * Finishes an iterator. - * - * @private - * @param {*} [value] - value to return - * @returns {Object} iterator protocol-compliant object - */ - function end( value ) { - FLG = true; - if ( arguments.length ) { - return { - 'value': value, - 'done': true - }; - } - return { - 'done': true - }; - } - - /** - * Returns a new iterator. - * - * @private - * @returns {Iterator} iterator - */ - function factory() { - return self.keys(); - } -}); - -/** -* Returns the last index at which a given element can be found. -* -* @name lastIndexOf -* @memberof Float16Array.prototype -* @type {Function} -* @param {number} searchElement - element to find -* @param {integer} [fromIndex] - starting index (inclusive) -* @throws {TypeError} `this` must be a floating-point number -* @throws {TypeError} first argument must be a numeric value -* @throws {TypeError} second argument must be an integer -* @returns {integer} index or -1 -* -* @example -* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 2.0 ] ); -* -* var idx = arr.lastIndexOf( 2.0 ); -* // returns 4 -* -* idx = arr.lastIndexOf( 2.0, 3 ); -* // returns 2 -* -* idx = arr.lastIndexOf( 4.0, 3 ); -* // returns -1 -* -* idx = arr.lastIndexOf( 1.0, -3 ); -* // returns 1 -*/ -setReadOnly( Float16Array.prototype, 'lastIndexOf', function lastIndexOf( searchElement, fromIndex ) { - var buf; - var i; - var v; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isNumber( searchElement ) ) { - throw new TypeError( format( 'null49', searchElement ) ); - } - if ( arguments.length > 1 ) { - if ( !isInteger( fromIndex ) ) { - throw new TypeError( format( 'null7f', fromIndex ) ); - } - if ( fromIndex >= this._length ) { - fromIndex = this._length - 1; - } else if ( fromIndex < 0 ) { - fromIndex += this._length; - } - } else { - fromIndex = this._length - 1; - } - buf = this._buffer; - v = toWord( searchElement ); - for ( i = fromIndex; i >= 0; i-- ) { - if ( v === buf[ i ] ) { - return i; - } - } - return -1; -}); - -/** -* Number of array elements. -* -* @name length -* @memberof Float16Array.prototype -* @readonly -* @type {NonNegativeInteger} -* -* @example -* var arr = new Float16Array( 10 ); -* -* var len = arr.length; -* // returns 10 -*/ -setReadOnlyAccessor( Float16Array.prototype, 'length', function get() { - return this._length; -}); - -/** -* Returns a new array with each element being the result of a provided callback function. -* -* @name map -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} fcn - callback function -* @param {*} [thisArg] - callback function execution context -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a function -* @returns {Float16Array} new floating-point number array -* -* @example -* function scale( v ) { -* return v * 2.0; -* } -* -* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] ); -* -* var out = arr.map( scale ); -* // returns -* -* var z = out[ 0 ]; -* // returns 0.0 -* -* z = out[ 1 ]; -* // returns 2.0 -* -* z = out[ 2 ]; -* // returns 4.0 -*/ -setReadOnly( Float16Array.prototype, 'map', function map( fcn, thisArg ) { - var outbuf; - var out; - var buf; - var i; - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( format('null3c'), fcn ); - } - buf = this._buffer; - out = new this.constructor( this._length ); - outbuf = out._buffer; // eslint-disable-line no-underscore-dangle - for ( i = 0; i < this._length; i++ ) { - outbuf[ i ] = toWord( fcn.call( thisArg, fromWord( buf[ i ] ), i, this ) ); // eslint-disable-line max-len - } - return out; -}); - -/** -* Applies a provided callback function to each element of the array, in order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion. -* -* @name reduce -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} reducer - callback function -* @param {*} [initialValue] - initial value -* @throws {TypeError} `this` must be a floating-point number array -* @throws {Error} if not provided an initial value, the array must have at least one element -* @returns {*} accumulated result -* -* @example -* function add( acc, v ) { -* return acc + v; -* } -* -* var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); -* -* var out = arr.reduce( add, 0 ); -* // returns 6.0 -*/ -setReadOnly( Float16Array.prototype, 'reduce', function reduce( reducer, initialValue ) { - var buf; - var len; - var acc; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isFunction( reducer ) ) { - throw new TypeError( format( 'null3c', reducer ) ); - } - buf = this._buffer; - len = this._length; - if ( arguments.length > 1 ) { - acc = initialValue; - i = 0; - } else { - if ( len === 0 ) { - throw new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' ); - } - acc = fromWord( buf[ 0 ] ); - i = 1; - } - for ( ; i < len; i++ ) { - acc = reducer( acc, fromWord( buf[ i ] ), i, this ); - } - return acc; -}); - -/** -* Applies a provided callback function to each element of the array, in reverse order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion. -* -* @name reduceRight -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} reducer - callback function -* @param {*} [initialValue] - initial value -* @throws {TypeError} `this` must be a floating-point number array -* @throws {Error} if not provided an initial value, the array must have at least one element -* @returns {*} accumulated result -* -* @example -* function add( acc, v ) { -* return acc + v; -* } -* -* var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); -* -* var out = arr.reduceRight( add, 0 ); -* // returns 6.0 -*/ -setReadOnly( Float16Array.prototype, 'reduceRight', function reduceRight( reducer, initialValue ) { - var buf; - var len; - var acc; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isFunction( reducer ) ) { - throw new TypeError( format( 'null3c', reducer ) ); - } - buf = this._buffer; - len = this._length; - if ( arguments.length > 1 ) { - acc = initialValue; - i = len - 1; - } else { - if ( len === 0 ) { - throw new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' ); - } - acc = fromWord( buf[ len-1 ] ); - i = len - 2; - } - for ( ; i >= 0; i-- ) { - acc = reducer( acc, fromWord( buf[ i ] ), i, this ); - } - return acc; -}); - -/** -* Reverses an array in-place. -* -* @name reverse -* @memberof Float16Array.prototype -* @type {Function} -* @throws {TypeError} `this` must be a floating-point number array -* @returns {Float16Array} reversed array -* -* @example -* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] ); -* -* var out = arr.reverse(); -* // returns -* -* var v = out[ 0 ]; -* // returns 2.0 -* -* v = out[ 1 ]; -* // returns 1.0 -* -* v = out[ 2 ]; -* // returns 0.0 -*/ -setReadOnly( Float16Array.prototype, 'reverse', function reverse() { - var buf; - var tmp; - var len; - var N; - var i; - var j; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number 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 one or more array elements. -* -* ## Notes -* -* - When provided a typed array, we must check whether the source array shares the same buffer as the target array and whether the underlying memory overlaps. In particular, we are concerned with the following scenario: -* -* ```text -* buf: --------------------- -* src: --------------------- -* ``` -* -* In the above, as we copy values from `src`, we will overwrite values in the `src` view, resulting in duplicated values copied into the end of `buf`, which is not intended. Hence, to avoid overwriting source values, we must **copy** source values to a temporary array. -* -* In the other overlapping scenario, -* -* ```text -* buf: --------------------- -* src: --------------------- -* ``` -* -* by the time we begin copying into the overlapping region, we are copying from the end of `src`, a non-overlapping region, which means we don't run the risk of copying copied values, rather than the original `src` values, as intended. -* -* @name set -* @memberof Float16Array.prototype -* @type {Function} -* @param {(Collection|Float16Array)} value - value(s) -* @param {NonNegativeInteger} [i=0] - element index at which to start writing values -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a collection -* @throws {TypeError} index argument must be a nonnegative integer -* @throws {RangeError} index argument is out-of-bounds -* @throws {RangeError} target array lacks sufficient storage to accommodate source values -* @returns {void} -* -* @example -* var arr = new Float16Array( 10 ); -* -* var v = arr[ 0 ]; -* // returns 0.0 -* -* arr.set( [ 1.0, 2.0 ], 0 ); -* -* v = arr[ 0 ]; -* // returns 1.0 -*/ -setReadOnly( Float16Array.prototype, 'set', function set( value ) { - var sbuf; - var idx; - var buf; - var tmp; - var flg; - var N; - var i; - var j; - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isCollection( value ) ) { - throw new TypeError( format( 'null2O', value ) ); - } - buf = this._buffer; - if ( arguments.length > 1 ) { - idx = arguments[ 1 ]; - if ( !isNonNegativeInteger( idx ) ) { - throw new TypeError( format( 'null2L', idx ) ); - } - } else { - idx = 0; - } - N = value.length; - if ( idx+N > this._length ) { - throw new RangeError( format('null03') ); - } - if ( isFloat16Array( value ) ) { - sbuf = value._buffer; // eslint-disable-line no-underscore-dangle - flg = true; - } else { - sbuf = value; - flg = false; - } - // Check for overlapping memory... - j = buf.byteOffset + (idx*BYTES_PER_ELEMENT); - if ( - sbuf.buffer === buf.buffer && - ( - sbuf.byteOffset < j && - sbuf.byteOffset+sbuf.byteLength > j - ) - ) { - // We need to copy source values... - tmp = new Uint16Array( sbuf.length ); - for ( i = 0; i < sbuf.length; i++ ) { - tmp[ i ] = sbuf[ i ]; - } - sbuf = tmp; - } - if ( flg ) { - for ( i = 0; i < N; idx++, i++ ) { - buf[ idx ] = sbuf[ i ]; - } - } else { - for ( i = 0; i < N; idx++, i++ ) { - buf[ idx ] = toWord( sbuf[ i ] ); - } - } -}); - -/** -* Copies a portion of a typed array to a new typed array. -* -* @name slice -* @memberof Float16Array.prototype -* @type {Function} -* @param {integer} [begin] - start index (inclusive) -* @param {integer} [end] - end index (exclusive) -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be integer -* @throws {TypeError} second argument must be integer -* @returns {Float16Array} floating-point number array -* -* @example -* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] ); -* -* var out = arr.slice(); -* // returns -* -* var len = out.length; -* // returns 5 -* -* var v = out[ 0 ]; -* // returns 0.0 -* -* v = out[ len-1 ]; -* // returns 4.0 -* -* out = arr.slice( 1, -2 ); -* // returns -* -* len = out.length; -* // returns 2 -* -* v = out[ 0 ]; -* // returns 1.0 -* -* v = out[ len-1 ]; -* // returns 2.0 -*/ -setReadOnly( Float16Array.prototype, 'slice', function slice( begin, end ) { - var outlen; - var outbuf; - var out; - var buf; - var len; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - buf = this._buffer; - len = this._length; - if ( arguments.length === 0 ) { - begin = 0; - end = len; - } else { - if ( !isInteger( begin ) ) { - throw new TypeError( format( 'null7e', begin ) ); - } - if ( begin < 0 ) { - begin += len; - if ( begin < 0 ) { - begin = 0; - } - } - if ( arguments.length === 1 ) { - end = len; - } else { - if ( !isInteger( end ) ) { - throw new TypeError( format( 'null7f', end ) ); - } - if ( end < 0 ) { - end += len; - if ( end < 0 ) { - end = 0; - } - } else if ( end > len ) { - end = len; - } - } - } - if ( begin < end ) { - outlen = end - begin; - } else { - outlen = 0; - } - out = new this.constructor( outlen ); - outbuf = out._buffer; // eslint-disable-line no-underscore-dangle - for ( i = 0; i < outlen; i++ ) { - outbuf[ i ] = buf[ i+begin ]; - } - return out; -}); - -/** -* Tests whether at least one element in an array passes a test implemented by a predicate function. -* -* @name some -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - predicate function execution context -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a function -* @returns {boolean} boolean indicating whether at least one element passes a test -* -* @example -* function predicate( v ) { -* return v > 0.0; -* } -* -* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] ); -* -* var bool = arr.some( predicate ); -* // returns true -*/ -setReadOnly( Float16Array.prototype, 'some', function some( predicate, thisArg ) { - var buf; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'null3c', predicate ) ); - } - buf = this._buffer; - for ( i = 0; i < this._length; i++ ) { - if ( predicate.call( thisArg, fromWord( buf[ i ] ), i, this ) ) { - return true; - } - } - return false; -}); - -/** -* Sorts an array in-place. -* -* @name sort -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} [compareFcn] - comparison function -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a function -* @returns {Float16Array} sorted array -* -* @example -* function compare( a, b ) { -* if ( a < b ) { -* return -1; -* } -* if ( a > b ) { -* return 1; -* } -* return 0; -* } -* -* var arr = new Float16Array( [ 1.0, 0.0, 2.0 ] ); -* -* arr.sort( compare ); -* -* var v = arr[ 0 ]; -* // returns 0.0 -* -* v = arr[ 1 ]; -* // returns 1.0 -* -* v = arr[ 2 ]; -* // returns 2.0 -*/ -setReadOnly( Float16Array.prototype, 'sort', function sort( compareFcn ) { - var buf; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - buf = this._buffer; - if ( arguments.length === 0 ) { - buf.sort( defaultCompare ); - return this; - } - if ( !isFunction( compareFcn ) ) { - throw new TypeError( format( 'null3c', compareFcn ) ); - } - buf.sort( compare ); - return this; - - /** - * Default comparison function for float16 values. - * - * @private - * @param {unsigned16} a - unsigned 16-bit integer for comparison - * @param {unsigned16} b - unsigned 16-bit integer for comparison - * @returns {number} comparison result - */ - function defaultCompare( a, b ) { // eslint-disable-line stdlib/no-unnecessary-nested-functions - var x = fromWord( a ); - var y = fromWord( b ); - - // Handle NaN... - if ( isnan( x ) && isnan( y ) ) { - return 0; - } - if ( isnan( x ) ) { - return 1; - } - if ( isnan( y ) ) { - return -1; - } - // Normal comparison - if ( x < y ) { - return -1; - } - if ( x > y ) { - return 1; - } - return 0; - } - - /** - * Comparison function wrapper. - * - * @private - * @param {unsigned16} a - unsigned 16-bit integer for comparison - * @param {unsigned16} b - unsigned 16-bit integer for comparison - * @returns {number} comparison result - */ - function compare( a, b ) { - return compareFcn( fromWord( a ), fromWord( b ) ); - } -}); - -/** -* Creates a new typed array view over the same underlying `ArrayBuffer` and with the same underlying data type as the host array. -* -* @name subarray -* @memberof Float16Array.prototype -* @type {Function} -* @param {integer} [begin] - start index (inclusive) -* @param {integer} [end] - end index (exclusive) -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be an integer -* @throws {TypeError} second argument must be an integer -* @returns {Float16Array} subarray -* -* @example -* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] ); -* -* var subarr = arr.subarray(); -* // returns -* -* var len = subarr.length; -* // returns 5 -* -* var bool = subarr[ 0 ]; -* // returns 0.0 -* -* bool = subarr[ len-1 ]; -* // returns 4.0 -* -* subarr = arr.subarray( 1, -2 ); -* // returns -* -* len = subarr.length; -* // returns 2 -* -* bool = subarr[ 0 ]; -* // returns 1.0 -* -* bool = subarr[ len-1 ]; -* // returns 2.0 -*/ -setReadOnly( Float16Array.prototype, 'subarray', function subarray( begin, end ) { - var offset; - var buf; - var len; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - buf = this._buffer; - len = this._length; - if ( arguments.length === 0 ) { - begin = 0; - end = len; - } else { - if ( !isInteger( begin ) ) { - throw new TypeError( format( 'null7e', begin ) ); - } - if ( begin < 0 ) { - begin += len; - if ( begin < 0 ) { - begin = 0; - } - } - if ( arguments.length === 1 ) { - end = len; - } else { - if ( !isInteger( end ) ) { - throw new TypeError( format( 'null7f', end ) ); - } - if ( end < 0 ) { - end += len; - if ( end < 0 ) { - end = 0; - } - } else if ( end > len ) { - end = len; - } - } - } - if ( begin >= len ) { - len = 0; - offset = buf.byteLength; - } else if ( begin >= end ) { - len = 0; - offset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT ); - } else { - len = end - begin; - offset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT ); - } - return new this.constructor( buf.buffer, offset, ( len < 0 ) ? 0 : len ); -}); - -/** -* Serializes an array as a locale-specific string. -* -* @name toLocaleString -* @memberof Float16Array.prototype -* @type {Function} -* @param {(string|Array)} [locales] - locale identifier(s) -* @param {Object} [options] - configuration options -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a string or an array of strings -* @throws {TypeError} options argument must be an object -* @returns {string} string representation -* -* @example -* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] ); -* -* var str = arr.toLocaleString(); -* // returns '0,1,2' -*/ -setReadOnly( Float16Array.prototype, 'toLocaleString', function toLocaleString( locales, options ) { - var opts; - var loc; - var out; - var buf; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( arguments.length === 0 ) { - loc = []; - } else if ( isString( locales ) || isStringArray( locales ) ) { - loc = locales; - } else { - throw new TypeError( format( 'invalid argument. First argument must be a string or an array of strings. Value: `%s`.', locales ) ); - } - if ( arguments.length < 2 ) { - opts = {}; - } else if ( isObject( options ) ) { - opts = options; - } else { - throw new TypeError( format( 'null2V', options ) ); - } - buf = this._buffer; - out = []; - for ( i = 0; i < this._length; i++ ) { - out.push( fromWord( buf[ i ] ) ); - } - return out.toLocaleString( loc, opts ); -}); - -/** -* Returns a new typed array containing the elements in reversed order. -* -* @name toReversed -* @memberof Float16Array.prototype -* @type {Function} -* @throws {TypeError} `this` must be a floating-point number array -* @returns {Float16Array} reversed array -* -* @example -* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] ); -* -* var out = arr.toReversed(); -* // returns -* -* var v = out[ 0 ]; -* // returns 2.0 -* -* v = out[ 1 ]; -* // returns 1.0 -* -* v = out[ 2 ]; -* // returns 0.0 -*/ -setReadOnly( Float16Array.prototype, 'toReversed', function toReversed() { - var outbuf; - var out; - var len; - var buf; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number 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; -}); - -/** -* Returns a new typed array containing the elements in sorted order. -* -* @name toSorted -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} [compareFcn] - comparison function -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a function -* @returns {Float16Array} sorted array -* -* @example -* function compare( a, b ) { -* if ( a > b ) { -* return 1; -* } -* if ( a < b ) { -* return -1; -* } -* return 0; -* } -* -* var arr = new Float16Array( [ 2.0, 0.0, 1.0 ] ); -* -* var out = arr.toSorted( compare ); -* // returns -* -* var v = out[ 0 ]; -* // returns 0.0 -* -* v = out[ 1 ]; -* // returns 1.0 -* -* v = out[ 2 ]; -* // returns 2.0 -*/ -setReadOnly( Float16Array.prototype, 'toSorted', function toSorted( compareFcn ) { - var out; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - out = new this.constructor( this ); - if ( arguments.length === 0 ) { - return out.sort(); - } - return out.sort( compareFcn ); -}); - -/** -* Serializes an array as a string. -* -* @name toString -* @memberof Float16Array.prototype -* @type {Function} -* @throws {TypeError} `this` must be a floating-point number array -* @returns {string} string representation -* -* @example -* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] ); -* -* var str = arr.toString(); -* // returns '0,1,2' -*/ -setReadOnly( Float16Array.prototype, 'toString', function toString() { - var out; - var buf; - var i; - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - buf = this._buffer; - out = []; - for ( i = 0; i < this._length; i++ ) { - out.push( fromWord( buf[ i ] ) ); - } - return out.join( ',' ); -}); - -/** -* Returns an iterator for iterating over each value in a typed array. -* -* @name values -* @memberof Float16Array.prototype -* @type {Function} -* @throws {TypeError} `this` must be a floating-point number array -* @returns {Iterator} iterator -* -* @example -* var arr = new Float16Array( [ 0.0, 1.0 ] ); -* -* var iter = arr.values(); -* -* var v = iter.next().value; -* // returns 0.0 -* -* v = iter.next().value; -* // returns 1.0 -* -* var bool = iter.next().done; -* // returns true -*/ -setReadOnly( Float16Array.prototype, 'values', function values() { - var iter; - var self; - var len; - var FLG; - var buf; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - self = this; - buf = this._buffer; - len = this._length; - - // Initialize an iteration index: - i = -1; - - // Create an iterator protocol-compliant object: - iter = {}; - setReadOnly( iter, 'next', next ); - setReadOnly( iter, 'return', end ); - - if ( ITERATOR_SYMBOL ) { - setReadOnly( iter, ITERATOR_SYMBOL, factory ); - } - return iter; - - /** - * Returns an iterator protocol-compliant object containing the next iterated value. - * - * @private - * @returns {Object} iterator protocol-compliant object - */ - function next() { - i += 1; - if ( FLG || i >= len ) { - return { - 'done': true - }; - } - return { - 'value': fromWord( buf[ i ] ), - 'done': false - }; - } - - /** - * Finishes an iterator. - * - * @private - * @param {*} [value] - value to return - * @returns {Object} iterator protocol-compliant object - */ - function end( value ) { - FLG = true; - if ( arguments.length ) { - return { - 'value': value, - 'done': true - }; - } - return { - 'done': true - }; - } - - /** - * Returns a new iterator. - * - * @private - * @returns {Iterator} iterator - */ - function factory() { - return self.values(); - } -}); - -/** -* Returns a new typed array with the element at a provided index replaced with a provided value. -* -* @name with -* @memberof Float16Array.prototype -* @type {Function} -* @param {integer} index - element index -* @param {number} value - new value -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be an integer -* @throws {RangeError} index argument is out-of-bounds -* @throws {TypeError} second argument must be a floating-point number -* @returns {Float16Array} new typed array -* -* @example -* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] ); -* -* var out = arr.with( 0, 3.0 ); -* // returns -* -* var v = out[ 0 ]; -* // returns 3.0 -*/ -setReadOnly( Float16Array.prototype, 'with', function copyWith( index, value ) { - var out; - var len; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isInteger( index ) ) { - throw new TypeError( format( 'null7e', index ) ); - } - len = this._length; - if ( index < 0 ) { - index += len; - } - if ( index < 0 || index >= len ) { - throw new RangeError( format( 'nullFP', index ) ); - } - if ( !isNumber( value ) ) { - throw new TypeError( format( 'null4A', value ) ); - } - out = new this.constructor( this ); - out[ index ] = value; - return out; -}); - - -// EXPORTS // - -module.exports = Float16Array; diff --git a/package.json b/package.json index 0ed7acd..953c789 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.0", "description": "Float16Array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,65 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-uint16": "^0.2.3", - "@stdlib/assert-has-float16array-support": "^0.1.1", - "@stdlib/assert-has-iterator-symbol-support": "^0.2.3", - "@stdlib/assert-is-arraybuffer": "^0.2.3", - "@stdlib/assert-is-collection": "^0.2.3", - "@stdlib/assert-is-function": "^0.2.3", - "@stdlib/assert-is-integer": "^0.2.3", - "@stdlib/assert-is-nonnegative-integer": "^0.2.3", - "@stdlib/assert-is-number": "^0.2.3", - "@stdlib/assert-is-object": "^0.2.3", - "@stdlib/assert-is-string": "^0.2.3", - "@stdlib/assert-is-string-array": "^0.2.3", - "@stdlib/blas-base-gcopy": "^0.2.3", - "@stdlib/math-base-assert-is-nan": "^0.2.3", - "@stdlib/math-base-special-floor": "^0.2.4", - "@stdlib/number-float16-base-from-word": "^0.2.1", - "@stdlib/number-float16-base-to-word": "^0.1.1", - "@stdlib/number-float64-base-to-float16": "^0.1.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/symbol-iterator": "^0.2.3", - "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.4", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", - "@stdlib/utils-define-read-write-accessor": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.2.3", - "@stdlib/assert-has-own-property": "^0.2.3", - "@stdlib/assert-instance-of": "^0.3.1", - "@stdlib/assert-is-array": "^0.2.3", - "@stdlib/assert-is-boolean": "^0.2.3", - "@stdlib/assert-is-iterator-like": "^0.2.3", - "@stdlib/console-log-each": "^0.2.4", - "@stdlib/math-base-special-pow": "^0.3.1", - "@stdlib/random-array-uniform": "^0.2.2", - "@stdlib/utils-identity-function": "^0.2.3", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..c9f26e2 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 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 main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/polyfill/test.at.js b/test/polyfill/test.at.js deleted file mode 100644 index 2cd65c2..0000000 --- a/test/polyfill/test.at.js +++ /dev/null @@ -1,144 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `at` method for returning an array element', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'at' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.at ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.at.call( value, 0 ); - }; - } -}); - -tape( 'the method throws an error if provided an index argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - 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.at( value ); - }; - } -}); - -tape( 'the method returns `undefined` if provided an index which exceeds array dimensions', function test( t ) { - var arr; - var v; - var i; - - arr = new Float16Array( 10 ); - for ( i = -arr.length; i < arr.length; i++ ) { - if ( i < 0 ) { - v = arr.at( i-arr.length ); - t.strictEqual( v, void 0, 'returns expected value for index '+(i-arr.length) ); - } else { - v = arr.at( arr.length+i ); - t.strictEqual( v, void 0, 'returns expected value for index '+(arr.length+i) ); - } - } - t.end(); -}); - -tape( 'the method returns an array element', function test( t ) { - var arr; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( i+0.05 ); - } - - arr = new Float16Array( arr ); - - for ( i = -arr.length; i < arr.length; i++ ) { - v = arr.at( i ); - if ( i < 0 ) { - t.strictEqual( v, float64ToFloat16( arr.length + i + 0.05 ), 'returns expected value for index '+i ); - } else { - t.strictEqual( v, float64ToFloat16( i + 0.05 ), 'returns expected value for index '+i ); - } - } - t.end(); -}); diff --git a/test/polyfill/test.copy_within.js b/test/polyfill/test.copy_within.js deleted file mode 100644 index 0a8eb57..0000000 --- a/test/polyfill/test.copy_within.js +++ /dev/null @@ -1,281 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 Uint16Array = require( '@stdlib/array-uint16' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `copyWithin` method for copying a sequence of array elements within a floating-point number array', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'copyWithin' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within an array', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( 0, 3 ); - buf = new Uint16Array( arr.buffer ); - - // Overwritten: - t.strictEqual( buf[ 0 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 4.05 ), 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 2 ], toWord( 2.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (negative target)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( -arr.length, 3 ); - buf = new Uint16Array( arr.buffer ); - - // Overwritten: - t.strictEqual( buf[ 0 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 4.05 ), 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 2 ], toWord( 2.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (negative start)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( 0, -2 ); - buf = new Uint16Array( arr.buffer ); - - // Overwritten: - t.strictEqual( buf[ 0 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 4.05 ), 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 2 ], toWord( 2.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (end=length)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( 0, 3, arr.length ); - buf = new Uint16Array( arr.buffer ); - - // Overwritten: - t.strictEqual( buf[ 0 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 4.05 ), 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 2 ], toWord( 2.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (non-inclusive end)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( 2, 0, 2 ); - buf = new Uint16Array( arr.buffer ); - - // Remain the same: - t.strictEqual( buf[ 0 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - - // Overwritten: - t.strictEqual( buf[ 2 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 1.05 ), 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (negative end)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( 2, 0, -3 ); - buf = new Uint16Array( arr.buffer ); - - // Remain the same: - t.strictEqual( buf[ 0 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - - // Overwritten: - t.strictEqual( buf[ 2 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 1.05 ), 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (target >= length)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( arr.length, 3 ); - buf = new Uint16Array( arr.buffer ); - - // Remain the same: - t.strictEqual( buf[ 0 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 2 ], toWord( 2.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (target > start)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( 2, 0 ); - buf = new Uint16Array( arr.buffer ); - - // Remain the same: - t.strictEqual( buf[ 0 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - - // Overwritten: - t.strictEqual( buf[ 2 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 4 ], toWord( 2.05 ), 'returns expected value' ); - - t.end(); -}); diff --git a/test/polyfill/test.entries.js b/test/polyfill/test.entries.js deleted file mode 100644 index 4cea4d1..0000000 --- a/test/polyfill/test.entries.js +++ /dev/null @@ -1,238 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 proxyquire = require( 'proxyquire' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isNumber = require( '@stdlib/assert-is-number' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `entries` method for returning an iterator for iterating over array key-value pairs', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'entries' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.entries ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.entries.call( value ); - }; - } -}); - -tape( 'the method returns an iterator protocol-compliant object', function test( t ) { - var buf; - var arr; - var it; - var v; - var i; - - buf = [ 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( buf ); - - it = arr.entries(); - t.strictEqual( it.next.length, 0, 'has zero arity' ); - - for ( i = 0; i < arr.length; i++ ) { - v = it.next(); - t.strictEqual( isArray( v.value ), true, 'returns expected value' ); - t.strictEqual( v.value[ 0 ], i, 'returns expected value' ); - t.strictEqual( isNumber( v.value[ 1 ] ), true, 'returns expected value' ); - t.strictEqual( v.value[ 1 ], float64ToFloat16( buf[ i ] ), 'returns expected value' ); - t.strictEqual( typeof v.done, 'boolean', 'returns expected value' ); - } - t.end(); -}); - -tape( 'the method returns an iterator which has a `return` method for closing an iterator (no argument)', function test( t ) { - var buf; - var arr; - var it; - var v; - - buf = [ 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( buf ); - - it = arr.entries(); - - v = it.next(); - t.strictEqual( v.value[ 1 ], float64ToFloat16( buf[ 0 ] ), 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value[ 1 ], float64ToFloat16( buf[ 1 ] ), 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.return(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method returns an iterator which has a `return` method for closing an iterator (argument)', function test( t ) { - var buf; - var arr; - var it; - var v; - - buf = [ 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( buf ); - - it = arr.entries(); - - v = it.next(); - t.strictEqual( v.value[ 1 ], float64ToFloat16( buf[ 0 ] ), 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value[ 1 ], float64ToFloat16( buf[ 1 ] ), 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.return( 'finished' ); - t.strictEqual( v.value, 'finished', 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'if an environment supports `Symbol.iterator`, the method returns an iterable', function test( t ) { - var Float16Array; - var arr; - var buf; - var it1; - var it2; - var v1; - var v2; - var i; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - buf = [ 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( buf ); - - it1 = arr.entries(); - t.strictEqual( typeof it1[ '__ITERATOR_SYMBOL__' ], 'function', 'has method' ); - t.strictEqual( it1[ '__ITERATOR_SYMBOL__' ].length, 0, 'has zero arity' ); - - it2 = it1[ '__ITERATOR_SYMBOL__' ](); - t.strictEqual( typeof it2, 'object', 'returns expected value' ); - t.strictEqual( typeof it2.next, 'function', 'has `next` method' ); - t.strictEqual( typeof it2.return, 'function', 'has `return` method' ); - - for ( i = 0; i < arr.length; i++ ) { - v1 = it1.next().value; - v2 = it2.next().value; - t.strictEqual( v1[ 0 ], v2[ 0 ], 'returns expected value' ); - t.strictEqual( v1[ 1 ], v2[ 1 ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'if an environment does not support `Symbol.iterator`, the method does not return an "iterable"', function test( t ) { - var Float16Array; - var arr; - var buf; - var it; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/symbol-iterator': false - }); - - buf = [ 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( buf ); - - it = arr.entries(); - t.strictEqual( it[ ITERATOR_SYMBOL ], void 0, 'does not have property' ); - - t.end(); -}); diff --git a/test/polyfill/test.every.js b/test/polyfill/test.every.js deleted file mode 100644 index 384adc4..0000000 --- a/test/polyfill/test.every.js +++ /dev/null @@ -1,174 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `every` method for returning boolean indicating whether all elements pass a test', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'every' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.every ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.every.call( value, predicate ); - }; - } - - function predicate( v ) { - return v === 0.0; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.every( value ); - }; - } -}); - -tape( 'the method returns `true` if operating on an empty floating-point number array', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( 0 ); - bool = arr.every( predicate ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns `true` if all elements pass a test', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 1.05, 1.05, 1.05 ] ); - bool = arr.every( predicate ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v === float64ToFloat16( 1.05 ); - } -}); - -tape( 'the method returns `false` if one or more elements fail a test', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 1.05, 0.05, 1.05 ] ); - bool = arr.every( predicate ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v === float64ToFloat16( 1.05 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var bool; - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ 1.05, 1.05, 1.05, 1.05 ] ); - bool = arr.every( predicate, ctx ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v === float64ToFloat16( 1.05 ); - } -}); diff --git a/test/polyfill/test.fill.js b/test/polyfill/test.fill.js deleted file mode 100644 index 197e33f..0000000 --- a/test/polyfill/test.fill.js +++ /dev/null @@ -1,305 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 Uint16Array = require( '@stdlib/array-uint16' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `fill` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'fill' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.fill ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.fill.call( value, 1.0 ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a floating-point number', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 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.fill( value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - 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.fill( 1.0, value ); - }; - } -}); - -tape( 'the method throws an error if provided a third argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - 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.fill( 1.0, 0, value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.fill( 1.05 ); - - t.strictEqual( out instanceof Float16Array, true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 10 ); - out = arr.fill( 1.05 ); - - t.strictEqual( out, arr, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'if called with one argument, the method sets each array element to the provided value', function test( t ) { - var arr; - var buf; - var i; - - arr = new Float16Array( 3 ); - arr.fill( 1.05 ); - - buf = new Uint16Array( arr.buffer ); - - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( buf[ i ], toWord( 1.05 ), 'returns expected value' ); - } - - t.end(); -}); - -tape( 'if called with two arguments, the method sets each array element to the provided value starting from a start index (inclusive)', function test( t ) { - var arr; - var buf; - - arr = new Float16Array( 3 ); - buf = new Uint16Array( arr.buffer ); - - arr.fill( 1.05, 1 ); - - t.strictEqual( buf[ 0 ], toWord( 0.0 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 2 ], toWord( 1.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'if called with three arguments, the method sets each array element to the provided value starting from a start index (inclusive) until a specified end index (exclusive)', function test( t ) { - var arr; - var buf; - - arr = new Float16Array( 3 ); - buf = new Uint16Array( arr.buffer ); - - arr.fill( 1.05, 0, 2 ); - - t.strictEqual( buf[ 0 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 2 ], toWord( 0.0 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method supports negative indices', function test( t ) { - var arr; - var buf; - - arr = new Float16Array( 3 ); - buf = new Uint16Array( arr.buffer ); - - arr.fill( 1.05, -3, -1 ); - - t.strictEqual( buf[ 0 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 2 ], toWord( 0.0 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'if a provided start index resolves to a negative index, the method fills an array starting from the first element', function test( t ) { - var arr; - var buf; - var i; - - arr = new Float16Array( 3 ); - buf = new Uint16Array( arr.buffer ); - - arr.fill( 1.05, -10 ); - - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( buf[ i ], toWord( 1.05 ), 'returns expected value' ); - } - - t.end(); -}); - -tape( 'if a provided end index resolves to an index exceeding the last array element index, the method fills an array until the last element (inclusive)', function test( t ) { - var arr; - var buf; - var i; - - arr = new Float16Array( 3 ); - buf = new Uint16Array( arr.buffer ); - - arr.fill( 1.05, 1, 10 ); - - t.strictEqual( buf[ 0 ], toWord( 0.0 ), 'returns expected value' ); - for ( i = 1; i < arr.length; i++ ) { - t.strictEqual( buf[ i ], toWord( 1.05 ), 'returns expected value' ); - } - - t.end(); -}); - -tape( 'if a provided start index resolves to an index which is greater than or equal to a resolved end index, the method does not fill an array', function test( t ) { - var arr; - var buf; - - arr = new Float16Array( 3 ); - buf = new Uint16Array( arr.buffer ); - - arr.fill( 1.0, 2, 1 ); - - t.strictEqual( buf[ 0 ], toWord( 0.0 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 0.0 ), 'returns expected value' ); - t.strictEqual( buf[ 2 ], toWord( 0.0 ), 'returns expected value' ); - - t.end(); -}); diff --git a/test/polyfill/test.filter.js b/test/polyfill/test.filter.js deleted file mode 100644 index c5be66b..0000000 --- a/test/polyfill/test.filter.js +++ /dev/null @@ -1,226 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 instanceOf = require( '@stdlib/assert-instance-of' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `filter` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'filter' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.filter ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.filter.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( v === 1.0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.filter( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.filter( predicate ); - - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v === 1.0 ); - } -}); - -tape( 'the method returns a new floating-point number array containing only those elements which satisfy a test condition', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 1.05, 2.05 ] ); - expected = new Uint16Array( [ toWord( 1.05 ), toWord( 1.05 ) ] ); - actual = arr.filter( predicate ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v === float64ToFloat16( 1.05 ) ); - } -}); - -tape( 'the method copies all elements to a new array if all elements satisfy a test condition', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ) - ]); - actual = arr.filter( predicate ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.notEqual( actual, arr, 'returns a new instance' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v > 1.0 ); - } -}); - -tape( 'the method returns an empty array if no elements satisfy a test condition', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array( [] ); - actual = arr.filter( predicate ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.notEqual( actual, arr, 'returns a new instance' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 1.0 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var expected; - var actual; - var arr; - var buf; - var ctx; - - arr = new Float16Array( [ 1.05, 2.05, 1.05, 1.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 1.05 ), - toWord( 1.05 ) - ]); - ctx = { - 'count': 0 - }; - actual = arr.filter( predicate, ctx ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v === float64ToFloat16( 1.05 ) ); - } -}); diff --git a/test/polyfill/test.find.js b/test/polyfill/test.find.js deleted file mode 100644 index 64dffd0..0000000 --- a/test/polyfill/test.find.js +++ /dev/null @@ -1,174 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `find` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'find' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.find ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.find.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( v === 1.0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.find( value ); - }; - } -}); - -tape( 'the method returns `undefined` if operating on an empty floating-point number array', function test( t ) { - var arr; - var v; - - arr = new Float16Array( 0 ); - v = arr.find( predicate ); - - t.strictEqual( v, void 0, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns the first element which passes a test', function test( t ) { - var arr; - var v; - - arr = new Float16Array( [ 1.05, -2.05, 3.05, -4.05 ] ); - v = arr.find( predicate ); - - t.strictEqual( v, float64ToFloat16( -2.05 ), 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method returns `undefined` if all elements fail a test', function test( t ) { - var arr; - var v; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - v = arr.find( predicate ); - - t.strictEqual( v, void 0, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - var v; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ -1.05, -2.05, 3.05, 4.05, 5.05 ] ); - v = arr.find( predicate, ctx ); - - t.strictEqual( v, float64ToFloat16( 3.05 ), 'returns expected value' ); - t.strictEqual( ctx.count, 3, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v > 0.0 ); - } -}); diff --git a/test/polyfill/test.find_index.js b/test/polyfill/test.find_index.js deleted file mode 100644 index e1516da..0000000 --- a/test/polyfill/test.find_index.js +++ /dev/null @@ -1,173 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `findIndex` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'findIndex' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.findIndex ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.findIndex.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( v === 1.0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.findIndex( value ); - }; - } -}); - -tape( 'the method returns `-1` if operating on an empty floating-point number array', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( 0 ); - idx = arr.findIndex( predicate ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns the index of the first element which passes a test', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( [ 1.05, -2.05, 3.05, -4.05 ] ); - idx = arr.findIndex( predicate ); - - t.strictEqual( idx, 1, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0); - } -}); - -tape( 'the method returns `-1` if all elements fail a test', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - idx = arr.findIndex( predicate ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - var idx; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ -1.05, -2.05, 3.05, 4.05, 5.05 ] ); - idx = arr.findIndex( predicate, ctx ); - - t.strictEqual( idx, 2, 'returns expected value' ); - t.strictEqual( ctx.count, 3, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v > 0.0 ); - } -}); diff --git a/test/polyfill/test.find_last.js b/test/polyfill/test.find_last.js deleted file mode 100644 index 091e5a7..0000000 --- a/test/polyfill/test.find_last.js +++ /dev/null @@ -1,174 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `findLast` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'findLast' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.findLast ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.findLast.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( v === 0.0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.findLast( value ); - }; - } -}); - -tape( 'the method returns `undefined` if operating on an empty floating-point number array', function test( t ) { - var arr; - var v; - - arr = new Float16Array( 0 ); - v = arr.findLast( predicate ); - - t.strictEqual( v, void 0, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns the last element which passes a test', function test( t ) { - var arr; - var v; - - arr = new Float16Array( [ 1.05, -2.05, 3.05, -4.05 ] ); - v = arr.findLast( predicate ); - - t.strictEqual( v, float64ToFloat16( -4.05 ), 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method returns `undefined` if all elements fail a test', function test( t ) { - var arr; - var v; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - v = arr.findLast( predicate ); - - t.strictEqual( v, void 0, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - var v; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ -1.05, -2.05, 3.05, 4.05, 5.05 ] ); - v = arr.findLast( predicate, ctx ); - - t.strictEqual( v, float64ToFloat16( 5.05 ), 'returns expected value' ); - t.strictEqual( ctx.count, 1, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v > 0.0 ); - } -}); diff --git a/test/polyfill/test.find_last_index.js b/test/polyfill/test.find_last_index.js deleted file mode 100644 index 1b7b8df..0000000 --- a/test/polyfill/test.find_last_index.js +++ /dev/null @@ -1,173 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `findLastIndex` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'findLastIndex' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.findLastIndex ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.findLastIndex.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( v === 1.0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.findLastIndex( value ); - }; - } -}); - -tape( 'the method returns `-1` if operating on an empty floating-point number array', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( 0 ); - idx = arr.findLastIndex( predicate ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns the index of the last element which passes a test', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( [ 1.05, -2.05, 3.05, -4.05 ] ); - idx = arr.findLastIndex( predicate ); - - t.strictEqual( idx, 3, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method returns `-1` if all elements fail a test', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - idx = arr.findLastIndex( predicate ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - var idx; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ -1.05, -2.05, 3.05, 4.05, 5.05 ] ); - idx = arr.findLastIndex( predicate, ctx ); - - t.strictEqual( idx, 4, 'returns expected value' ); - t.strictEqual( ctx.count, 1, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v > 0.0 ); - } -}); diff --git a/test/polyfill/test.for_each.js b/test/polyfill/test.for_each.js deleted file mode 100644 index 98e75c2..0000000 --- a/test/polyfill/test.for_each.js +++ /dev/null @@ -1,196 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `forEach` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'forEach' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.forEach ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.forEach.call( value, fcn ); - }; - } - - function fcn( v ) { - if ( !isNumber( v ) ) { - t.fail( 'should be a number' ); - } - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.forEach( value ); - }; - } -}); - -tape( 'the method should not invoke a provided callback function if operating on an empty floating-point array', function test( t ) { - var arr; - - arr = new Float16Array( 0 ); - arr.forEach( fcn ); - - t.end(); - - function fcn() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns `undefined`', function test( t ) { - var arr; - var out; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - out = arr.forEach( fcn ); - - t.strictEqual( out, void 0, 'returns expected value' ); - t.end(); - - function fcn( v ) { - if ( !isNumber( v ) ) { - t.fail( 'should be a number' ); - } - } -}); - -tape( 'the method invokes a provided function for each element in an array', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var arr; - - indices = []; - values = []; - arrays = []; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - arr.forEach( fcn ); - - expected = [ - float64ToFloat16( 1.05 ), - float64ToFloat16( 2.05 ), - float64ToFloat16( 3.05 ), - float64ToFloat16( 4.05 ) - ]; - - t.deepEqual( values, expected, 'returns expected value' ); - t.deepEqual( indices, [ 0, 1, 2, 3 ], 'returns expected value' ); - t.strictEqual( arrays[ 0 ], arr, 'returns expected value' ); - t.strictEqual( arrays[ 1 ], arr, 'returns expected value' ); - t.strictEqual( arrays[ 2 ], arr, 'returns expected value' ); - t.strictEqual( arrays[ 3 ], arr, 'returns expected value' ); - - t.end(); - - function fcn( v, i, arr ) { - values.push( v ); - indices.push( i ); - arrays.push( arr ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - arr.forEach( fcn, ctx ); - - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function fcn() { - this.count += 1; // eslint-disable-line no-invalid-this - } -}); diff --git a/test/polyfill/test.from.js b/test/polyfill/test.from.js deleted file mode 100644 index d9cfc1a..0000000 --- a/test/polyfill/test.from.js +++ /dev/null @@ -1,654 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 proxyquire = require( 'proxyquire' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is a `from` method for creating a 16-bit floating-point number array from an array-like object or an iterable', function test( t ) { - var arr; - - t.strictEqual( hasOwnProp( Float16Array, 'from' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.from ), true, 'has method' ); - - arr = Float16Array.from( [] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a constructor', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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 Float16Array.from.call( value, [] ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array constructor', function test( t ) { - var values; - var i; - - values = [ - {}, - null, - 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 Float16Array.from.call( value, [] ); - }; - } -}); - -tape( 'the method throws an error if not provided an iterable or array-like object', function test( t ) { - var values; - var i; - - 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 Float16Array.from( value ); - }; - } -}); - -tape( 'the method throws an error if not provided an iterable or array-like object (callback)', function test( t ) { - var values; - var i; - - 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 Float16Array.from( value, clbk ); - }; - } - - function clbk() { - return 1.0; - } -}); - -tape( 'the method throws an error if not provided an iterable or array-like object (callback, thisArg)', function test( t ) { - var values; - var i; - - 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 Float16Array.from( value, clbk, {} ); - }; - } - - function clbk() { - return 1.0; - } -}); - -tape( 'the method throws an error if provided a second argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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 Float16Array.from( [], value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not a function (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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 Float16Array.from( [], value, {} ); - }; - } -}); - -tape( 'the method returns a floating-point number array', function test( t ) { - var arr; - var v; - - // Generic array: - arr = Float16Array.from( [] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Float16Array.from( [ 1.0, 2.0, 3.0, 4.0 ] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - // Generic array containing non-numeric values: - arr = Float16Array.from( [ 'beep' ] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - arr = Float16Array.from( [ null, 4 ] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - arr = Float16Array.from( [ true, {}, '' ] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 3, 'returns expected value' ); - - // Typed array: - arr = Float16Array.from( new Uint16Array( 0 ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Float16Array.from( new Uint16Array( [ 1, 1 ] ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // Floating-point number typed array: - arr = Float16Array.from( new Float16Array( 0 ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Float16Array.from( new Float16Array( [ 1.0, 2.0 ] ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method returns a floating-point number array (iterable)', function test( t ) { - var Float16Array; - var iter; - var arr; - var v; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - iter = { - 'next': next, - 'i': 0, - 'N': 4 - }; - arr = Float16Array.from( createIterable( iter ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, iter.N, 'returns expected value' ); - - t.end(); - - function hasSupport() { - return true; - } - - function createIterable( iterator ) { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return iterator; - } - } - - function next() { - iter.i += 1; - if ( iter.i <= iter.N ) { - return { - 'value': 1.0 - }; - } - return { - 'done': true - }; - } -}); - -tape( 'the method supports providing a "map" function which is invoked for each source element', function test( t ) { - var arr; - var v; - - // Generic array: - arr = Float16Array.from( [], clbk1 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Float16Array.from( [ 1.0, 2.0, 3.0, 4.0 ], clbk1 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - // Generic array containing non-numeric values: - arr = Float16Array.from( [ 'beep' ], clbk2 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - arr = Float16Array.from( [ null ], clbk2 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - arr = Float16Array.from( [ [], {} ], clbk1 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - arr = Float16Array.from( [ 4, 5 ], clbk1 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // Typed array: - arr = Float16Array.from( new Uint16Array( 0 ), clbk1 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Float16Array.from( new Uint16Array( [ 1, 1 ] ), clbk1 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // Floating-point number typed array: - arr = Float16Array.from( new Float16Array( 0 ), clbk2 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Float16Array.from( new Float16Array( [ true, true ] ), clbk2 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - t.end(); - - function clbk1( v ) { - return v; - } - - function clbk2() { - return true; - } -}); - -tape( 'the method supports providing a "map" function which is invoked for each iterated value', function test( t ) { - var Float16Array; - var iter; - var arr; - var v; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - iter = { - 'next': next, - 'i': 0, - 'N': 4 - }; - arr = Float16Array.from( createIterable( iter ), clbk ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, iter.N, 'returns expected value' ); - - t.end(); - - function hasSupport() { - return true; - } - - function createIterable( iterator ) { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return iterator; - } - } - - function next() { - iter.i += 1; - if ( iter.i <= iter.N ) { - return { - 'value': 1.0 - }; - } - return { - 'done': true - }; - } - - function clbk( v ) { - return !v; - } -}); - -tape( 'the method supports providing a `this` context for a provided map function', function test( t ) { - var arr; - var ctx; - - ctx = { - 'count': 0 - }; - arr = Float16Array.from( [ 1.0, 2.0, 3.0, 4.0 ], clbk1, ctx ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function clbk1( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v; - } -}); - -tape( 'the method supports providing a `this` context for a provided map function (iterable)', function test( t ) { - var Float16Array; - var iter; - var ctx; - var arr; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - iter = { - 'next': next, - 'i': 0, - 'N': 4 - }; - ctx = { - 'count': 0 - }; - - arr = Float16Array.from( createIterable( iter ), clbk, ctx ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function hasSupport() { - return true; - } - - function createIterable( iterator ) { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return iterator; - } - } - - function next() { - iter.i += 1; - if ( iter.i <= iter.N ) { - return { - 'value': 1.0 - }; - } - return { - 'done': true - }; - } - - function clbk( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v; - } -}); - -tape( 'the method throws an error if provided a non-iterable object (non-ES2015+)', function test( t ) { - var Float16Array; - var values; - var i; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - {}, - { - '0': 1, - '1': 2, - '2': 3 - } - ]; - 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 Float16Array.from( value ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the method throws an error if provided a non-iterable object (ES2015+)', function test( t ) { - var Float16Array; - var values; - var i; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - values = [ - {}, - { - '0': 1, - '1': 2, - '2': 3 - }, - { - '__SYMBOL_ITERATOR__': null - }, - { - '__SYMBOL_ITERATOR__': 'beep' - }, - { - '__SYMBOL_ITERATOR__': nonIterable1 - }, - { - '__SYMBOL_ITERATOR__': nonIterable2 - } - ]; - 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 Float16Array.from( value ); - }; - } - - function hasSupport() { - return true; - } - - function nonIterable1() { - return null; - } - - function nonIterable2() { - return {}; - } -}); diff --git a/test/polyfill/test.includes.js b/test/polyfill/test.includes.js deleted file mode 100644 index 8bb9850..0000000 --- a/test/polyfill/test.includes.js +++ /dev/null @@ -1,222 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `includes` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'includes' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.includes ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.includes.call( value, true ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a numeric value', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 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.includes( value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - 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.includes( true, value ); - }; - } -}); - -tape( 'the method returns `false` if operating on an empty floating-point number array', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( 0 ); - bool = arr.includes( 1.0 ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `false` if a floating-point number is not found', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( 10 ); - bool = arr.includes( 1.0 ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `true` if an array contains a specified floating-point number', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05] ); - bool = arr.includes( float64ToFloat16( 1.05 ) ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `false` if provided a second argument which exceeds the input array length', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( 10 ); - bool = arr.includes( 0.0, 20 ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 1.05, 1.05, 1.05 ] ); - - bool = arr.includes( float64ToFloat16( 1.05 ), 0 ); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = arr.includes( float64ToFloat16( 2.05 ), 1 ); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = arr.includes( float64ToFloat16( 2.05 ), 3 ); - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index (negative)', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 1.05, 1.05, 1.05 ] ); - - bool = arr.includes( float64ToFloat16( 1.05 ), -5 ); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = arr.includes( float64ToFloat16( 2.05 ), -2 ); - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'when provided a starting index which resolves to an index which is less than zero, the method searches from the first array element', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 1.05, 1.05, 1.05 ] ); - - bool = arr.includes( float64ToFloat16( 1.05 ), -10 ); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = arr.includes( float64ToFloat16( 2.05 ), -10 ); - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); -}); diff --git a/test/polyfill/test.index_of.js b/test/polyfill/test.index_of.js deleted file mode 100644 index b432c6d..0000000 --- a/test/polyfill/test.index_of.js +++ /dev/null @@ -1,222 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `indexOf` method for returning the index of an array element', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'indexOf' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.indexOf ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.indexOf.call( value, 1.0 ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a numeric value', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 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.indexOf( value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - 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.indexOf( 1.0, value ); - }; - } -}); - -tape( 'the method returns `-1` if operating on an empty floating-point number array', function test( t ) { - var arr; - var idx; - - arr = new Float16Array(); - idx = arr.indexOf( 1.0 ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `-1` if a numeric value is not found', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( 10 ); - idx = arr.indexOf( 1.0 ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns the index of the first match if a numeric value is found', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - idx = arr.indexOf( float64ToFloat16( 2.05 ) ); - - t.strictEqual( idx, 1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `-1` if provided a second argument which exceeds the input array length', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( 10 ); - idx = arr.indexOf( 1.0, 20 ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 2.05, 5.05 ] ); - - idx = arr.indexOf( float64ToFloat16( 2.05 ), 0 ); - t.strictEqual( idx, 1, 'returns expected value' ); - - idx = arr.indexOf( float64ToFloat16( 2.05 ), 2 ); - t.strictEqual( idx, 3, 'returns expected value' ); - - idx = arr.indexOf( float64ToFloat16( 2.05 ), 4 ); - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index (negative)', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 2.05, 5.05 ] ); - - idx = arr.indexOf( float64ToFloat16( 2.05 ), -5 ); - t.strictEqual( idx, 1, 'returns expected value' ); - - idx = arr.indexOf( float64ToFloat16( 2.05 ), -1 ); - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'when provided a starting index which resolves to an index which is less than zero, the method searches from the first array element', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 2.05, 5.05 ] ); - - idx = arr.indexOf( float64ToFloat16( 2.05 ), -10 ); - t.strictEqual( idx, 1, 'returns expected value' ); - - idx = arr.indexOf( float64ToFloat16( 1.05 ), -10 ); - t.strictEqual( idx, 0, 'returns expected value' ); - t.end(); -}); diff --git a/test/polyfill/test.join.js b/test/polyfill/test.join.js deleted file mode 100644 index 007f1cb..0000000 --- a/test/polyfill/test.join.js +++ /dev/null @@ -1,173 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `join` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'join' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.join ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.join.call( value ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `separator` argument which is not a string', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - 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.join( value ); - }; - } -}); - -tape( 'the method returns an empty string if invoked on an empty array', function test( t ) { - var str; - var arr; - - arr = new Float16Array( 0 ); - str = arr.join(); - - t.strictEqual( str, '', 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a string representation of a floating-point number array with elements separated by a separator', function test( t ) { - var expected; - var str; - var arr; - var i; - - arr = new Float16Array( [ 0.05, 1.05, 2.05, 3.05, 4.05 ] ); - - expected = float64ToFloat16( 0.05 ); - for ( i = 1; i < arr.length; i++ ) { - expected += '@' + float64ToFloat16( i + 0.05 ); - } - - str = arr.join( '@' ); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a string representation of a floating-point number array with elements separated by a separator (single element)', function test( t ) { - var expected; - var str; - var arr; - - arr = new Float16Array( [ 1.05 ] ); - expected = '' + float64ToFloat16( 1.05 ); - - str = arr.join(); - - t.strictEqual( str, expected, 'returns expected value' ); - - arr = new Float16Array( [ 1.05 ] ); - expected = '' + float64ToFloat16( 1.05 ); - - str = arr.join( '@' ); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if the method is invoked without a separator argument, the method returns a string representation of a floating-point number array with elements separated by a comma', function test( t ) { - var expected; - var str; - var arr; - var i; - - arr = new Float16Array( [ 0.05, 1.05, 2.05, 3.05, 4.05 ] ); - - expected = float64ToFloat16( 0.05 ); - for ( i = 1; i < arr.length; i++ ) { - expected += ',' + float64ToFloat16( i + 0.05 ); - } - - str = arr.join(); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); diff --git a/test/polyfill/test.js b/test/polyfill/test.js deleted file mode 100644 index 6e254ad..0000000 --- a/test/polyfill/test.js +++ /dev/null @@ -1,740 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 proxyquire = require( 'proxyquire' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var arr = new Float16Array( 0 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var ctor; - var arr; - - ctor = Float16Array; - - arr = ctor( 0 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (no argument)', function test( t ) { - var arr = new Float16Array(); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (no argument, no new)', function test( t ) { - var ctor; - var arr; - - ctor = Float16Array; - - arr = ctor(); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (length)', function test( t ) { - var arr = new Float16Array( 10 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (length, no new)', function test( t ) { - var ctor; - var arr; - - ctor = Float16Array; - - arr = ctor( 10 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (array)', function test( t ) { - var arr = new Float16Array( [] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (array, no new)', function test( t ) { - var ctor; - var arr; - - ctor = Float16Array; - - arr = ctor( [] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (typed array)', function test( t ) { - var arr = new Float16Array( new Uint16Array( 0 ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (typed array, no new)', function test( t ) { - var ctor; - var arr; - - ctor = Float16Array; - - arr = ctor( new Uint16Array( 0 ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (iterable)', function test( t ) { - var Float16Array; - var arr; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - arr = new Float16Array( createIterable() ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); - - function hasSupport() { - return true; - } - - function createIterable() { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return { - 'next': next - }; - } - - function next() { - return { - 'done': true - }; - } - } -}); - -tape( 'the constructor returns a 16-bit floating-point number array (iterable, no new)', function test( t ) { - var ctor; - var arr; - - ctor = proxyquire( './../../lib/polyfill', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - arr = ctor( createIterable() ); - t.strictEqual( arr instanceof ctor, true, 'returns expected value' ); - - t.end(); - - function hasSupport() { - return true; - } - - function createIterable() { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return { - 'next': next - }; - } - - function next() { - return { - 'done': true - }; - } - } -}); - -tape( 'the constructor returns a 16-bit floating-point number array (ArrayBuffer)', function test( t ) { - var arr = new Float16Array( new ArrayBuffer( 0 ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (ArrayBuffer, no new)', function test( t ) { - var ctor; - var arr; - - ctor = Float16Array; - - arr = ctor( new ArrayBuffer( 0 ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (ArrayBuffer, byte offset)', function test( t ) { - var arr = new Float16Array( new ArrayBuffer( 8 ), 8 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (ArrayBuffer, byte offset, no new)', function test( t ) { - var ctor; - var arr; - - ctor = Float16Array; - - arr = ctor( new ArrayBuffer( 8 ), 8 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (ArrayBuffer, byte offset, length)', function test( t ) { - var arr = new Float16Array( new ArrayBuffer( 8 ), 8, 0 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (ArrayBuffer, byte offset, length, no new)', function test( t ) { - var ctor; - var arr; - - ctor = Float16Array; - - arr = ctor( new ArrayBuffer( 8 ), 8, 0 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'attached to the constructor is a property returning the number of bytes per array element', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Float16Array.BYTES_PER_ELEMENT, 2, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the constructor is a property returning the constructor name', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array, 'name' ), true, 'has property' ); - t.strictEqual( Float16Array.name, 'Float16Array', 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance having a `BYTES_PER_ELEMENT` property returning the number of bytes per array element', function test( t ) { - var arr; - - t.strictEqual( hasOwnProp( Float16Array.prototype, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Float16Array.prototype.BYTES_PER_ELEMENT, 2, 'returns expected value' ); - - arr = new Float16Array( 0 ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance having a `buffer` property for returning the underlying memory (i.e., ArrayBuffer)', function test( t ) { - var arr; - var buf; - - arr = new Float16Array( 0 ); - buf = arr.buffer; - t.strictEqual( isArrayBuffer( buf ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance having a `byteLength` property for returning the number of bytes belonging to the array view', function test( t ) { - var arr; - var v; - - arr = new Float16Array( 0 ); - v = arr.byteLength; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( new ArrayBuffer( 64 ), 8 ); - v = arr.byteLength; - t.strictEqual( v, 56, 'returns expected value' ); - - arr = new Float16Array( new ArrayBuffer( 64 ), 64 ); - v = arr.byteLength; - t.strictEqual( v, 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance having a `byteOffset` property for returning the byte offset pointing to the first array element in the underlying memory', function test( t ) { - var arr; - var v; - - arr = new Float16Array( 0 ); - v = arr.byteOffset; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( new ArrayBuffer( 64 ), 32 ); - v = arr.byteOffset; - t.strictEqual( v, 32, 'returns expected value' ); - - arr = new Float16Array( new ArrayBuffer( 64 ), 64 ); - v = arr.byteOffset; - t.strictEqual( v, 64, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance having a `length` property for returning the number of array elements', function test( t ) { - var arr; - var v; - - // No arguments: - arr = new Float16Array(); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - // Explicit array length: - arr = new Float16Array( 0 ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( 10 ); - v = arr.length; - t.strictEqual( v, 10, 'returns expected value' ); - - // Generic array: - arr = new Float16Array( [] ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - // Typed array: - arr = new Float16Array( new Uint16Array( 0 ) ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( new Uint16Array( [ 1.0, 1.0 ] ) ); - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // Float16 typed array: - arr = new Float16Array( new Float16Array( 0 ) ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( new Float16Array( [ 1.0, 2.0 ] ) ); - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // ArrayBuffer: - arr = new Float16Array( new ArrayBuffer( 64 ), 32 ); - v = arr.length; - t.strictEqual( v, 16, 'returns expected value' ); - - arr = new Float16Array( new ArrayBuffer( 64 ), 64 ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( new ArrayBuffer( 64 ), 32, 2 ); - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance having a `length` property for returning the number of array elements (iterable)', function test( t ) { - var Float16Array; - var iter; - var arr; - var v; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - iter = { - 'next': next, - 'i': 0, - 'N': 4 - }; - arr = new Float16Array( createIterable( iter ) ); - v = arr.length; - t.strictEqual( v, iter.N, 'returns expected value' ); - - t.end(); - - function hasSupport() { - return true; - } - - function createIterable( iterator ) { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return iterator; - } - } - - function next() { - iter.i += 1; - if ( iter.i <= iter.N ) { - return { - 'value': 1.0 - }; - } - return { - 'done': true - }; - } -}); - -tape( 'the constructor throws an error if provided an ArrayBuffer which is not a multiple of 2', function test( t ) { - var values; - var i; - - values = [ - 1, - 3, - 5, - 7, - 9, - 11, - 101, - 1001 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided an ArrayBuffer having a byte length equal to '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Float16Array( new ArrayBuffer( value ) ); - }; - } -}); - -tape( 'the constructor throws an error if provided a non-iterable object (non-ES2015+)', function test( t ) { - var Float16Array; - var values; - var i; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - {}, - { - '0': 1, - '1': 2, - '2': 3 - } - ]; - 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 new Float16Array( value ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the constructor throws an error if provided a non-iterable object (ES2015+)', function test( t ) { - var Float16Array; - var values; - var i; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - values = [ - {}, - { - '0': 1, - '1': 2, - '2': 3 - }, - { - '__SYMBOL_ITERATOR__': null - }, - { - '__SYMBOL_ITERATOR__': 'beep' - }, - { - '__SYMBOL_ITERATOR__': nonIterable1 - }, - { - '__SYMBOL_ITERATOR__': nonIterable2 - } - ]; - 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 new Float16Array( value ); - }; - } - - function hasSupport() { - return true; - } - - function nonIterable1() { - return null; - } - - function nonIterable2() { - return {}; - } -}); - -tape( 'the constructor throws an error if not provided a length, iterable, array-like object, or ArrayBuffer', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - 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 new Float16Array( value ); - }; - } -}); - -tape( 'the constructor throws an error if provided more than one argument and the first argument is not an ArrayBuffer', function test( t ) { - var values; - var i; - - 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 new Float16Array( value, 0 ); - }; - } -}); - -tape( 'the constructor throws an error if provided a byte offset argument which is not a nonnegative integer', function test( t ) { - var values; - var i; - - values = [ - '5', - -1, - 3.14, - 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 new Float16Array( new ArrayBuffer( 64 ), value ); - }; - } -}); - -tape( 'the constructor throws an error if provided a byte offset argument which is not a multiple of 2', function test( t ) { - var values; - var i; - - values = [ - 1, - 3, - 5, - 7, - 9, - 11, - 101, - 1001 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Float16Array( new ArrayBuffer( 1e3 ), value ); - }; - } -}); - -tape( 'the constructor throws an error if provided a byte offset argument such that the view byte length is not a multiple of 8', function test( t ) { - var values; - var i; - - values = [ - 2, - 4, - 6, - 8, - 10, - 12, - 14, - 16, - 18, - 20 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Float16Array( new ArrayBuffer( 101 ), value ); - }; - } -}); - -tape( 'the constructor throws an error if provided a length argument which is not a nonnegative integer (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - -1, - 3.14, - 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 new Float16Array( new ArrayBuffer( 64 ), 0, value ); - }; - } -}); - -tape( 'the constructor throws an error if provided insufficient memory to accommodate byte offset and length arguments', function test( t ) { - var values; - var i; - - values = [ - 8, - 16, - 24, - 32 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Float16Array( new ArrayBuffer( 100 ), value, 1e3 ); - }; - } -}); diff --git a/test/polyfill/test.keys.js b/test/polyfill/test.keys.js deleted file mode 100644 index 59c6210..0000000 --- a/test/polyfill/test.keys.js +++ /dev/null @@ -1,261 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 proxyquire = require( 'proxyquire' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `keys` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'keys' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.keys ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.keys.call( value ); - }; - } -}); - -tape( 'the method returns an iterator protocol-compliant object', function test( t ) { - var expected; - var arr; - var it; - var i; - var r; - var e; - - arr = new Float16Array( [ 1.05, 2.05 ] ); - expected = [ - { - 'value': 0, - 'done': false - }, - { - 'value': 1, - 'done': false - }, - { - 'done': true - } - ]; - it = arr.keys(); - - t.strictEqual( typeof it, 'object', 'returns expected value' ); - t.strictEqual( typeof it.next, 'function', 'has next method' ); - - for ( i = 0; i < expected.length; i++ ) { - r = it.next(); - e = expected[ i ]; - if ( e.value === void 0 ) { - t.deepEqual( r, e, 'returns expected value' ); - } else { - t.strictEqual( r.value, e.value, 'returns expected value' ); - t.strictEqual( r.done, e.done, 'returns expected value' ); - } - } - - t.end(); -}); - -tape( 'the method returns an iterator which does not iterate over empty arrays', function test( t ) { - var expected; - var arr; - var it; - var i; - var v; - - arr = new Float16Array( [] ); - expected = [ - { - 'done': true - }, - { - 'done': true - }, - { - 'done': true - } - ]; - it = arr.keys(); - - t.strictEqual( typeof it, 'object', 'returns expected value' ); - t.strictEqual( typeof it.next, 'function', 'has next method' ); - - for ( i = 0; i < expected.length; i++ ) { - v = it.next(); - t.deepEqual( v, expected[ i ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (no argument)', function test( t ) { - var arr; - var it; - var v; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - it = arr.keys(); - - v = it.next(); - t.strictEqual( v.value, 0, 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, 1, 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.return(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (argument)', function test( t ) { - var arr; - var it; - var v; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - it = arr.keys(); - - v = it.next(); - t.strictEqual( v.value, 0, 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, 1, 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.return( 'beep' ); - t.strictEqual( v.value, 'beep', 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'if an environment supports `Symbol.iterator`, the method returns an iterable', function test( t ) { - var Float16Array; - var arr; - var buf; - var it1; - var it2; - var v1; - var v2; - var i; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - buf = [ 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( buf ); - - it1 = arr.keys(); - t.strictEqual( typeof it1[ '__ITERATOR_SYMBOL__' ], 'function', 'has method' ); - t.strictEqual( it1[ '__ITERATOR_SYMBOL__' ].length, 0, 'has zero arity' ); - - it2 = it1[ '__ITERATOR_SYMBOL__' ](); - t.strictEqual( typeof it2, 'object', 'returns expected value' ); - t.strictEqual( typeof it2.next, 'function', 'has `next` method' ); - t.strictEqual( typeof it2.return, 'function', 'has `return` method' ); - - for ( i = 0; i < arr.length; i++ ) { - v1 = it1.next().value; - v2 = it2.next().value; - t.strictEqual( v1, v2, 'returns expected value' ); - } - t.end(); -}); - -tape( 'if an environment does not support `Symbol.iterator`, the method does not return an "iterable"', function test( t ) { - var Float16Array; - var arr; - var buf; - var it; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/symbol-iterator': false - }); - - buf = [ 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( buf ); - - it = arr.keys(); - t.strictEqual( it[ ITERATOR_SYMBOL ], void 0, 'does not have property' ); - - t.end(); -}); diff --git a/test/polyfill/test.last_index_of.js b/test/polyfill/test.last_index_of.js deleted file mode 100644 index 6a2fe99..0000000 --- a/test/polyfill/test.last_index_of.js +++ /dev/null @@ -1,211 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `lastIndexOf` method for returning the index of an array element', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'lastIndexOf' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.lastIndexOf ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.lastIndexOf.call( value, true ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a numeric value', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 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.lastIndexOf( value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - 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.lastIndexOf( true, value ); - }; - } -}); - -tape( 'the method returns `-1` if operating on an empty floating-point number array', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( 0 ); - idx = arr.lastIndexOf( 0.0 ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `-1` if a numeric value is not found', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( 10 ); - idx = arr.lastIndexOf( 1.0 ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns the index of the first match when searching from the end of the array if a search element is found', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 1.05, 2.05 ] ); - idx = arr.lastIndexOf( float64ToFloat16( 1.05 ) ); - - t.strictEqual( idx, 2, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 2.05, 1.05, 1.05 ] ); - - idx = arr.lastIndexOf( float64ToFloat16( 1.05 ), 4 ); - t.strictEqual( idx, 4, 'returns expected value' ); - - idx = arr.lastIndexOf( float64ToFloat16( 2.05 ), 2 ); - t.strictEqual( idx, 2, 'returns expected value' ); - - idx = arr.lastIndexOf( float64ToFloat16( 2.05 ), 0 ); - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index (negative)', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 2.05, 1.05, 1.05 ] ); - - idx = arr.lastIndexOf( float64ToFloat16( 1.05 ), -3 ); - t.strictEqual( idx, 0, 'returns expected value' ); - - idx = arr.lastIndexOf( float64ToFloat16( 2.05 ), -1 ); - t.strictEqual( idx, 2, 'returns expected value' ); - t.end(); -}); - -tape( 'when the method is provided a starting index which resolves to an index which exceeds the maximum array index, the method searches from the last array element', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 2.05, 1.05, 1.05 ] ); - - idx = arr.lastIndexOf( float64ToFloat16( 1.05 ), 10 ); - t.strictEqual( idx, 4, 'returns expected value' ); - - idx = arr.lastIndexOf( float64ToFloat16( 2.05 ), 10 ); - t.strictEqual( idx, 2, 'returns expected value' ); - t.end(); -}); diff --git a/test/polyfill/test.map.js b/test/polyfill/test.map.js deleted file mode 100644 index 233d1d8..0000000 --- a/test/polyfill/test.map.js +++ /dev/null @@ -1,178 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 identity = require( '@stdlib/utils-identity-function' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `map` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'map' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.map ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.map.call( value, identity ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.map( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.map( identity ); - - t.strictEqual( instanceOf( out, Float16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - t.notEqual( out, arr, 'returns a new instance' ); - t.end(); -}); - -tape( 'the method returns a new floating-point number array containing elements which are the result of a provided callback function', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( -1.05 ), - toWord( -2.05 ), - toWord( -3.05 ), - toWord( -4.05 ) - ]); - actual = arr.map( invert ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.notEqual( actual, arr, 'returns a new instance' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); - - function invert( v ) { - return -v; - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var expected; - var actual; - var arr; - var buf; - var ctx; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( -1.05 ), - toWord( -2.05 ), - toWord( -3.05 ), - toWord( -4.05 ) - ]); - ctx = { - 'count': 0 - }; - actual = arr.map( invert, ctx ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.strictEqual( ctx.count, 6, 'returns expected value' ); - t.end(); - - function invert( v, i ) { - this.count += i; // eslint-disable-line no-invalid-this - return -v; - } -}); diff --git a/test/polyfill/test.of.js b/test/polyfill/test.of.js deleted file mode 100644 index 5031bb5..0000000 --- a/test/polyfill/test.of.js +++ /dev/null @@ -1,130 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `of` method for creating a 16-bit floating-point number array from a variable number of arguments', function test( t ) { - var arr; - - t.strictEqual( hasOwnProp( Float16Array, 'of' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.of ), true, 'has method' ); - - arr = Float16Array.of(); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a constructor', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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 Float16Array.of.call( value, true, true ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point array constructor', function test( t ) { - var values; - var i; - - values = [ - {}, - null, - 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 Float16Array.of.call( value, true, true ); - }; - } -}); - -tape( 'the method returns a floating-point number array', function test( t ) { - var arr; - var v; - - // No arguments: - arr = Float16Array.of(); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - // Numeric arguments: - arr = Float16Array.of( 1.0, 2.0, 3.0, 4.0 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - // Non-numeric arguments: - arr = Float16Array.of( 1, {}, 0, null, 'beep' ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 5, 'returns expected value' ); - - // Mixed arguments: - arr = Float16Array.of( true, 1, false, 0 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - t.end(); -}); diff --git a/test/polyfill/test.reduce.js b/test/polyfill/test.reduce.js deleted file mode 100644 index 7d9cbc0..0000000 --- a/test/polyfill/test.reduce.js +++ /dev/null @@ -1,189 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `reduce` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'reduce' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.reduce ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.reduce.call( value, reducer ); - }; - } - - function reducer( acc, value ) { - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.reduce( value ); - }; - } -}); - -tape( 'the method throws an error if not provided an initial value when operating on an empty floating-point number array', function test( t ) { - var arr; - - arr = new Float16Array( 0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - arr.reduce( reducer ); - } - - function reducer( acc, value ) { - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method uses the first element of the array as the initial value when an initial value is not provided', function test( t ) { - var valueArray; - var accArray; - var expected; - var actual; - var arr; - var ind; - - arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - accArray = [ 1.0, 3.0 ]; - valueArray = [ 2.0, 3.0 ]; - expected = float64ToFloat16( 6.0 ); - actual = arr.reduce( reducer ); - - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); - - function reducer( acc, value, index ) { - ind = index-1; - t.strictEqual( acc, float64ToFloat16( accArray[ ind ] ), 'returns expected value' ); - t.strictEqual( value, float64ToFloat16( valueArray[ ind ] ), 'returns expected value' ); - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method supports providing an initial value as the second argument', function test( t ) { - var valueArray; - var accArray; - var expected; - var actual; - var arr; - - arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - accArray = [ 2.0, 3.0, 5.0 ]; - valueArray = [ 1.0, 2.0, 3.0 ]; - expected = 8.0; - actual = arr.reduce( reducer, 2.0 ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value, index ) { - t.strictEqual( acc, float64ToFloat16( accArray[ index ] ), 'returns expected value' ); - t.strictEqual( value, float64ToFloat16( valueArray[ index ] ), 'returns expected value' ); - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method returns the accumulated result', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = float64ToFloat16( 10.20 ); - actual = arr.reduce( reducer ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value ) { - return float64ToFloat16( acc + value ); - } -}); diff --git a/test/polyfill/test.reduce_right.js b/test/polyfill/test.reduce_right.js deleted file mode 100644 index 0d27e43..0000000 --- a/test/polyfill/test.reduce_right.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `reduceRight` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'reduceRight' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.reduceRight ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.reduceRight.call( value, reducer ); - }; - } - - function reducer( acc, value ) { - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.reduceRight( value ); - }; - } -}); - -tape( 'the method throws an error if not provided an initial value when operating on an empty floating-point number array', function test( t ) { - var arr; - - arr = new Float16Array( 0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - arr.reduceRight( reducer ); - } - - function reducer( acc, value ) { - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method uses the last element of the array as the initial value when an initial value is not provided', function test( t ) { - var valueArray; - var accArray; - var expected; - var actual; - var arr; - var len; - - arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - len = arr.length; - accArray = [ 3.0, 5.0 ]; - valueArray = [ 2.0, 1.0 ]; - expected = float64ToFloat16( 6.0 ); - actual = arr.reduceRight( reducer ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value, index ) { - var ind = (len-index-2); - t.strictEqual( acc, float64ToFloat16( accArray[ ind ] ), 'returns expected value' ); - t.strictEqual( value, float64ToFloat16( valueArray[ ind ] ), 'returns expected value' ); - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method supports providing an initial value as the second argument', function test( t ) { - var valueArray; - var accArray; - var expected; - var actual; - var arr; - var len; - - arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - len = arr.length; - accArray = [ 2.0, 5.0, 7.0 ]; - valueArray = [ 3.0, 2.0, 1.0 ]; - expected = 8.0; - actual = arr.reduceRight( reducer, 2.0 ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value, index ) { - var ind = (len-index-1); - t.strictEqual( acc, float64ToFloat16( accArray[ ind ] ), 'returns expected value' ); - t.strictEqual( value, float64ToFloat16( valueArray[ ind ] ), 'returns expected value' ); - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method returns the accumulated result', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = float64ToFloat16( 10.20 ); - actual = arr.reduceRight( reducer ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value ) { - return float64ToFloat16( acc + value ); - } -}); diff --git a/test/polyfill/test.reverse.js b/test/polyfill/test.reverse.js deleted file mode 100644 index 080a4c3..0000000 --- a/test/polyfill/test.reverse.js +++ /dev/null @@ -1,122 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 instanceOf = require( '@stdlib/assert-instance-of' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, '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( Float16Array.prototype, 'reverse' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.reverse ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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 floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - 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 floating-point number array in-place', function test( t ) { - var expected; - var arr; - var buf; - var out; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05, 5.05 ] ); - expected = new Uint16Array([ - toWord( 5.05 ), - toWord( 4.05 ), - toWord( 3.05 ), - toWord( 2.05 ), - toWord( 1.05 ) - ]); - out = arr.reverse(); - buf = new Uint16Array( arr.buffer ); - - t.strictEqual( instanceOf( arr, Float16Array ), true, 'returns expected value' ); - t.strictEqual( out, arr, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 10 ); - out = arr.reverse(); - - t.strictEqual( out.length, 10, 'returns expected value' ); - t.end(); -}); diff --git a/test/polyfill/test.set.js b/test/polyfill/test.set.js deleted file mode 100644 index d5e0ebb..0000000 --- a/test/polyfill/test.set.js +++ /dev/null @@ -1,259 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `set` method for setting one or more array elements', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.set ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.set.call( value, 0 ); - }; - } -}); - -tape( 'the method throws an error if provided an index argument which is not a nonnegative integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - -5, - 3.14, - 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.set( [ 1.0 ], value ); - }; - } -}); - -tape( 'the method throws an error if provided an index argument which is out-of-bounds', function test( t ) { - var values; - var arr1; - var arr2; - var i; - - arr1 = new Float16Array( 10 ); - arr2 = []; - for ( i = 0; i < arr1.length; i++ ) { - arr2.push( 1.0 ); - } - - values = [ - 1, - 2, - 3, - 4, - 5 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr1.set( arr2, value ); - }; - } -}); - -tape( 'the method sets one or more array elements', function test( t ) { - var arr; - var v; - var i; - - arr = new Float16Array( 10 ); - - v = arr[ 0 ]; - t.strictEqual( v, 0.0, 'returns expected value' ); - - // No index argument: - arr.set( [ 1.0 ] ); - - v = arr[ 0 ]; - t.strictEqual( v, 1.0, 'returns expected value' ); - - arr.set( [ 0.0 ] ); - - // Index argument: - for ( i = 0; i < arr.length; i++ ) { - v = arr[ i ]; - t.strictEqual( v, 0.0, 'returns expected value' ); - - arr.set( [ 1.05 ], i ); - - v = arr[ i ]; - t.strictEqual( v, float64ToFloat16( 1.05 ), 'returns expected value' ); - } - - // Multiple values, no index argument: - arr.set( [ 1.05, 2.05 ] ); - - v = arr[ 0 ]; - t.strictEqual( v, float64ToFloat16( 1.05 ), 'returns expected value' ); - - v = arr[ 1 ]; - t.strictEqual( v, float64ToFloat16( 2.05 ), 'returns expected value' ); - - // Multiple values, index argument: - arr.set( [ 1.05, 2.05 ], 2 ); - - v = arr[ 2 ]; - t.strictEqual( v, float64ToFloat16( 1.05 ), 'returns expected value' ); - - v = arr[ 3 ]; - t.strictEqual( v, float64ToFloat16( 2.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method sets an array element (floating-point number array; shared buffer)', function test( t ) { - var byteOffset; - var arr; - var src; - var buf; - var ab; - var v; - var i; - - byteOffset = 112; - - ab = new ArrayBuffer( 240 ); - arr = new Float16Array( ab, byteOffset, 10 ); - - // Overlapping (requires copy), multiple values, no index argument: - buf = [ 1.05, 2.05 ]; - src = new Float16Array( ab, byteOffset-(1*arr.BYTES_PER_ELEMENT), 2 ); - for ( i = 0; i < buf.length; i++ ) { - src[ i ] = buf[ i ]; - } - arr.set( src ); - - v = arr[ 0 ]; - t.strictEqual( v, float64ToFloat16( buf[ 0 ] ), 'returns expected value' ); - - v = arr[ 1 ]; - t.strictEqual( v, float64ToFloat16( buf[ 1 ] ), 'returns expected value' ); - - // Overlapping (requires copy), multiple values, index argument: - buf = [ -1.05, -2.05 ]; - src = new Float16Array( ab, byteOffset+(1*arr.BYTES_PER_ELEMENT), 2 ); - for ( i = 0; i < buf.length; i++ ) { - src[ i ] = buf[ i ]; - } - arr.set( src, 2 ); - - v = arr[ 2 ]; - t.strictEqual( v, float64ToFloat16( buf[ 0 ] ), 'returns expected value' ); - - v = arr[ 3 ]; - t.strictEqual( v, float64ToFloat16( buf[ 1 ] ), 'returns expected value' ); - - // Overlapping (no copy), multiple values, no index argument: - buf = [ 3.05, 4.05 ]; - src = new Float16Array( ab, byteOffset+(1*arr.BYTES_PER_ELEMENT), 2 ); - for ( i = 0; i < buf.length; i++ ) { - src[ i ] = buf[ i ]; - } - arr.set( src ); - - v = arr[ 0 ]; - t.strictEqual( v, float64ToFloat16( buf[ 0 ] ), 'returns expected value' ); - - v = arr[ 1 ]; - t.strictEqual( v, float64ToFloat16( buf[ 1 ] ), 'returns expected value' ); - - // Overlapping (no copy), multiple values, index argument: - buf = [ -3.05, -4.05 ]; - src = new Float16Array( ab, byteOffset+(3*arr.BYTES_PER_ELEMENT), 2 ); - for ( i = 0; i < buf.length; i++ ) { - src[ i ] = buf[ i ]; - } - arr.set( src, 2 ); - - v = arr[ 2 ]; - t.strictEqual( v, float64ToFloat16( buf[ 0 ] ), 'returns expected value' ); - - v = arr[ 3 ]; - t.strictEqual( v, float64ToFloat16( buf[ 1 ] ), 'returns expected value' ); - - t.end(); -}); diff --git a/test/polyfill/test.slice.js b/test/polyfill/test.slice.js deleted file mode 100644 index f6743cb..0000000 --- a/test/polyfill/test.slice.js +++ /dev/null @@ -1,311 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 instanceOf = require( '@stdlib/assert-instance-of' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `slice` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'slice' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.slice ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.slice.call( value ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.slice( value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.slice( 0, value ); - }; - } -}); - -tape( 'the method returns an empty typed array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.slice(); - - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'if called without arguments, the method returns a typed array containing the same elements as the original array', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ) - ]); - actual = arr.slice(); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.notEqual( actual, arr, 'returns a new instance' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if called with one argument, the method returns a typed array containing elements starting from a specified beginning index (inclusive)', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ) - ]); - actual = arr.slice( 1 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if provided two arguments, the method returns a typed array containing elements starting from a specified beginning index (inclusive) and ending at a specified stop index (exclusive)', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ) - ]); - actual = arr.slice( 1, 3 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ) - ]); - actual = arr.slice( 1, 30 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method resolves negative indices relative to the last element', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ) - ]); - actual = arr.slice( -3, -1 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ) - ]); - actual = arr.slice( -30, -2 ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty typed array if a resolved beginning index exceeds a resolved ending index', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array( [] ); - actual = arr.slice( 2, 0 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty typed array if a resolved beginning index exceeds the maximum array index', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array( [] ); - actual = arr.slice( 5 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty typed array if a resolved ending index is less than or equal to zero', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); - expected = new Uint16Array( [] ); - actual = arr.slice( 2, -8 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - - actual = arr.slice( 1, 0 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); diff --git a/test/polyfill/test.some.js b/test/polyfill/test.some.js deleted file mode 100644 index dfa9cda..0000000 --- a/test/polyfill/test.some.js +++ /dev/null @@ -1,196 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `some` method for returning boolean indicating whether at least one element passes a test', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'some' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.some ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.some.call( value, predicate ); - }; - } - - function predicate( v ) { - return v === 1.0; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.some( value ); - }; - } -}); - -tape( 'the method returns `false` if operating on an empty floating-point number array', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( 0 ); - bool = arr.some( predicate ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns `true` if at least one element passes a test', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - bool = arr.some( predicate ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v === float64ToFloat16( 1.05 ); - } -}); - -tape( 'the method returns `false` if all elements fail a test', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - bool = arr.some( predicate ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v === float64ToFloat16( 5.05 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var bool; - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - bool = arr.some( predicate, ctx ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v === float64ToFloat16( 4.05 ); - } -}); - -tape( 'the method stops executing upon encountering the first element which passes a test', function test( t ) { - var bool; - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - bool = arr.some( predicate, ctx ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.strictEqual( ctx.count, 1, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v === float64ToFloat16( 1.05 ); - } -}); diff --git a/test/polyfill/test.sort.js b/test/polyfill/test.sort.js deleted file mode 100644 index 1ebbfd6..0000000 --- a/test/polyfill/test.sort.js +++ /dev/null @@ -1,189 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 instanceOf = require( '@stdlib/assert-instance-of' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Comparison function. -* -* @private -* @param {boolean} a - first value for comparison -* @param {boolean} b - second value for comparison -* @returns {number} comparison result -*/ -function compareFcn( a, b ) { - if ( a < b ) { - return -1; - } - if ( a > b ) { - return 1; - } - return 0; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `sort` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'sort' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.sort ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.sort.call( value, compareFcn ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.sort( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.sort( compareFcn ); - - t.strictEqual( out.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the method sorts elements of a floating-point number array in-place', function test( t ) { - var expected; - var arr; - var out; - var buf; - - arr = new Float16Array( [ 4.05, 3.05, 1.05, 5.05, 2.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ), - toWord( 5.05 ) - ]); - out = arr.sort( compareFcn ); - buf = new Uint16Array( out.buffer ); - - t.strictEqual( instanceOf( arr, Float16Array ), true, 'returns expected value' ); - t.strictEqual( out, arr, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - - arr = new Float16Array( [ 2.05, 1.05, -1.05, 0.05, -2.05 ] ); - expected = new Uint16Array([ - toWord( -2.05 ), - toWord( -1.05 ), - toWord( 0.05 ), - toWord( 1.05 ), - toWord( 2.05 ) - ]); - out = arr.sort( compareFcn ); - buf = new Uint16Array( out.buffer ); - - t.strictEqual( instanceOf( arr, Float16Array ), true, 'returns expected value' ); - t.strictEqual( out, arr, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Float16Array( [ 4.05, 3.05, 1.05, 5.05, 2.05 ] ); - out = arr.sort( compareFcn ); - - t.strictEqual( out.length, arr.length, 'returns expected value' ); - t.end(); -}); diff --git a/test/polyfill/test.subarray.js b/test/polyfill/test.subarray.js deleted file mode 100644 index c6d42d1..0000000 --- a/test/polyfill/test.subarray.js +++ /dev/null @@ -1,308 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 instanceOf = require( '@stdlib/assert-instance-of' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `subarray` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'subarray' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.subarray ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.subarray.call( value ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.subarray( value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.subarray( 0, value ); - }; - } -}); - -tape( 'the method returns empty array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.subarray(); - - t.strictEqual( out.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'if called without arguments, the method returns a view containing the same elements as the original array', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ) - ]); - actual = arr.subarray(); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if called with one argument, the method returns a view containing elements starting from a specified beginning index (inclusive)', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ) - ]); - actual = arr.subarray( 1 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if provided two arguments, the method returns a view containing elements starting from a specified beginning index (inclusive) and ending at a specified stop index (exclusive)', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ) - ]); - actual = arr.subarray( 1, 3 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method resolves negative indices relative to the last element', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ) - ]); - actual = arr.subarray( -3, -1 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 2.05 ) - ]); - actual = arr.subarray( -30, -2 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty view if a resolved beginning index exceeds a resolved ending index', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array( [] ); - actual = arr.subarray( 2, 0 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty view if a resolved beginning index exceeds the maximum array index', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array( [] ); - actual = arr.subarray( 5 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty view if a resolved ending index is less than or equal to zero', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array( [] ); - actual = arr.subarray( 2, -8 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - - actual = arr.subarray( 1, 0 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); diff --git a/test/polyfill/test.to_locale_string.js b/test/polyfill/test.to_locale_string.js deleted file mode 100644 index 96fb9b0..0000000 --- a/test/polyfill/test.to_locale_string.js +++ /dev/null @@ -1,187 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `toLocaleString` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'toLocaleString' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.toLocaleString ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.toLocaleString.call( value ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a string or an array of strings', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 0 ); - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - {}, - [ 1, 2, 3 ], - 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.toLocaleString( value ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a string or an array of strings (options)', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 0 ); - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - {}, - [ 1, 2, 3 ], - 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.toLocaleString( value, {} ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an object', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array(); - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - 'beep', - [], - 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.toLocaleString( 'en-GB', value ); - }; - } -}); - -tape( 'the method returns an empty string if invoked on an empty array', function test( t ) { - var str; - var arr; - - arr = new Float16Array( 0 ); - str = arr.toLocaleString(); - - t.strictEqual( str, '', 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a string representation of a floating-point number array', function test( t ) { - var expected; - var str; - var arr; - - arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - expected = '1,2,3'; - - str = arr.toLocaleString(); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); diff --git a/test/polyfill/test.to_reversed.js b/test/polyfill/test.to_reversed.js deleted file mode 100644 index a3f8da5..0000000 --- a/test/polyfill/test.to_reversed.js +++ /dev/null @@ -1,121 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 instanceOf = require( '@stdlib/assert-instance-of' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, '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( Float16Array.prototype, 'toReversed' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.toReversed ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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 floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - 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 buf; - var out; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05, 5.05 ] ); - expected = new Uint16Array([ - toWord( 5.05 ), - toWord( 4.05 ), - toWord( 3.05 ), - toWord( 2.05 ), - toWord( 1.05 ) - ]); - out = arr.toReversed(); - buf = new Uint16Array( out.buffer ); - - t.strictEqual( instanceOf( out, Float16Array ), true, 'returns expected value' ); - t.notEqual( out, arr, 'returns a new instance' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 10 ); - out = arr.toReversed(); - - t.strictEqual( out.length, 10, 'returns expected value' ); - t.end(); -}); diff --git a/test/polyfill/test.to_sorted.js b/test/polyfill/test.to_sorted.js deleted file mode 100644 index e011bef..0000000 --- a/test/polyfill/test.to_sorted.js +++ /dev/null @@ -1,172 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 instanceOf = require( '@stdlib/assert-instance-of' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Comparison function. -* -* @private -* @param {boolean} a - first value for comparison -* @param {boolean} b - second value for comparison -* @returns {number} comparison result -*/ -function compareFcn( a, b ) { - if ( a < b ) { - return -1; - } - if ( a > b ) { - return 1; - } - return 0; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `toSorted` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'toSorted' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.toSorted ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.toSorted.call( value, compareFcn ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.toSorted( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.toSorted( compareFcn ); - - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a new typed array containing elements in sorted order', function test( t ) { - var expected; - var arr; - var out; - var buf; - - arr = new Float16Array( [ 4.05, 3.05, 1.05, 5.05, 2.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ), - toWord( 5.05 ) - ]); - out = arr.toSorted( compareFcn ); - buf = new Uint16Array( out.buffer ); - - t.strictEqual( instanceOf( out, Float16Array ), true, 'returns expected value' ); - t.notEqual( out, arr, 'returns a new instance' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Float16Array( [ 4.05, 3.05, 1.05, 5.05, 2.05 ] ); - out = arr.toSorted( compareFcn ); - - t.strictEqual( out.length, arr.length, 'returns expected value' ); - t.end(); -}); diff --git a/test/polyfill/test.to_string.js b/test/polyfill/test.to_string.js deleted file mode 100644 index b0c098b..0000000 --- a/test/polyfill/test.to_string.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `toString` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.toString ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.toString.call( value ); - }; - } -}); - -tape( 'the method returns an empty string if invoked on an empty array', function test( t ) { - var str; - var arr; - - arr = new Float16Array( 0 ); - str = arr.toString(); - - t.strictEqual( str, '', 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a string representation of a floating-point number array', function test( t ) { - var expected; - var str; - var arr; - - arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - expected = '1,2,3,4'; - - str = arr.toString(); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); diff --git a/test/polyfill/test.values.js b/test/polyfill/test.values.js deleted file mode 100644 index ce5fc09..0000000 --- a/test/polyfill/test.values.js +++ /dev/null @@ -1,264 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 proxyquire = require( 'proxyquire' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var isNumber = require( '@stdlib/assert-is-number' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `values` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'values' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.values ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.values.call( value ); - }; - } -}); - -tape( 'the method returns an iterator protocol-compliant object', function test( t ) { - var expected; - var arr; - var it; - var i; - var r; - var e; - - arr = new Float16Array( [ 1.05, 2.05 ] ); - expected = [ - { - 'value': float64ToFloat16( 1.05 ), - 'done': false - }, - { - 'value': float64ToFloat16( 2.05 ), - 'done': false - }, - { - 'done': true - } - ]; - it = arr.values(); - - t.strictEqual( typeof it, 'object', 'returns expected value' ); - t.strictEqual( typeof it.next, 'function', 'has next method' ); - - for ( i = 0; i < expected.length; i++ ) { - r = it.next(); - e = expected[ i ]; - if ( e.value === void 0 ) { - t.deepEqual( r, e, 'returns expected value' ); - } else { - t.strictEqual( isNumber( r.value ), true, 'returns expected value' ); - t.strictEqual( r.value, e.value, 'returns expected value' ); - t.strictEqual( r.done, e.done, 'returns expected value' ); - } - } - - t.end(); -}); - -tape( 'the method returns an iterator which does not iterate over empty arrays', function test( t ) { - var expected; - var arr; - var it; - var i; - var v; - - arr = new Float16Array( [] ); - expected = [ - { - 'done': true - }, - { - 'done': true - }, - { - 'done': true - } - ]; - it = arr.values(); - - t.strictEqual( typeof it, 'object', 'returns expected value' ); - t.strictEqual( typeof it.next, 'function', 'has next method' ); - - for ( i = 0; i < expected.length; i++ ) { - v = it.next(); - t.deepEqual( v, expected[ i ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (no argument)', function test( t ) { - var arr; - var it; - var v; - - arr = new Float16Array( [ 1.05, 2.05, 3.05 ] ); - it = arr.values(); - - v = it.next(); - t.strictEqual( v.value, float64ToFloat16( 1.05 ), 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, float64ToFloat16( 2.05 ), 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.return(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (argument)', function test( t ) { - var arr; - var it; - var v; - - arr = new Float16Array( [ 1.05, 2.05, 3.05 ] ); - it = arr.values(); - - v = it.next(); - t.strictEqual( v.value, float64ToFloat16( 1.05 ), 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, float64ToFloat16( 2.05 ), 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.return( 'beep' ); - t.strictEqual( v.value, 'beep', 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'if an environment supports `Symbol.iterator`, the method returns an iterable', function test( t ) { - var Float16Array; - var arr; - var buf; - var it1; - var it2; - var v1; - var v2; - var i; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - buf = [ 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( buf ); - - it1 = arr.values(); - t.strictEqual( typeof it1[ '__ITERATOR_SYMBOL__' ], 'function', 'has method' ); - t.strictEqual( it1[ '__ITERATOR_SYMBOL__' ].length, 0, 'has zero arity' ); - - it2 = it1[ '__ITERATOR_SYMBOL__' ](); - t.strictEqual( typeof it2, 'object', 'returns expected value' ); - t.strictEqual( typeof it2.next, 'function', 'has `next` method' ); - t.strictEqual( typeof it2.return, 'function', 'has `return` method' ); - - for ( i = 0; i < arr.length; i++ ) { - v1 = it1.next().value; - v2 = it2.next().value; - t.strictEqual( v1, v2, 'returns expected value' ); - } - t.end(); -}); - -tape( 'if an environment does not support `Symbol.iterator`, the method does not return an "iterable"', function test( t ) { - var Float16Array; - var arr; - var buf; - var it; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/symbol-iterator': false - }); - - buf = [ 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( buf ); - - it = arr.values(); - t.strictEqual( it[ ITERATOR_SYMBOL ], void 0, 'does not have property' ); - - t.end(); -}); diff --git a/test/polyfill/test.with.js b/test/polyfill/test.with.js deleted file mode 100644 index 0b6eda1..0000000 --- a/test/polyfill/test.with.js +++ /dev/null @@ -1,213 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `with` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'with' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.with ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.with.call( value, 0, true ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 3.14, - 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.with( value, true ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not in bounds', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - -11, - -12, - 11, - 12 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.with( value, 1.0 ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not a numeric value', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 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.with( 0, value ); - }; - } -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 10 ); - out = arr.with( 5, 1.0 ); - - t.strictEqual( out.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a new floating-point number array with the element at a provided index replaced with a provided value', function test( t ) { - var expected; - var arr; - var buf; - var out; - - arr = new Float16Array( [ 1.05, 1.05, 1.05, 1.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 1.05 ), - toWord( 1.05 ), - toWord( 2.05 ) - ]); - out = arr.with( 3, 2.05 ); - buf = new Uint16Array( out.buffer ); - - t.strictEqual( out instanceof Float16Array, true, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.notEqual( out, arr, 'returns new instance' ); - t.end(); -}); - -tape( 'the method supports negative indices', function test( t ) { - var expected; - var arr; - var buf; - var out; - - arr = new Float16Array( [ 1.05, 1.05, 1.05, 1.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 1.05 ), - toWord( 1.05 ), - toWord( 2.05 ) - ]); - out = arr.with( -1, 2.05 ); - buf = new Uint16Array( out.buffer ); - - t.strictEqual( out instanceof Float16Array, true, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.at.js b/test/test.at.js deleted file mode 100644 index 19df3bd..0000000 --- a/test/test.at.js +++ /dev/null @@ -1,111 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `at` method for returning an array element', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.at ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.at.call( value, 0 ); - }; - } -}); - -tape( 'the method returns `undefined` if provided an index which exceeds array dimensions', function test( t ) { - var arr; - var v; - var i; - - arr = new Float16Array( 10 ); - for ( i = -arr.length; i < arr.length; i++ ) { - if ( i < 0 ) { - v = arr.at( i-arr.length ); - t.strictEqual( v, void 0, 'returns expected value for index '+(i-arr.length) ); - } else { - v = arr.at( arr.length+i ); - t.strictEqual( v, void 0, 'returns expected value for index '+(arr.length+i) ); - } - } - t.end(); -}); - -tape( 'the method returns an array element', function test( t ) { - var arr; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( i+0.05 ); - } - - arr = new Float16Array( arr ); - - for ( i = -arr.length; i < arr.length; i++ ) { - v = arr.at( i ); - if ( i < 0 ) { - t.strictEqual( v, float64ToFloat16( arr.length + i + 0.05 ), 'returns expected value for index '+i ); - } else { - t.strictEqual( v, float64ToFloat16( i + 0.05 ), 'returns expected value for index '+i ); - } - } - t.end(); -}); diff --git a/test/test.copy_within.js b/test/test.copy_within.js deleted file mode 100644 index d286509..0000000 --- a/test/test.copy_within.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `copyWithin` method for copying a sequence of array elements within a floating-point number array', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within an array', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( 0, 3 ); - buf = new Uint16Array( arr.buffer ); - - // Overwritten: - t.strictEqual( buf[ 0 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 4.05 ), 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 2 ], toWord( 2.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (negative target)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( -arr.length, 3 ); - buf = new Uint16Array( arr.buffer ); - - // Overwritten: - t.strictEqual( buf[ 0 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 4.05 ), 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 2 ], toWord( 2.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (negative start)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( 0, -2 ); - buf = new Uint16Array( arr.buffer ); - - // Overwritten: - t.strictEqual( buf[ 0 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 4.05 ), 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 2 ], toWord( 2.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (end=length)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( 0, 3, arr.length ); - buf = new Uint16Array( arr.buffer ); - - // Overwritten: - t.strictEqual( buf[ 0 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 4.05 ), 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 2 ], toWord( 2.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (non-inclusive end)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( 2, 0, 2 ); - buf = new Uint16Array( arr.buffer ); - - // Remain the same: - t.strictEqual( buf[ 0 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - - // Overwritten: - t.strictEqual( buf[ 2 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 1.05 ), 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (negative end)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( 2, 0, -3 ); - buf = new Uint16Array( arr.buffer ); - - // Remain the same: - t.strictEqual( buf[ 0 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - - // Overwritten: - t.strictEqual( buf[ 2 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 1.05 ), 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (target >= length)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( arr.length, 3 ); - buf = new Uint16Array( arr.buffer ); - - // Remain the same: - t.strictEqual( buf[ 0 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 2 ], toWord( 2.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (target > start)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( 2, 0 ); - buf = new Uint16Array( arr.buffer ); - - // Remain the same: - t.strictEqual( buf[ 0 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - - // Overwritten: - t.strictEqual( buf[ 2 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 4 ], toWord( 2.05 ), 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.entries.js b/test/test.entries.js deleted file mode 100644 index 396dd8e..0000000 --- a/test/test.entries.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isNumber = require( '@stdlib/assert-is-number' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `entries` method for returning an iterator for iterating over array key-value pairs', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.entries ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.entries.call( value ); - }; - } -}); - -tape( 'the method returns an iterator protocol-compliant object', function test( t ) { - var buf; - var arr; - var it; - var v; - var i; - - buf = [ 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( buf ); - - it = arr.entries(); - t.strictEqual( it.next.length, 0, 'has zero arity' ); - - for ( i = 0; i < arr.length; i++ ) { - v = it.next(); - t.strictEqual( isArray( v.value ), true, 'returns expected value' ); - t.strictEqual( v.value[ 0 ], i, 'returns expected value' ); - t.strictEqual( isNumber( v.value[ 1 ] ), true, 'returns expected value' ); - t.strictEqual( v.value[ 1 ], float64ToFloat16( buf[ i ] ), 'returns expected value' ); - t.strictEqual( typeof v.done, 'boolean', 'returns expected value' ); - } - t.end(); -}); diff --git a/test/test.every.js b/test/test.every.js deleted file mode 100644 index 0742d6a..0000000 --- a/test/test.every.js +++ /dev/null @@ -1,172 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `every` method for returning boolean indicating whether all elements pass a test', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.every ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.every.call( value, predicate ); - }; - } - - function predicate( v ) { - return v === 0.0; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.every( value ); - }; - } -}); - -tape( 'the method returns `true` if operating on an empty floating-point number array', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( 0 ); - bool = arr.every( predicate ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns `true` if all elements pass a test', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 1.05, 1.05, 1.05 ] ); - bool = arr.every( predicate ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v === float64ToFloat16( 1.05 ); - } -}); - -tape( 'the method returns `false` if one or more elements fail a test', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 1.05, 0.05, 1.05 ] ); - bool = arr.every( predicate ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v === float64ToFloat16( 1.05 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var bool; - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ 1.05, 1.05, 1.05, 1.05 ] ); - bool = arr.every( predicate, ctx ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v === float64ToFloat16( 1.05 ); - } -}); diff --git a/test/test.fill.js b/test/test.fill.js deleted file mode 100644 index d434060..0000000 --- a/test/test.fill.js +++ /dev/null @@ -1,212 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `fill` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.fill ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.fill.call( value, 1.0 ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.fill( 1.05 ); - - t.strictEqual( out instanceof Float16Array, true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 10 ); - out = arr.fill( 1.05 ); - - t.strictEqual( out, arr, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'if called with one argument, the method sets each array element to the provided value', function test( t ) { - var arr; - var buf; - var i; - - arr = new Float16Array( 3 ); - arr.fill( 1.05 ); - - buf = new Uint16Array( arr.buffer ); - - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( buf[ i ], toWord( 1.05 ), 'returns expected value' ); - } - - t.end(); -}); - -tape( 'if called with two arguments, the method sets each array element to the provided value starting from a start index (inclusive)', function test( t ) { - var arr; - var buf; - - arr = new Float16Array( 3 ); - buf = new Uint16Array( arr.buffer ); - - arr.fill( 1.05, 1 ); - - t.strictEqual( buf[ 0 ], toWord( 0.0 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 2 ], toWord( 1.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'if called with three arguments, the method sets each array element to the provided value starting from a start index (inclusive) until a specified end index (exclusive)', function test( t ) { - var arr; - var buf; - - arr = new Float16Array( 3 ); - buf = new Uint16Array( arr.buffer ); - - arr.fill( 1.05, 0, 2 ); - - t.strictEqual( buf[ 0 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 2 ], toWord( 0.0 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method supports negative indices', function test( t ) { - var arr; - var buf; - - arr = new Float16Array( 3 ); - buf = new Uint16Array( arr.buffer ); - - arr.fill( 1.05, -3, -1 ); - - t.strictEqual( buf[ 0 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 2 ], toWord( 0.0 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'if a provided start index resolves to a negative index, the method fills an array starting from the first element', function test( t ) { - var arr; - var buf; - var i; - - arr = new Float16Array( 3 ); - buf = new Uint16Array( arr.buffer ); - - arr.fill( 1.05, -10 ); - - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( buf[ i ], toWord( 1.05 ), 'returns expected value' ); - } - - t.end(); -}); - -tape( 'if a provided end index resolves to an index exceeding the last array element index, the method fills an array until the last element (inclusive)', function test( t ) { - var arr; - var buf; - var i; - - arr = new Float16Array( 3 ); - buf = new Uint16Array( arr.buffer ); - - arr.fill( 1.05, 1, 10 ); - - t.strictEqual( buf[ 0 ], toWord( 0.0 ), 'returns expected value' ); - for ( i = 1; i < arr.length; i++ ) { - t.strictEqual( buf[ i ], toWord( 1.05 ), 'returns expected value' ); - } - - t.end(); -}); - -tape( 'if a provided start index resolves to an index which is greater than or equal to a resolved end index, the method does not fill an array', function test( t ) { - var arr; - var buf; - - arr = new Float16Array( 3 ); - buf = new Uint16Array( arr.buffer ); - - arr.fill( 1.0, 2, 1 ); - - t.strictEqual( buf[ 0 ], toWord( 0.0 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 0.0 ), 'returns expected value' ); - t.strictEqual( buf[ 2 ], toWord( 0.0 ), 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.filter.js b/test/test.filter.js deleted file mode 100644 index 1b77a61..0000000 --- a/test/test.filter.js +++ /dev/null @@ -1,224 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `filter` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.filter ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.filter.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( v === 1.0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.filter( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.filter( predicate ); - - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v === 1.0 ); - } -}); - -tape( 'the method returns a new floating-point number array containing only those elements which satisfy a test condition', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 1.05, 2.05 ] ); - expected = new Uint16Array( [ toWord( 1.05 ), toWord( 1.05 ) ] ); - actual = arr.filter( predicate ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v === float64ToFloat16( 1.05 ) ); - } -}); - -tape( 'the method copies all elements to a new array if all elements satisfy a test condition', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ) - ]); - actual = arr.filter( predicate ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.notEqual( actual, arr, 'returns a new instance' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v > 1.0 ); - } -}); - -tape( 'the method returns an empty array if no elements satisfy a test condition', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array( [] ); - actual = arr.filter( predicate ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.notEqual( actual, arr, 'returns a new instance' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 1.0 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var expected; - var actual; - var arr; - var buf; - var ctx; - - arr = new Float16Array( [ 1.05, 2.05, 1.05, 1.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 1.05 ), - toWord( 1.05 ) - ]); - ctx = { - 'count': 0 - }; - actual = arr.filter( predicate, ctx ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v === float64ToFloat16( 1.05 ) ); - } -}); diff --git a/test/test.find.js b/test/test.find.js deleted file mode 100644 index 1836dc3..0000000 --- a/test/test.find.js +++ /dev/null @@ -1,172 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `find` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.find ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.find.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( v === 1.0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.find( value ); - }; - } -}); - -tape( 'the method returns `undefined` if operating on an empty floating-point number array', function test( t ) { - var arr; - var v; - - arr = new Float16Array( 0 ); - v = arr.find( predicate ); - - t.strictEqual( v, void 0, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns the first element which passes a test', function test( t ) { - var arr; - var v; - - arr = new Float16Array( [ 1.05, -2.05, 3.05, -4.05 ] ); - v = arr.find( predicate ); - - t.strictEqual( v, float64ToFloat16( -2.05 ), 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method returns `undefined` if all elements fail a test', function test( t ) { - var arr; - var v; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - v = arr.find( predicate ); - - t.strictEqual( v, void 0, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - var v; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ -1.05, -2.05, 3.05, 4.05, 5.05 ] ); - v = arr.find( predicate, ctx ); - - t.strictEqual( v, float64ToFloat16( 3.05 ), 'returns expected value' ); - t.strictEqual( ctx.count, 3, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v > 0.0 ); - } -}); diff --git a/test/test.find_index.js b/test/test.find_index.js deleted file mode 100644 index b3e9023..0000000 --- a/test/test.find_index.js +++ /dev/null @@ -1,171 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `findIndex` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.findIndex ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.findIndex.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( v === 1.0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.findIndex( value ); - }; - } -}); - -tape( 'the method returns `-1` if operating on an empty floating-point number array', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( 0 ); - idx = arr.findIndex( predicate ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns the index of the first element which passes a test', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( [ 1.05, -2.05, 3.05, -4.05 ] ); - idx = arr.findIndex( predicate ); - - t.strictEqual( idx, 1, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0); - } -}); - -tape( 'the method returns `-1` if all elements fail a test', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - idx = arr.findIndex( predicate ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - var idx; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ -1.05, -2.05, 3.05, 4.05, 5.05 ] ); - idx = arr.findIndex( predicate, ctx ); - - t.strictEqual( idx, 2, 'returns expected value' ); - t.strictEqual( ctx.count, 3, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v > 0.0 ); - } -}); diff --git a/test/test.find_last.js b/test/test.find_last.js deleted file mode 100644 index 4451b22..0000000 --- a/test/test.find_last.js +++ /dev/null @@ -1,172 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `findLast` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.findLast ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.findLast.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( v === 0.0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.findLast( value ); - }; - } -}); - -tape( 'the method returns `undefined` if operating on an empty floating-point number array', function test( t ) { - var arr; - var v; - - arr = new Float16Array( 0 ); - v = arr.findLast( predicate ); - - t.strictEqual( v, void 0, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns the last element which passes a test', function test( t ) { - var arr; - var v; - - arr = new Float16Array( [ 1.05, -2.05, 3.05, -4.05 ] ); - v = arr.findLast( predicate ); - - t.strictEqual( v, float64ToFloat16( -4.05 ), 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method returns `undefined` if all elements fail a test', function test( t ) { - var arr; - var v; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - v = arr.findLast( predicate ); - - t.strictEqual( v, void 0, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - var v; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ -1.05, -2.05, 3.05, 4.05, 5.05 ] ); - v = arr.findLast( predicate, ctx ); - - t.strictEqual( v, float64ToFloat16( 5.05 ), 'returns expected value' ); - t.strictEqual( ctx.count, 1, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v > 0.0 ); - } -}); diff --git a/test/test.find_last_index.js b/test/test.find_last_index.js deleted file mode 100644 index c303468..0000000 --- a/test/test.find_last_index.js +++ /dev/null @@ -1,171 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `findLastIndex` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.findLastIndex ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.findLastIndex.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( v === 1.0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.findLastIndex( value ); - }; - } -}); - -tape( 'the method returns `-1` if operating on an empty floating-point number array', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( 0 ); - idx = arr.findLastIndex( predicate ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns the index of the last element which passes a test', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( [ 1.05, -2.05, 3.05, -4.05 ] ); - idx = arr.findLastIndex( predicate ); - - t.strictEqual( idx, 3, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method returns `-1` if all elements fail a test', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - idx = arr.findLastIndex( predicate ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - var idx; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ -1.05, -2.05, 3.05, 4.05, 5.05 ] ); - idx = arr.findLastIndex( predicate, ctx ); - - t.strictEqual( idx, 4, 'returns expected value' ); - t.strictEqual( ctx.count, 1, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v > 0.0 ); - } -}); diff --git a/test/test.for_each.js b/test/test.for_each.js deleted file mode 100644 index af6afda..0000000 --- a/test/test.for_each.js +++ /dev/null @@ -1,194 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `forEach` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.forEach ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.forEach.call( value, fcn ); - }; - } - - function fcn( v ) { - if ( !isNumber( v ) ) { - t.fail( 'should be a number' ); - } - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.forEach( value ); - }; - } -}); - -tape( 'the method should not invoke a provided callback function if operating on an empty floating-point array', function test( t ) { - var arr; - - arr = new Float16Array( 0 ); - arr.forEach( fcn ); - - t.end(); - - function fcn() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns `undefined`', function test( t ) { - var arr; - var out; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - out = arr.forEach( fcn ); - - t.strictEqual( out, void 0, 'returns expected value' ); - t.end(); - - function fcn( v ) { - if ( !isNumber( v ) ) { - t.fail( 'should be a number' ); - } - } -}); - -tape( 'the method invokes a provided function for each element in an array', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var arr; - - indices = []; - values = []; - arrays = []; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - arr.forEach( fcn ); - - expected = [ - float64ToFloat16( 1.05 ), - float64ToFloat16( 2.05 ), - float64ToFloat16( 3.05 ), - float64ToFloat16( 4.05 ) - ]; - - t.deepEqual( values, expected, 'returns expected value' ); - t.deepEqual( indices, [ 0, 1, 2, 3 ], 'returns expected value' ); - t.strictEqual( arrays[ 0 ], arr, 'returns expected value' ); - t.strictEqual( arrays[ 1 ], arr, 'returns expected value' ); - t.strictEqual( arrays[ 2 ], arr, 'returns expected value' ); - t.strictEqual( arrays[ 3 ], arr, 'returns expected value' ); - - t.end(); - - function fcn( v, i, arr ) { - values.push( v ); - indices.push( i ); - arrays.push( arr ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - arr.forEach( fcn, ctx ); - - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function fcn() { - this.count += 1; // eslint-disable-line no-invalid-this - } -}); diff --git a/test/test.from.js b/test/test.from.js deleted file mode 100644 index 15a43a2..0000000 --- a/test/test.from.js +++ /dev/null @@ -1,309 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 Uint16Array = require( '@stdlib/array-uint16' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is a `from` method for creating a 16-bit floating-point number array from an array-like object or an iterable', function test( t ) { - var arr; - - t.strictEqual( isFunction( Float16Array.from ), true, 'has method' ); - - arr = Float16Array.from( [] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a constructor', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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 Float16Array.from.call( value, [] ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array constructor', function test( t ) { - var values; - var i; - - values = [ - {}, - null, - 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 Float16Array.from.call( value, [] ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - {}, - [] - ]; - 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 Float16Array.from( [], value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not a function (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - {}, - [] - ]; - 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 Float16Array.from( [], value, {} ); - }; - } -}); - -tape( 'the method returns a floating-point number array', function test( t ) { - var arr; - var v; - - // Generic array: - arr = Float16Array.from( [] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Float16Array.from( [ 1.0, 2.0, 3.0, 4.0 ] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - // Generic array containing non-numeric values: - arr = Float16Array.from( [ 'beep' ] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - arr = Float16Array.from( [ null, 4 ] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - arr = Float16Array.from( [ true, {}, '' ] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 3, 'returns expected value' ); - - // Typed array: - arr = Float16Array.from( new Uint16Array( 0 ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Float16Array.from( new Uint16Array( [ 1, 1 ] ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // Floating-point number typed array: - arr = Float16Array.from( new Float16Array( 0 ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Float16Array.from( new Float16Array( [ 1.0, 2.0 ] ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method supports providing a "map" function which is invoked for each source element', function test( t ) { - var arr; - var v; - - // Generic array: - arr = Float16Array.from( [], clbk1 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Float16Array.from( [ 1.0, 2.0, 3.0, 4.0 ], clbk1 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - // Generic array containing non-numeric values: - arr = Float16Array.from( [ 'beep' ], clbk2 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - arr = Float16Array.from( [ null ], clbk2 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - arr = Float16Array.from( [ [], {} ], clbk1 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - arr = Float16Array.from( [ 4, 5 ], clbk1 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // Typed array: - arr = Float16Array.from( new Uint16Array( 0 ), clbk1 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Float16Array.from( new Uint16Array( [ 1, 1 ] ), clbk1 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // Floating-point number typed array: - arr = Float16Array.from( new Float16Array( 0 ), clbk2 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Float16Array.from( new Float16Array( [ true, true ] ), clbk2 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - t.end(); - - function clbk1( v ) { - return v; - } - - function clbk2() { - return true; - } -}); - -tape( 'the method supports providing a `this` context for a provided map function', function test( t ) { - var arr; - var ctx; - - ctx = { - 'count': 0 - }; - arr = Float16Array.from( [ 1.0, 2.0, 3.0, 4.0 ], clbk1, ctx ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function clbk1( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v; - } -}); diff --git a/test/test.includes.js b/test/test.includes.js deleted file mode 100644 index a367b40..0000000 --- a/test/test.includes.js +++ /dev/null @@ -1,160 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `includes` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.includes ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.includes.call( value, true ); - }; - } -}); - -tape( 'the method returns `false` if operating on an empty floating-point number array', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( 0 ); - bool = arr.includes( 1.0 ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `false` if a floating-point number is not found', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( 10 ); - bool = arr.includes( 1.0 ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `true` if an array contains a specified floating-point number', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05] ); - bool = arr.includes( float64ToFloat16( 1.05 ) ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `false` if provided a second argument which exceeds the input array length', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( 10 ); - bool = arr.includes( 0.0, 20 ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 1.05, 1.05, 1.05 ] ); - - bool = arr.includes( float64ToFloat16( 1.05 ), 0 ); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = arr.includes( float64ToFloat16( 2.05 ), 1 ); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = arr.includes( float64ToFloat16( 2.05 ), 3 ); - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index (negative)', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 1.05, 1.05, 1.05 ] ); - - bool = arr.includes( float64ToFloat16( 1.05 ), -5 ); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = arr.includes( float64ToFloat16( 2.05 ), -2 ); - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'when provided a starting index which resolves to an index which is less than zero, the method searches from the first array element', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 1.05, 1.05, 1.05 ] ); - - bool = arr.includes( float64ToFloat16( 1.05 ), -10 ); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = arr.includes( float64ToFloat16( 2.05 ), -10 ); - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.index_of.js b/test/test.index_of.js deleted file mode 100644 index 2a684aa..0000000 --- a/test/test.index_of.js +++ /dev/null @@ -1,160 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `indexOf` method for returning the index of an array element', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.indexOf ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.indexOf.call( value, 1.0 ); - }; - } -}); - -tape( 'the method returns `-1` if operating on an empty floating-point number array', function test( t ) { - var arr; - var idx; - - arr = new Float16Array(); - idx = arr.indexOf( 1.0 ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `-1` if a numeric value is not found', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( 10 ); - idx = arr.indexOf( 1.0 ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns the index of the first match if a numeric value is found', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - idx = arr.indexOf( float64ToFloat16( 2.05 ) ); - - t.strictEqual( idx, 1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `-1` if provided a second argument which exceeds the input array length', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( 10 ); - idx = arr.indexOf( 1.0, 20 ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 2.05, 5.05 ] ); - - idx = arr.indexOf( float64ToFloat16( 2.05 ), 0 ); - t.strictEqual( idx, 1, 'returns expected value' ); - - idx = arr.indexOf( float64ToFloat16( 2.05 ), 2 ); - t.strictEqual( idx, 3, 'returns expected value' ); - - idx = arr.indexOf( float64ToFloat16( 2.05 ), 4 ); - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index (negative)', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 2.05, 5.05 ] ); - - idx = arr.indexOf( float64ToFloat16( 2.05 ), -5 ); - t.strictEqual( idx, 1, 'returns expected value' ); - - idx = arr.indexOf( float64ToFloat16( 2.05 ), -1 ); - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'when provided a starting index which resolves to an index which is less than zero, the method searches from the first array element', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 2.05, 5.05 ] ); - - idx = arr.indexOf( float64ToFloat16( 2.05 ), -10 ); - t.strictEqual( idx, 1, 'returns expected value' ); - - idx = arr.indexOf( float64ToFloat16( 1.05 ), -10 ); - t.strictEqual( idx, 0, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.join.js b/test/test.join.js deleted file mode 100644 index 800bb1f..0000000 --- a/test/test.join.js +++ /dev/null @@ -1,141 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `join` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.join ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.join.call( value ); - }; - } -}); - -tape( 'the method returns an empty string if invoked on an empty array', function test( t ) { - var str; - var arr; - - arr = new Float16Array( 0 ); - str = arr.join(); - - t.strictEqual( str, '', 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a string representation of a floating-point number array with elements separated by a separator', function test( t ) { - var expected; - var str; - var arr; - var i; - - arr = new Float16Array( [ 0.05, 1.05, 2.05, 3.05, 4.05 ] ); - - expected = float64ToFloat16( 0.05 ); - for ( i = 1; i < arr.length; i++ ) { - expected += '@' + float64ToFloat16( i + 0.05 ); - } - - str = arr.join( '@' ); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a string representation of a floating-point number array with elements separated by a separator (single element)', function test( t ) { - var expected; - var str; - var arr; - - arr = new Float16Array( [ 1.05 ] ); - expected = '' + float64ToFloat16( 1.05 ); - - str = arr.join(); - - t.strictEqual( str, expected, 'returns expected value' ); - - arr = new Float16Array( [ 1.05 ] ); - expected = '' + float64ToFloat16( 1.05 ); - - str = arr.join( '@' ); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if the method is invoked without a separator argument, the method returns a string representation of a floating-point number array with elements separated by a comma', function test( t ) { - var expected; - var str; - var arr; - var i; - - arr = new Float16Array( [ 0.05, 1.05, 2.05, 3.05, 4.05 ] ); - - expected = float64ToFloat16( 0.05 ); - for ( i = 1; i < arr.length; i++ ) { - expected += ',' + float64ToFloat16( i + 0.05 ); - } - - str = arr.join(); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 930feef..0000000 --- a/test/test.js +++ /dev/null @@ -1,320 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var arr = new Float16Array( 0 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (no argument)', function test( t ) { - var arr = new Float16Array(); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (length)', function test( t ) { - var arr = new Float16Array( 10 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (array)', function test( t ) { - var arr = new Float16Array( [] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (typed array)', function test( t ) { - var arr = new Float16Array( new Uint16Array( 0 ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (ArrayBuffer)', function test( t ) { - var arr = new Float16Array( new ArrayBuffer( 0 ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (ArrayBuffer, byte offset)', function test( t ) { - var arr = new Float16Array( new ArrayBuffer( 8 ), 8 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (ArrayBuffer, byte offset, length)', function test( t ) { - var arr = new Float16Array( new ArrayBuffer( 8 ), 8, 0 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the constructor is a property returning the number of bytes per array element', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Float16Array.BYTES_PER_ELEMENT, 2, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the constructor is a property returning the constructor name', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array, 'name' ), true, 'has property' ); - t.strictEqual( Float16Array.name, 'Float16Array', 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance having a `BYTES_PER_ELEMENT` property returning the number of bytes per array element', function test( t ) { - var arr; - - t.strictEqual( hasOwnProp( Float16Array.prototype, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Float16Array.prototype.BYTES_PER_ELEMENT, 2, 'returns expected value' ); - - arr = new Float16Array( 0 ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance having a `buffer` property for returning the underlying memory (i.e., ArrayBuffer)', function test( t ) { - var arr; - var buf; - - arr = new Float16Array( 0 ); - buf = arr.buffer; - t.strictEqual( isArrayBuffer( buf ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance having a `byteLength` property for returning the number of bytes belonging to the array view', function test( t ) { - var arr; - var v; - - arr = new Float16Array( 0 ); - v = arr.byteLength; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( new ArrayBuffer( 64 ), 8 ); - v = arr.byteLength; - t.strictEqual( v, 56, 'returns expected value' ); - - arr = new Float16Array( new ArrayBuffer( 64 ), 64 ); - v = arr.byteLength; - t.strictEqual( v, 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance having a `byteOffset` property for returning the byte offset pointing to the first array element in the underlying memory', function test( t ) { - var arr; - var v; - - arr = new Float16Array( 0 ); - v = arr.byteOffset; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( new ArrayBuffer( 64 ), 32 ); - v = arr.byteOffset; - t.strictEqual( v, 32, 'returns expected value' ); - - arr = new Float16Array( new ArrayBuffer( 64 ), 64 ); - v = arr.byteOffset; - t.strictEqual( v, 64, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance having a `length` property for returning the number of array elements', function test( t ) { - var arr; - var v; - - // No arguments: - arr = new Float16Array(); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - // Explicit array length: - arr = new Float16Array( 0 ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( 10 ); - v = arr.length; - t.strictEqual( v, 10, 'returns expected value' ); - - // Generic array: - arr = new Float16Array( [] ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - // Typed array: - arr = new Float16Array( new Uint16Array( 0 ) ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( new Uint16Array( [ 1.0, 1.0 ] ) ); - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // Float16 typed array: - arr = new Float16Array( new Float16Array( 0 ) ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( new Float16Array( [ 1.0, 2.0 ] ) ); - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // ArrayBuffer: - arr = new Float16Array( new ArrayBuffer( 64 ), 32 ); - v = arr.length; - t.strictEqual( v, 16, 'returns expected value' ); - - arr = new Float16Array( new ArrayBuffer( 64 ), 64 ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( new ArrayBuffer( 64 ), 32, 2 ); - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor throws an error if provided an ArrayBuffer which is not a multiple of 2', function test( t ) { - var values; - var i; - - values = [ - 1, - 3, - 5, - 7, - 9, - 11, - 101, - 1001 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided an ArrayBuffer having a byte length equal to '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Float16Array( new ArrayBuffer( value ) ); - }; - } -}); - -tape( 'the constructor throws an error if provided a byte offset argument which is not a multiple of 2', function test( t ) { - var values; - var i; - - values = [ - 1, - 3, - 5, - 7, - 9, - 11, - 101, - 1001 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Float16Array( new ArrayBuffer( 1e3 ), value ); - }; - } -}); - -tape( 'the constructor throws an error if provided a byte offset argument such that the view byte length is not a multiple of 8', function test( t ) { - var values; - var i; - - values = [ - 2, - 4, - 6, - 8, - 10, - 12, - 14, - 16, - 18, - 20 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Float16Array( new ArrayBuffer( 101 ), value ); - }; - } -}); - -tape( 'the constructor throws an error if provided insufficient memory to accommodate byte offset and length arguments', function test( t ) { - var values; - var i; - - values = [ - 8, - 16, - 24, - 32 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Float16Array( new ArrayBuffer( 100 ), value, 1e3 ); - }; - } -}); diff --git a/test/test.keys.js b/test/test.keys.js deleted file mode 100644 index 283d682..0000000 --- a/test/test.keys.js +++ /dev/null @@ -1,144 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `keys` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.keys ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.keys.call( value ); - }; - } -}); - -tape( 'the method returns an iterator protocol-compliant object', function test( t ) { - var expected; - var arr; - var it; - var i; - var r; - var e; - - arr = new Float16Array( [ 1.05, 2.05 ] ); - expected = [ - { - 'value': 0, - 'done': false - }, - { - 'value': 1, - 'done': false - }, - { - 'done': true - } - ]; - it = arr.keys(); - - t.strictEqual( typeof it, 'object', 'returns expected value' ); - t.strictEqual( typeof it.next, 'function', 'has next method' ); - - for ( i = 0; i < expected.length; i++ ) { - r = it.next(); - e = expected[ i ]; - if ( e.value === void 0 ) { - t.strictEqual( r.value, e.value, 'returns expected value' ); - t.strictEqual( r.done, e.done, 'returns expected value' ); - } else { - t.strictEqual( r.value, e.value, 'returns expected value' ); - t.strictEqual( r.done, e.done, 'returns expected value' ); - } - } - - t.end(); -}); - -tape( 'the method returns an iterator which does not iterate over empty arrays', function test( t ) { - var expected; - var arr; - var it; - var i; - var v; - - arr = new Float16Array( [] ); - expected = [ - { - 'done': true - }, - { - 'done': true - }, - { - 'done': true - } - ]; - it = arr.keys(); - - t.strictEqual( typeof it, 'object', 'returns expected value' ); - t.strictEqual( typeof it.next, 'function', 'has next method' ); - - for ( i = 0; i < expected.length; i++ ) { - v = it.next(); - t.strictEqual( v.value, expected[ i ].value, 'returns expected value' ); - t.strictEqual( v.done, expected[ i ].done, 'returns expected value' ); - } - t.end(); -}); diff --git a/test/test.last_index_of.js b/test/test.last_index_of.js deleted file mode 100644 index 5a42168..0000000 --- a/test/test.last_index_of.js +++ /dev/null @@ -1,149 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `lastIndexOf` method for returning the index of an array element', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.lastIndexOf ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.lastIndexOf.call( value, true ); - }; - } -}); - -tape( 'the method returns `-1` if operating on an empty floating-point number array', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( 0 ); - idx = arr.lastIndexOf( 0.0 ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `-1` if a numeric value is not found', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( 10 ); - idx = arr.lastIndexOf( 1.0 ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns the index of the first match when searching from the end of the array if a search element is found', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 1.05, 2.05 ] ); - idx = arr.lastIndexOf( float64ToFloat16( 1.05 ) ); - - t.strictEqual( idx, 2, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 2.05, 1.05, 1.05 ] ); - - idx = arr.lastIndexOf( float64ToFloat16( 1.05 ), 4 ); - t.strictEqual( idx, 4, 'returns expected value' ); - - idx = arr.lastIndexOf( float64ToFloat16( 2.05 ), 2 ); - t.strictEqual( idx, 2, 'returns expected value' ); - - idx = arr.lastIndexOf( float64ToFloat16( 2.05 ), 0 ); - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index (negative)', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 2.05, 1.05, 1.05 ] ); - - idx = arr.lastIndexOf( float64ToFloat16( 1.05 ), -3 ); - t.strictEqual( idx, 0, 'returns expected value' ); - - idx = arr.lastIndexOf( float64ToFloat16( 2.05 ), -1 ); - t.strictEqual( idx, 2, 'returns expected value' ); - t.end(); -}); - -tape( 'when the method is provided a starting index which resolves to an index which exceeds the maximum array index, the method searches from the last array element', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 2.05, 1.05, 1.05 ] ); - - idx = arr.lastIndexOf( float64ToFloat16( 1.05 ), 10 ); - t.strictEqual( idx, 4, 'returns expected value' ); - - idx = arr.lastIndexOf( float64ToFloat16( 2.05 ), 10 ); - t.strictEqual( idx, 2, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.map.js b/test/test.map.js deleted file mode 100644 index f7e5594..0000000 --- a/test/test.map.js +++ /dev/null @@ -1,176 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var identity = require( '@stdlib/utils-identity-function' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `map` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.map ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.map.call( value, identity ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.map( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.map( identity ); - - t.strictEqual( instanceOf( out, Float16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - t.notEqual( out, arr, 'returns a new instance' ); - t.end(); -}); - -tape( 'the method returns a new floating-point number array containing elements which are the result of a provided callback function', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( -1.05 ), - toWord( -2.05 ), - toWord( -3.05 ), - toWord( -4.05 ) - ]); - actual = arr.map( invert ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.notEqual( actual, arr, 'returns a new instance' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); - - function invert( v ) { - return -v; - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var expected; - var actual; - var arr; - var buf; - var ctx; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( -1.05 ), - toWord( -2.05 ), - toWord( -3.05 ), - toWord( -4.05 ) - ]); - ctx = { - 'count': 0 - }; - actual = arr.map( invert, ctx ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.strictEqual( ctx.count, 6, 'returns expected value' ); - t.end(); - - function invert( v, i ) { - this.count += i; // eslint-disable-line no-invalid-this - return -v; - } -}); diff --git a/test/test.of.js b/test/test.of.js deleted file mode 100644 index 6486686..0000000 --- a/test/test.of.js +++ /dev/null @@ -1,128 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `of` method for creating a 16-bit floating-point number array from a variable number of arguments', function test( t ) { - var arr; - - t.strictEqual( isFunction( Float16Array.of ), true, 'has method' ); - - arr = Float16Array.of(); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a constructor', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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 Float16Array.of.call( value, true, true ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point array constructor', function test( t ) { - var values; - var i; - - values = [ - {}, - null, - 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 Float16Array.of.call( value, true, true ); - }; - } -}); - -tape( 'the method returns a floating-point number array', function test( t ) { - var arr; - var v; - - // No arguments: - arr = Float16Array.of(); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - // Numeric arguments: - arr = Float16Array.of( 1.0, 2.0, 3.0, 4.0 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - // Non-numeric arguments: - arr = Float16Array.of( 1, {}, 0, null, 'beep' ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 5, 'returns expected value' ); - - // Mixed arguments: - arr = Float16Array.of( true, 1, false, 0 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 2010bde..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 proxyquire = require( 'proxyquire' ); -var hasFloat16ArraySupport = require( '@stdlib/assert-has-float16array-support' ); -var polyfill = require( './../lib/polyfill' ); -var ctor = require( './../lib' ); - - -// VARIABLES // - -var hasFloat16Arrays = hasFloat16ArraySupport(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports `Float16Array`, the export is an alias for `Float16Array`', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-float16array-support': isTrue, - './main.js': Mock - }); - t.strictEqual( Foo, Mock, 'returns builtin' ); - - if ( hasFloat16Arrays ) { - t.strictEqual( ctor, Float16Array, 'is alias' ); // eslint-disable-line stdlib/require-globals, no-undef - } - - t.end(); - - function Mock() { - return this; - } - - function isTrue() { - return true; - } -}); - -tape( 'if an environment does not support `Float16Array`, the export is a polyfill', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-float16array-support': isFalse - }); - - t.strictEqual( Foo, polyfill, 'returns polyfill' ); - t.end(); - - function isFalse() { - return false; - } -}); diff --git a/test/test.reduce.js b/test/test.reduce.js deleted file mode 100644 index 34786fc..0000000 --- a/test/test.reduce.js +++ /dev/null @@ -1,187 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `reduce` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.reduce ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.reduce.call( value, reducer ); - }; - } - - function reducer( acc, value ) { - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.reduce( value ); - }; - } -}); - -tape( 'the method throws an error if not provided an initial value when operating on an empty floating-point number array', function test( t ) { - var arr; - - arr = new Float16Array( 0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - arr.reduce( reducer ); - } - - function reducer( acc, value ) { - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method uses the first element of the array as the initial value when an initial value is not provided', function test( t ) { - var valueArray; - var accArray; - var expected; - var actual; - var arr; - var ind; - - arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - accArray = [ 1.0, 3.0 ]; - valueArray = [ 2.0, 3.0 ]; - expected = float64ToFloat16( 6.0 ); - actual = arr.reduce( reducer ); - - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); - - function reducer( acc, value, index ) { - ind = index-1; - t.strictEqual( acc, float64ToFloat16( accArray[ ind ] ), 'returns expected value' ); - t.strictEqual( value, float64ToFloat16( valueArray[ ind ] ), 'returns expected value' ); - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method supports providing an initial value as the second argument', function test( t ) { - var valueArray; - var accArray; - var expected; - var actual; - var arr; - - arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - accArray = [ 2.0, 3.0, 5.0 ]; - valueArray = [ 1.0, 2.0, 3.0 ]; - expected = 8.0; - actual = arr.reduce( reducer, 2.0 ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value, index ) { - t.strictEqual( acc, float64ToFloat16( accArray[ index ] ), 'returns expected value' ); - t.strictEqual( value, float64ToFloat16( valueArray[ index ] ), 'returns expected value' ); - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method returns the accumulated result', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = float64ToFloat16( 10.20 ); - actual = arr.reduce( reducer ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value ) { - return float64ToFloat16( acc + value ); - } -}); diff --git a/test/test.reduce_right.js b/test/test.reduce_right.js deleted file mode 100644 index 313b948..0000000 --- a/test/test.reduce_right.js +++ /dev/null @@ -1,190 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `reduceRight` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.reduceRight ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.reduceRight.call( value, reducer ); - }; - } - - function reducer( acc, value ) { - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.reduceRight( value ); - }; - } -}); - -tape( 'the method throws an error if not provided an initial value when operating on an empty floating-point number array', function test( t ) { - var arr; - - arr = new Float16Array( 0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - arr.reduceRight( reducer ); - } - - function reducer( acc, value ) { - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method uses the last element of the array as the initial value when an initial value is not provided', function test( t ) { - var valueArray; - var accArray; - var expected; - var actual; - var arr; - var len; - - arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - len = arr.length; - accArray = [ 3.0, 5.0 ]; - valueArray = [ 2.0, 1.0 ]; - expected = float64ToFloat16( 6.0 ); - actual = arr.reduceRight( reducer ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value, index ) { - var ind = (len-index-2); - t.strictEqual( acc, float64ToFloat16( accArray[ ind ] ), 'returns expected value' ); - t.strictEqual( value, float64ToFloat16( valueArray[ ind ] ), 'returns expected value' ); - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method supports providing an initial value as the second argument', function test( t ) { - var valueArray; - var accArray; - var expected; - var actual; - var arr; - var len; - - arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - len = arr.length; - accArray = [ 2.0, 5.0, 7.0 ]; - valueArray = [ 3.0, 2.0, 1.0 ]; - expected = 8.0; - actual = arr.reduceRight( reducer, 2.0 ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value, index ) { - var ind = (len-index-1); - t.strictEqual( acc, float64ToFloat16( accArray[ ind ] ), 'returns expected value' ); - t.strictEqual( value, float64ToFloat16( valueArray[ ind ] ), 'returns expected value' ); - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method returns the accumulated result', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = float64ToFloat16( 10.20 ); - actual = arr.reduceRight( reducer ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value ) { - return float64ToFloat16( acc + value ); - } -}); diff --git a/test/test.reverse.js b/test/test.reverse.js deleted file mode 100644 index 147a4a0..0000000 --- a/test/test.reverse.js +++ /dev/null @@ -1,120 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, '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( isFunction( Float16Array.prototype.reverse ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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 floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - 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 floating-point number array in-place', function test( t ) { - var expected; - var arr; - var buf; - var out; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05, 5.05 ] ); - expected = new Uint16Array([ - toWord( 5.05 ), - toWord( 4.05 ), - toWord( 3.05 ), - toWord( 2.05 ), - toWord( 1.05 ) - ]); - out = arr.reverse(); - buf = new Uint16Array( arr.buffer ); - - t.strictEqual( instanceOf( arr, Float16Array ), true, 'returns expected value' ); - t.strictEqual( out, arr, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 10 ); - out = arr.reverse(); - - t.strictEqual( out.length, 10, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.set.js b/test/test.set.js deleted file mode 100644 index 559efab..0000000 --- a/test/test.set.js +++ /dev/null @@ -1,225 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `set` method for setting one or more array elements', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.set ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.set.call( value, 0 ); - }; - } -}); - -tape( 'the method throws an error if provided an index argument which is out-of-bounds', function test( t ) { - var values; - var arr1; - var arr2; - var i; - - arr1 = new Float16Array( 10 ); - arr2 = []; - for ( i = 0; i < arr1.length; i++ ) { - arr2.push( 1.0 ); - } - - values = [ - 1, - 2, - 3, - 4, - 5 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr1.set( arr2, value ); - }; - } -}); - -tape( 'the method sets one or more array elements', function test( t ) { - var arr; - var v; - var i; - - arr = new Float16Array( 10 ); - - v = arr[ 0 ]; - t.strictEqual( v, 0.0, 'returns expected value' ); - - // No index argument: - arr.set( [ 1.0 ] ); - - v = arr[ 0 ]; - t.strictEqual( v, 1.0, 'returns expected value' ); - - arr.set( [ 0.0 ] ); - - // Index argument: - for ( i = 0; i < arr.length; i++ ) { - v = arr[ i ]; - t.strictEqual( v, 0.0, 'returns expected value' ); - - arr.set( [ 1.05 ], i ); - - v = arr[ i ]; - t.strictEqual( v, float64ToFloat16( 1.05 ), 'returns expected value' ); - } - - // Multiple values, no index argument: - arr.set( [ 1.05, 2.05 ] ); - - v = arr[ 0 ]; - t.strictEqual( v, float64ToFloat16( 1.05 ), 'returns expected value' ); - - v = arr[ 1 ]; - t.strictEqual( v, float64ToFloat16( 2.05 ), 'returns expected value' ); - - // Multiple values, index argument: - arr.set( [ 1.05, 2.05 ], 2 ); - - v = arr[ 2 ]; - t.strictEqual( v, float64ToFloat16( 1.05 ), 'returns expected value' ); - - v = arr[ 3 ]; - t.strictEqual( v, float64ToFloat16( 2.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method sets an array element (floating-point number array; shared buffer)', function test( t ) { - var byteOffset; - var arr; - var src; - var buf; - var ab; - var v; - var i; - - byteOffset = 112; - - ab = new ArrayBuffer( 240 ); - arr = new Float16Array( ab, byteOffset, 10 ); - - // Overlapping (requires copy), multiple values, no index argument: - buf = [ 1.05, 2.05 ]; - src = new Float16Array( ab, byteOffset-(1*arr.BYTES_PER_ELEMENT), 2 ); - for ( i = 0; i < buf.length; i++ ) { - src[ i ] = buf[ i ]; - } - arr.set( src ); - - v = arr[ 0 ]; - t.strictEqual( v, float64ToFloat16( buf[ 0 ] ), 'returns expected value' ); - - v = arr[ 1 ]; - t.strictEqual( v, float64ToFloat16( buf[ 1 ] ), 'returns expected value' ); - - // Overlapping (requires copy), multiple values, index argument: - buf = [ -1.05, -2.05 ]; - src = new Float16Array( ab, byteOffset+(1*arr.BYTES_PER_ELEMENT), 2 ); - for ( i = 0; i < buf.length; i++ ) { - src[ i ] = buf[ i ]; - } - arr.set( src, 2 ); - - v = arr[ 2 ]; - t.strictEqual( v, float64ToFloat16( buf[ 0 ] ), 'returns expected value' ); - - v = arr[ 3 ]; - t.strictEqual( v, float64ToFloat16( buf[ 1 ] ), 'returns expected value' ); - - // Overlapping (no copy), multiple values, no index argument: - buf = [ 3.05, 4.05 ]; - src = new Float16Array( ab, byteOffset+(1*arr.BYTES_PER_ELEMENT), 2 ); - for ( i = 0; i < buf.length; i++ ) { - src[ i ] = buf[ i ]; - } - arr.set( src ); - - v = arr[ 0 ]; - t.strictEqual( v, float64ToFloat16( buf[ 0 ] ), 'returns expected value' ); - - v = arr[ 1 ]; - t.strictEqual( v, float64ToFloat16( buf[ 1 ] ), 'returns expected value' ); - - // Overlapping (no copy), multiple values, index argument: - buf = [ -3.05, -4.05 ]; - src = new Float16Array( ab, byteOffset+(3*arr.BYTES_PER_ELEMENT), 2 ); - for ( i = 0; i < buf.length; i++ ) { - src[ i ] = buf[ i ]; - } - arr.set( src, 2 ); - - v = arr[ 2 ]; - t.strictEqual( v, float64ToFloat16( buf[ 0 ] ), 'returns expected value' ); - - v = arr[ 3 ]; - t.strictEqual( v, float64ToFloat16( buf[ 1 ] ), 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.slice.js b/test/test.slice.js deleted file mode 100644 index a9f9e04..0000000 --- a/test/test.slice.js +++ /dev/null @@ -1,249 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `slice` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.slice ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.slice.call( value ); - }; - } -}); - -tape( 'the method returns an empty typed array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.slice(); - - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'if called without arguments, the method returns a typed array containing the same elements as the original array', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ) - ]); - actual = arr.slice(); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.notEqual( actual, arr, 'returns a new instance' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if called with one argument, the method returns a typed array containing elements starting from a specified beginning index (inclusive)', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ) - ]); - actual = arr.slice( 1 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if provided two arguments, the method returns a typed array containing elements starting from a specified beginning index (inclusive) and ending at a specified stop index (exclusive)', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ) - ]); - actual = arr.slice( 1, 3 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ) - ]); - actual = arr.slice( 1, 30 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method resolves negative indices relative to the last element', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ) - ]); - actual = arr.slice( -3, -1 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ) - ]); - actual = arr.slice( -30, -2 ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty typed array if a resolved beginning index exceeds a resolved ending index', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array( [] ); - actual = arr.slice( 2, 0 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty typed array if a resolved beginning index exceeds the maximum array index', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array( [] ); - actual = arr.slice( 5 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty typed array if a resolved ending index is less than or equal to zero', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); - expected = new Uint16Array( [] ); - actual = arr.slice( 2, -8 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - - actual = arr.slice( 1, 0 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.some.js b/test/test.some.js deleted file mode 100644 index 238d1d9..0000000 --- a/test/test.some.js +++ /dev/null @@ -1,194 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `some` method for returning boolean indicating whether at least one element passes a test', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.some ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.some.call( value, predicate ); - }; - } - - function predicate( v ) { - return v === 1.0; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.some( value ); - }; - } -}); - -tape( 'the method returns `false` if operating on an empty floating-point number array', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( 0 ); - bool = arr.some( predicate ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns `true` if at least one element passes a test', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - bool = arr.some( predicate ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v === float64ToFloat16( 1.05 ); - } -}); - -tape( 'the method returns `false` if all elements fail a test', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - bool = arr.some( predicate ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v === float64ToFloat16( 5.05 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var bool; - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - bool = arr.some( predicate, ctx ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v === float64ToFloat16( 4.05 ); - } -}); - -tape( 'the method stops executing upon encountering the first element which passes a test', function test( t ) { - var bool; - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - bool = arr.some( predicate, ctx ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.strictEqual( ctx.count, 1, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v === float64ToFloat16( 1.05 ); - } -}); diff --git a/test/test.sort.js b/test/test.sort.js deleted file mode 100644 index e976a68..0000000 --- a/test/test.sort.js +++ /dev/null @@ -1,186 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Comparison function. -* -* @private -* @param {boolean} a - first value for comparison -* @param {boolean} b - second value for comparison -* @returns {number} comparison result -*/ -function compareFcn( a, b ) { - if ( a < b ) { - return -1; - } - if ( a > b ) { - return 1; - } - return 0; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `sort` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.sort ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.sort.call( value, compareFcn ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - {}, - [] - ]; - 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.sort( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.sort( compareFcn ); - - t.strictEqual( out.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the method sorts elements of a floating-point number array in-place', function test( t ) { - var expected; - var arr; - var out; - var buf; - - arr = new Float16Array( [ 4.05, 3.05, 1.05, 5.05, 2.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ), - toWord( 5.05 ) - ]); - out = arr.sort( compareFcn ); - buf = new Uint16Array( out.buffer ); - - t.strictEqual( instanceOf( arr, Float16Array ), true, 'returns expected value' ); - t.strictEqual( out, arr, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - - arr = new Float16Array( [ 2.05, 1.05, -1.05, 0.05, -2.05 ] ); - expected = new Uint16Array([ - toWord( -2.05 ), - toWord( -1.05 ), - toWord( 0.05 ), - toWord( 1.05 ), - toWord( 2.05 ) - ]); - out = arr.sort( compareFcn ); - buf = new Uint16Array( out.buffer ); - - t.strictEqual( instanceOf( arr, Float16Array ), true, 'returns expected value' ); - t.strictEqual( out, arr, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Float16Array( [ 4.05, 3.05, 1.05, 5.05, 2.05 ] ); - out = arr.sort( compareFcn ); - - t.strictEqual( out.length, arr.length, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.subarray.js b/test/test.subarray.js deleted file mode 100644 index 6684448..0000000 --- a/test/test.subarray.js +++ /dev/null @@ -1,246 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `subarray` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.subarray ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.subarray.call( value ); - }; - } -}); - -tape( 'the method returns empty array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.subarray(); - - t.strictEqual( out.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'if called without arguments, the method returns a view containing the same elements as the original array', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ) - ]); - actual = arr.subarray(); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if called with one argument, the method returns a view containing elements starting from a specified beginning index (inclusive)', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ) - ]); - actual = arr.subarray( 1 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if provided two arguments, the method returns a view containing elements starting from a specified beginning index (inclusive) and ending at a specified stop index (exclusive)', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ) - ]); - actual = arr.subarray( 1, 3 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method resolves negative indices relative to the last element', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ) - ]); - actual = arr.subarray( -3, -1 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 2.05 ) - ]); - actual = arr.subarray( -30, -2 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty view if a resolved beginning index exceeds a resolved ending index', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array( [] ); - actual = arr.subarray( 2, 0 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty view if a resolved beginning index exceeds the maximum array index', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array( [] ); - actual = arr.subarray( 5 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty view if a resolved ending index is less than or equal to zero', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array( [] ); - actual = arr.subarray( 2, -8 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - - actual = arr.subarray( 1, 0 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.to_locale_string.js b/test/test.to_locale_string.js deleted file mode 100644 index 6359a2c..0000000 --- a/test/test.to_locale_string.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `toLocaleString` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.toLocaleString ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.toLocaleString.call( value ); - }; - } -}); - -tape( 'the method returns an empty string if invoked on an empty array', function test( t ) { - var str; - var arr; - - arr = new Float16Array( 0 ); - str = arr.toLocaleString(); - - t.strictEqual( str, '', 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a string representation of a floating-point number array', function test( t ) { - var expected; - var str; - var arr; - - arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - expected = '1,2,3'; - - str = arr.toLocaleString(); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.to_reversed.js b/test/test.to_reversed.js deleted file mode 100644 index a82ad13..0000000 --- a/test/test.to_reversed.js +++ /dev/null @@ -1,119 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, '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( isFunction( Float16Array.prototype.toReversed ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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 floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - 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 buf; - var out; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05, 5.05 ] ); - expected = new Uint16Array([ - toWord( 5.05 ), - toWord( 4.05 ), - toWord( 3.05 ), - toWord( 2.05 ), - toWord( 1.05 ) - ]); - out = arr.toReversed(); - buf = new Uint16Array( out.buffer ); - - t.strictEqual( instanceOf( out, Float16Array ), true, 'returns expected value' ); - t.notEqual( out, arr, 'returns a new instance' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 10 ); - out = arr.toReversed(); - - t.strictEqual( out.length, 10, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.to_sorted.js b/test/test.to_sorted.js deleted file mode 100644 index 77508b5..0000000 --- a/test/test.to_sorted.js +++ /dev/null @@ -1,169 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Comparison function. -* -* @private -* @param {boolean} a - first value for comparison -* @param {boolean} b - second value for comparison -* @returns {number} comparison result -*/ -function compareFcn( a, b ) { - if ( a < b ) { - return -1; - } - if ( a > b ) { - return 1; - } - return 0; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `toSorted` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.toSorted ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.toSorted.call( value, compareFcn ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - {}, - [] - ]; - 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.toSorted( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.toSorted( compareFcn ); - - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a new typed array containing elements in sorted order', function test( t ) { - var expected; - var arr; - var out; - var buf; - - arr = new Float16Array( [ 4.05, 3.05, 1.05, 5.05, 2.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ), - toWord( 5.05 ) - ]); - out = arr.toSorted( compareFcn ); - buf = new Uint16Array( out.buffer ); - - t.strictEqual( instanceOf( out, Float16Array ), true, 'returns expected value' ); - t.notEqual( out, arr, 'returns a new instance' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Float16Array( [ 4.05, 3.05, 1.05, 5.05, 2.05 ] ); - out = arr.toSorted( compareFcn ); - - t.strictEqual( out.length, arr.length, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.to_string.js b/test/test.to_string.js deleted file mode 100644 index a2bb9e3..0000000 --- a/test/test.to_string.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `toString` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.toString ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with an invalid `this` context', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - null, - void 0 - ]; - 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.toString.call( value ); - }; - } -}); - -tape( 'the method returns an empty string if invoked on an empty array', function test( t ) { - var str; - var arr; - - arr = new Float16Array( 0 ); - str = arr.toString(); - - t.strictEqual( str, '', 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a string representation of a floating-point number array', function test( t ) { - var expected; - var str; - var arr; - - arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - expected = '1,2,3,4'; - - str = arr.toString(); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.values.js b/test/test.values.js deleted file mode 100644 index 225b3fe..0000000 --- a/test/test.values.js +++ /dev/null @@ -1,147 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var isNumber = require( '@stdlib/assert-is-number' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `values` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.values ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.values.call( value ); - }; - } -}); - -tape( 'the method returns an iterator protocol-compliant object', function test( t ) { - var expected; - var arr; - var it; - var i; - var r; - var e; - - arr = new Float16Array( [ 1.05, 2.05 ] ); - expected = [ - { - 'value': float64ToFloat16( 1.05 ), - 'done': false - }, - { - 'value': float64ToFloat16( 2.05 ), - 'done': false - }, - { - 'done': true - } - ]; - it = arr.values(); - - t.strictEqual( typeof it, 'object', 'returns expected value' ); - t.strictEqual( typeof it.next, 'function', 'has next method' ); - - for ( i = 0; i < expected.length; i++ ) { - r = it.next(); - e = expected[ i ]; - if ( e.value === void 0 ) { - t.strictEqual( r.value, e.value, 'returns expected value' ); - t.strictEqual( r.done, e.done, 'returns expected value' ); - } else { - t.strictEqual( isNumber( r.value ), true, 'returns expected value' ); - t.strictEqual( r.value, e.value, 'returns expected value' ); - t.strictEqual( r.done, e.done, 'returns expected value' ); - } - } - - t.end(); -}); - -tape( 'the method returns an iterator which does not iterate over empty arrays', function test( t ) { - var expected; - var arr; - var it; - var i; - var v; - - arr = new Float16Array( [] ); - expected = [ - { - 'done': true - }, - { - 'done': true - }, - { - 'done': true - } - ]; - it = arr.values(); - - t.strictEqual( typeof it, 'object', 'returns expected value' ); - t.strictEqual( typeof it.next, 'function', 'has next method' ); - - for ( i = 0; i < expected.length; i++ ) { - v = it.next(); - t.strictEqual( v.value, expected[ i ].value, 'returns expected value' ); - t.strictEqual( v.done, expected[ i ].done, 'returns expected value' ); - } - t.end(); -}); diff --git a/test/test.with.js b/test/test.with.js deleted file mode 100644 index de134c8..0000000 --- a/test/test.with.js +++ /dev/null @@ -1,151 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `with` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.with ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.with.call( value, 0, true ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not in bounds', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - -11, - -12, - 11, - 12 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.with( value, 1.0 ); - }; - } -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 10 ); - out = arr.with( 5, 1.0 ); - - t.strictEqual( out.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a new floating-point number array with the element at a provided index replaced with a provided value', function test( t ) { - var expected; - var arr; - var buf; - var out; - - arr = new Float16Array( [ 1.05, 1.05, 1.05, 1.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 1.05 ), - toWord( 1.05 ), - toWord( 2.05 ) - ]); - out = arr.with( 3, 2.05 ); - buf = new Uint16Array( out.buffer ); - - t.strictEqual( out instanceof Float16Array, true, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.notEqual( out, arr, 'returns new instance' ); - t.end(); -}); - -tape( 'the method supports negative indices', function test( t ) { - var expected; - var arr; - var buf; - var out; - - arr = new Float16Array( [ 1.05, 1.05, 1.05, 1.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 1.05 ), - toWord( 1.05 ), - toWord( 2.05 ) - ]); - out = arr.with( -1, 2.05 ); - buf = new Uint16Array( out.buffer ); - - t.strictEqual( out instanceof Float16Array, true, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); From 00ae2d8eff194894eafccaf050f8db3c5a4bf8e6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 2 Jun 2026 09:59:36 +0000 Subject: [PATCH 12/14] Transform error messages --- lib/polyfill/index.js | 104 +++++++++++++++++++++--------------------- package.json | 2 +- 2 files changed, 53 insertions(+), 53 deletions(-) diff --git a/lib/polyfill/index.js b/lib/polyfill/index.js index bd087e9..f4a1a8f 100644 --- a/lib/polyfill/index.js +++ b/lib/polyfill/index.js @@ -38,7 +38,7 @@ var setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); var setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' ); var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var Uint16Array = require( '@stdlib/array-uint16' ); var f16 = require( '@stdlib/number-float64-base-to-float16' ); var toWord = require( '@stdlib/number-float16-base-to-word' ); @@ -234,49 +234,49 @@ function Float16Array() { } } else if ( isArrayBuffer( arg ) ) { if ( !isInteger( arg.byteLength/BYTES_PER_ELEMENT ) ) { - throw new RangeError( format( 'invalid argument. ArrayBuffer byte length must be a multiple of %u. Byte length: `%u`.', BYTES_PER_ELEMENT, arg.byteLength ) ); + throw new RangeError( format( 'nullE9', BYTES_PER_ELEMENT, arg.byteLength ) ); } buf = new Uint16Array( arg ); } else if ( isObject( arg ) ) { if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, ArrayBuffer, typed array, or array-like object. Value: `%s`.', arg ) ); + throw new TypeError( format( 'null29', arg ) ); } if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( 'null2A', arg ) ); } buf = arg[ ITERATOR_SYMBOL ](); if ( !isFunction( buf.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( 'null2A', arg ) ); } buf = new Uint16Array( fromIterator( buf ) ); } else { - throw new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); + throw new TypeError( format( 'null2A', arg ) ); } } else { buf = arguments[ 0 ]; if ( !isArrayBuffer( buf ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', buf ) ); + throw new TypeError( format( 'null2B', buf ) ); } byteOffset = arguments[ 1 ]; if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) ); + throw new TypeError( format( 'null2C', byteOffset ) ); } if ( !isInteger( byteOffset/BYTES_PER_ELEMENT ) ) { - throw new RangeError( format( 'invalid argument. Byte offset must be a multiple of %u. Value: `%u`.', BYTES_PER_ELEMENT, byteOffset ) ); + throw new RangeError( format( 'nullEA', BYTES_PER_ELEMENT, byteOffset ) ); } if ( nargs === 2 ) { len = buf.byteLength - byteOffset; if ( !isInteger( len/BYTES_PER_ELEMENT ) ) { - throw new RangeError( format( 'invalid arguments. ArrayBuffer view byte length must be a multiple of %u. View byte length: `%u`.', BYTES_PER_ELEMENT, len ) ); + throw new RangeError( format( 'null2E', BYTES_PER_ELEMENT, len ) ); } buf = new Uint16Array( buf, byteOffset ); } else { len = arguments[ 2 ]; if ( !isNonNegativeInteger( len ) ) { - throw new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', len ) ); + throw new TypeError( format( 'null2F', len ) ); } if ( (len*BYTES_PER_ELEMENT) > (buf.byteLength-byteOffset) ) { - throw new RangeError( format( 'invalid arguments. ArrayBuffer has insufficient capacity. Either decrease the array length or provide a bigger buffer. Minimum capacity: `%u`.', len*BYTES_PER_ELEMENT ) ); + throw new RangeError( format( 'null2G', len*BYTES_PER_ELEMENT ) ); } buf = new Uint16Array( buf, byteOffset, len ); } @@ -362,7 +362,7 @@ setReadOnly( Float16Array, 'from', function from( src ) { var len; var i; if ( !isFunction( this ) ) { - throw new TypeError( 'invalid invocation. `this` context must be a constructor.' ); + throw new TypeError( format('null01') ); } if ( !isFloatingPointArrayConstructor( this ) ) { throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); @@ -371,7 +371,7 @@ setReadOnly( Float16Array, 'from', function from( src ) { if ( nargs > 1 ) { clbk = arguments[ 1 ]; if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', clbk ) ); + throw new TypeError( format( 'null2H', clbk ) ); } if ( nargs > 2 ) { thisArg = arguments[ 2 ]; @@ -392,7 +392,7 @@ setReadOnly( Float16Array, 'from', function from( src ) { if ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) { // eslint-disable-line max-len buf = src[ ITERATOR_SYMBOL ](); if ( !isFunction( buf.next ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) ); + throw new TypeError( format( 'null2J', src ) ); } if ( clbk ) { tmp = fromIteratorMap( buf, clbk, thisArg ); @@ -410,7 +410,7 @@ setReadOnly( Float16Array, 'from', function from( src ) { } return out; } - throw new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) ); + throw new TypeError( format( 'null2J', src ) ); }); /** @@ -438,7 +438,7 @@ setReadOnly( Float16Array, 'of', function of() { var args; var i; if ( !isFunction( this ) ) { - throw new TypeError( 'invalid invocation. `this` context must be a constructor.' ); + throw new TypeError( format('null01') ); } if ( !isFloatingPointArrayConstructor( this ) ) { throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); @@ -478,7 +478,7 @@ setReadOnly( Float16Array.prototype, 'at', function at( idx ) { throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Must provide an integer. Value: `%s`.', idx ) ); + throw new TypeError( format( 'null8A', idx ) ); } if ( idx < 0 ) { idx += this._length; @@ -731,7 +731,7 @@ setReadOnly( Float16Array.prototype, 'every', function every( predicate, thisArg throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( 'null3c', predicate ) ); } buf = this._buffer; for ( i = 0; i < this._length; i++ ) { @@ -781,13 +781,13 @@ setReadOnly( Float16Array.prototype, 'fill', function fill( value, start, end ) throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isNumber( value ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a number. Value: `%s`.', value ) ); + throw new TypeError( format( 'null49', value ) ); } buf = this._buffer; len = this._length; if ( arguments.length > 1 ) { if ( !isInteger( start ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', start ) ); + throw new TypeError( format( 'null7f', start ) ); } if ( start < 0 ) { start += len; @@ -797,7 +797,7 @@ setReadOnly( Float16Array.prototype, 'fill', function fill( value, start, end ) } if ( arguments.length > 2 ) { if ( !isInteger( end ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', end ) ); + throw new TypeError( format( 'null2z', end ) ); } if ( end < 0 ) { end += len; @@ -863,7 +863,7 @@ setReadOnly( Float16Array.prototype, 'filter', function filter( predicate, thisA throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( 'null3c', predicate ) ); } buf = this._buffer; out = []; @@ -907,7 +907,7 @@ setReadOnly( Float16Array.prototype, 'find', function find( predicate, thisArg ) throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( 'null3c', predicate ) ); } buf = this._buffer; for ( i = 0; i < this._length; i++ ) { @@ -949,7 +949,7 @@ setReadOnly( Float16Array.prototype, 'findIndex', function findIndex( predicate, throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( 'null3c', predicate ) ); } buf = this._buffer; for ( i = 0; i < this._length; i++ ) { @@ -992,7 +992,7 @@ setReadOnly( Float16Array.prototype, 'findLast', function findLast( predicate, t throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( 'null3c', predicate ) ); } buf = this._buffer; for ( i = this._length-1; i >= 0; i-- ) { @@ -1034,7 +1034,7 @@ setReadOnly( Float16Array.prototype, 'findLastIndex', function findLastIndex( pr throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( 'null3c', predicate ) ); } buf = this._buffer; for ( i = this._length-1; i >= 0; i-- ) { @@ -1074,7 +1074,7 @@ setReadOnly( Float16Array.prototype, 'forEach', function forEach( fcn, thisArg ) throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( 'null3c', fcn ) ); } buf = this._buffer; for ( i = 0; i < this._length; i++ ) { @@ -1099,7 +1099,7 @@ setReadOnly( Float16Array.prototype, '_get', function get( idx ) { throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isNonNegativeInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Must provide a nonnegative integer. Value: `%s`.', idx ) ); + throw new TypeError( format( 'null2K', idx ) ); } if ( idx >= this._length ) { return; @@ -1141,11 +1141,11 @@ setReadOnly( Float16Array.prototype, 'includes', function includes( searchElemen throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isNumber( searchElement ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a number. Value: `%s`.', searchElement ) ); + throw new TypeError( format( 'null49', searchElement ) ); } if ( arguments.length > 1 ) { if ( !isInteger( fromIndex ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) ); + throw new TypeError( format( 'null7f', fromIndex ) ); } if ( fromIndex < 0 ) { fromIndex += this._length; @@ -1200,11 +1200,11 @@ setReadOnly( Float16Array.prototype, 'indexOf', function indexOf( searchElement, throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isNumber( searchElement ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a number. Value: `%s`.', searchElement ) ); + throw new TypeError( format( 'null49', searchElement ) ); } if ( arguments.length > 1 ) { if ( !isInteger( fromIndex ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) ); + throw new TypeError( format( 'null7f', fromIndex ) ); } if ( fromIndex < 0 ) { fromIndex += this._length; @@ -1255,7 +1255,7 @@ setReadOnly( Float16Array.prototype, 'join', function join( separator ) { } if ( arguments.length > 0 ) { if ( !isString( separator ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', separator ) ); + throw new TypeError( format( 'null3F', separator ) ); } } else { separator = ','; @@ -1404,11 +1404,11 @@ setReadOnly( Float16Array.prototype, 'lastIndexOf', function lastIndexOf( search throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isNumber( searchElement ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a number. Value: `%s`.', searchElement ) ); + throw new TypeError( format( 'null49', searchElement ) ); } if ( arguments.length > 1 ) { if ( !isInteger( fromIndex ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) ); + throw new TypeError( format( 'null7f', fromIndex ) ); } if ( fromIndex >= this._length ) { fromIndex = this._length - 1; @@ -1486,7 +1486,7 @@ setReadOnly( Float16Array.prototype, 'map', function map( fcn, thisArg ) { throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isFunction( fcn ) ) { - throw new TypeError( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ); + throw new TypeError( format('null3c'), fcn ); } buf = this._buffer; out = new this.constructor( this._length ); @@ -1529,7 +1529,7 @@ setReadOnly( Float16Array.prototype, 'reduce', function reduce( reducer, initial throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isFunction( reducer ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', reducer ) ); + throw new TypeError( format( 'null3c', reducer ) ); } buf = this._buffer; len = this._length; @@ -1581,7 +1581,7 @@ setReadOnly( Float16Array.prototype, 'reduceRight', function reduceRight( reduce throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isFunction( reducer ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', reducer ) ); + throw new TypeError( format( 'null3c', reducer ) ); } buf = this._buffer; len = this._length; @@ -1707,20 +1707,20 @@ setReadOnly( Float16Array.prototype, 'set', function set( value ) { throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isCollection( value ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', value ) ); + throw new TypeError( format( 'null2O', value ) ); } buf = this._buffer; if ( arguments.length > 1 ) { idx = arguments[ 1 ]; if ( !isNonNegativeInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Index argument must be a nonnegative integer. Value: `%s`.', idx ) ); + throw new TypeError( format( 'null2L', idx ) ); } } else { idx = 0; } N = value.length; if ( idx+N > this._length ) { - throw new RangeError( 'invalid arguments. Target array lacks sufficient storage to accommodate source values.' ); + throw new RangeError( format('null03') ); } if ( isFloat16Array( value ) ) { sbuf = value._buffer; // eslint-disable-line no-underscore-dangle @@ -1814,7 +1814,7 @@ setReadOnly( Float16Array.prototype, 'slice', function slice( begin, end ) { end = len; } else { if ( !isInteger( begin ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', begin ) ); + throw new TypeError( format( 'null7e', begin ) ); } if ( begin < 0 ) { begin += len; @@ -1826,7 +1826,7 @@ setReadOnly( Float16Array.prototype, 'slice', function slice( begin, end ) { end = len; } else { if ( !isInteger( end ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', end ) ); + throw new TypeError( format( 'null7f', end ) ); } if ( end < 0 ) { end += len; @@ -1881,7 +1881,7 @@ setReadOnly( Float16Array.prototype, 'some', function some( predicate, thisArg ) throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( 'null3c', predicate ) ); } buf = this._buffer; for ( i = 0; i < this._length; i++ ) { @@ -1939,7 +1939,7 @@ setReadOnly( Float16Array.prototype, 'sort', function sort( compareFcn ) { return this; } if ( !isFunction( compareFcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', compareFcn ) ); + throw new TypeError( format( 'null3c', compareFcn ) ); } buf.sort( compare ); return this; @@ -2044,7 +2044,7 @@ setReadOnly( Float16Array.prototype, 'subarray', function subarray( begin, end ) end = len; } else { if ( !isInteger( begin ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', begin ) ); + throw new TypeError( format( 'null7e', begin ) ); } if ( begin < 0 ) { begin += len; @@ -2056,7 +2056,7 @@ setReadOnly( Float16Array.prototype, 'subarray', function subarray( begin, end ) end = len; } else { if ( !isInteger( end ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', end ) ); + throw new TypeError( format( 'null7f', end ) ); } if ( end < 0 ) { end += len; @@ -2122,7 +2122,7 @@ setReadOnly( Float16Array.prototype, 'toLocaleString', function toLocaleString( } else if ( isObject( options ) ) { opts = options; } else { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + throw new TypeError( format( 'null2V', options ) ); } buf = this._buffer; out = []; @@ -2387,17 +2387,17 @@ setReadOnly( Float16Array.prototype, 'with', function copyWith( index, value ) { throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); } if ( !isInteger( index ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', index ) ); + throw new TypeError( format( 'null7e', index ) ); } len = this._length; if ( index < 0 ) { index += len; } if ( index < 0 || index >= len ) { - throw new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%s`.', index ) ); + throw new RangeError( format( 'nullFP', index ) ); } if ( !isNumber( value ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a number. Value: `%s`.', value ) ); + throw new TypeError( format( 'null4A', value ) ); } out = new this.constructor( this ); out[ index ] = value; diff --git a/package.json b/package.json index 7f32128..0ed7acd 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "@stdlib/number-float16-base-from-word": "^0.2.1", "@stdlib/number-float16-base-to-word": "^0.1.1", "@stdlib/number-float64-base-to-float16": "^0.1.2", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/symbol-iterator": "^0.2.3", "@stdlib/types": "^0.4.3", "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.4", From af8e5cbfc328bce6d969c733001fdbd512da3dcb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 2 Jun 2026 10:00:00 +0000 Subject: [PATCH 13/14] Remove files --- index.d.ts | 1312 -------------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 6159 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index ed52b06..0000000 --- a/index.d.ts +++ /dev/null @@ -1,1312 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2026 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. -*/ - -/* eslint-disable max-lines */ - -// TypeScript Version: 4.1 - -/// - -import { Iterator as Iter, IterableIterator, TypedIterator } from '@stdlib/types/iter'; -import { ArrayLike } from '@stdlib/types/array'; -import ArrayBuffer = require( '@stdlib/array-buffer' ); - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = Iter | IterableIterator; - -/** -* Locale-specific configuration options. -*/ -interface LocaleOptions { - /** - * Configuration property. - */ - [ key: string | symbol | number ]: T | undefined; -} - -/** -* Callback invoked for each element in a source object. -* -* @returns transformed value -*/ -type FromNullary = ( this: U ) => number; - -/** -* Callback invoked for each element in a source object. -* -* @param value - source element -* @returns transformed value -*/ -type FromUnary = ( this: U, value: number ) => number; - -/** -* Callback invoked for each element in a source object. -* -* @param value - source element -* @param index - source element index -* @returns transformed value -*/ -type FromBinary = ( this: U, value: number, index: number ) => number; - -/** -* Callback invoked for each element in a source object. -* -* @param value - source element -* @param index - source element index -* @returns transformed value -*/ -type FromCallback = FromNullary | FromUnary | FromBinary; - -/** -* Checks whether an element in an array passes a test. -* -* @returns boolean indicating whether an element in an array passes a test -*/ -type NullaryPredicate = ( this: U ) => boolean; - -/** -* Checks whether an element in an array passes a test. -* -* @param value - current array element -* @returns boolean indicating whether an element in an array passes a test -*/ -type UnaryPredicate = ( this: U, value: number ) => boolean; - -/** -* Checks whether an element in an array passes a test. -* -* @param value - current array element -* @param index - current array element index -* @returns boolean indicating whether an element in an array passes a test -*/ -type BinaryPredicate = ( this: U, value: number, index: number ) => boolean; - -/** -* Checks whether an element in an array passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - array on which the method was called -* @returns boolean indicating whether an element in an array passes a test -*/ -type TernaryPredicate = ( this: U, value: number, index: number, arr: Float16Array ) => boolean; - -/** -* Checks whether an element in an array passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - array on which the method was called -* @returns boolean indicating whether an element in an array passes a test -*/ -type Predicate = NullaryPredicate | UnaryPredicate | BinaryPredicate | TernaryPredicate; - -/** -* Callback invoked for each element in an array. -* -* @returns undefined -*/ -type NullaryCallback = ( this: U ) => void; - -/** -* Callback invoked for each element in an array. -* -* @param value - current array element -* @returns undefined -*/ -type UnaryCallback = ( this: U, value: number ) => void; - -/** -* Callback invoked for each element in an array. -* -* @param value - current array element -* @param index - current array element index -* @returns undefined -*/ -type BinaryCallback = ( this: U, value: number, index: number ) => void; - -/** -* Callback invoked for each element in an array. -* -* @param value - current array element -* @param index - current array element index -* @param arr - array on which the method was called -* @returns undefined -*/ -type TernaryCallback = ( this: U, value: number, index: number, arr: Float16Array ) => void; - -/** -* Callback invoked for each element in an array. -* -* @param value - current array element -* @param index - current array element index -* @param arr - array on which the method was called -* @returns undefined -*/ -type Callback = NullaryCallback | UnaryCallback | BinaryCallback | TernaryCallback; - -/** -* Callback invoked for each element in an array. -* -* @returns returned value -*/ -type NullaryMapFcn = ( this: U ) => number; - -/** -* Callback invoked for each element in an array. -* -* @param value - current array element -* @returns returned value -*/ -type UnaryMapFcn = ( this: U, value: number ) => number; - -/** -* Callback invoked for each element in an array. -* -* @param value - current array element -* @param index - current array element index -* @returns returned value -*/ -type BinaryMapFcn = ( this: U, value: number, index: number ) => number; - -/** -* Callback invoked for each element in an array. -* -* @param value - current array element -* @param index - current array element index -* @param arr - array on which the method was called -* @returns returned value -*/ -type TernaryMapFcn = ( this: U, value: number, index: number, arr: Float16Array ) => number; - -/** -* Callback invoked for each element in an array. -* -* @param value - current array element -* @param index - current array element index -* @param arr - array on which the method was called -* @returns returned value -*/ -type MapFcn = NullaryMapFcn | UnaryMapFcn | BinaryMapFcn | TernaryMapFcn; - -/** -* Reducer function invoked for each element in an array. -* -* @returns accumulated result -*/ -type NullaryReducer = () => U; - -/** -* Reducer function invoked for each element in an array. -* -* @param acc - accumulated result -* @returns accumulated result -*/ -type UnaryReducer = ( acc: U ) => U; - -/** -* Reducer function invoked for each element in an array. -* -* @param acc - accumulated result -* @param value - current array element -* @returns accumulated result -*/ -type BinaryReducer = ( acc: U, value: number ) => U; - -/** -* Reducer function invoked for each element in an array. -* -* @param acc - accumulated result -* @param value - current array element -* @param index - current array element index -* @returns accumulated result -*/ -type TernaryReducer = ( acc: U, value: number, index: number ) => U; - -/** -* @param acc - accumulated result -* @param value - current array element -* @param index - current array element index -* @param arr - array on which the method was called -* @returns accumulated result -*/ -type QuaternaryReducer = ( acc: U, value: number, index: number, arr: Float16Array ) => U; - -/** -* Reducer function invoked for each element in an array. -* -* @param acc - accumulated result -* @param value - current array element -* @param index - current array element index -* @param arr - array on which the method was called -* @returns accumulated result -*/ -type Reducer = NullaryReducer | UnaryReducer | BinaryReducer | TernaryReducer | QuaternaryReducer; - -/** -* Comparator function. -* -* @param a - first number for comparison -* @param b - second number for comparison -* @returns number indicating comparison result -*/ -type CompareFcn = ( a: number, b: number ) => number; - -/** -* Class for creating a half-precision floating-point number array. -*/ -declare class Float16Array { - /** - * Half-precision floating-point number array constructor. - * - * @param arg - length, typed array, array-like object, or buffer - * @param byteOffset - byte offset (default: 0) - * @param length - view length - * @throws ArrayBuffer byte length must be a multiple of `2` - * @throws if provided only a single argument, must provide a valid argument - * @throws byte offset must be a nonnegative integer - * @throws view length must be a positive multiple of `2` - * @throws must provide sufficient memory to accommodate byte offset and view length requirements - * @returns half-precision floating-point number array - * - * @example - * var arr = new Float16Array(); - * // returns - * - * var len = arr.length; - * // returns 0 - * - * @example - * var arr = new Float16Array( 2 ); - * // returns - * - * var len = arr.length; - * // returns 2 - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0 ] ); - * // returns - * - * var len = arr.length; - * // returns 2 - * - * @example - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = new Float16Array( buf ); - * // returns - * - * var len = arr.length; - * // returns 8 - * - * @example - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = new Float16Array( buf, 8 ); - * // returns - * - * var len = arr.length; - * // returns 4 - * - * @example - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = new Float16Array( buf, 8, 2 ); - * // returns - * - * var len = arr.length; - * // returns 2 - */ - constructor( arg?: number | ArrayLike | ArrayBuffer | Iterable, byteOffset?: number, length?: number ); - - /** - * Returns an array element located at integer position (index) `i`, with support for both nonnegative and negative integer indices. - * - * @param i - element index - * @throws index argument must be an integer - * @returns array element - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var v = arr.at( 0 ); - * // returns 1.0 - * - * v = arr.at( -1 ); - * // returns 3.0 - * - * v = arr.at( 100 ); - * // returns undefined - */ - at( i: number ): number | void; - - /** - * Pointer to the underlying data buffer. - * - * @example - * var arr = new Float16Array( 10 ); - * - * var buf = arr.buffer; - * // returns - */ - readonly buffer: ArrayBuffer; - - /** - * Length (in bytes) of the array. - * - * @example - * var arr = new Float16Array( 10 ); - * - * var byteLength = arr.byteLength; - * // returns 20 - */ - readonly byteLength: number; - - /** - * Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`. - * - * @example - * var arr = new Float16Array( 10 ); - * - * var byteOffset = arr.byteOffset; - * // returns 0 - */ - readonly byteOffset: number; - - /** - * Size (in bytes) of each array element. - * - * @example - * var arr = new Float16Array( 10 ); - * - * var nbytes = arr.BYTES_PER_ELEMENT; - * // returns 2 - */ - readonly BYTES_PER_ELEMENT: 2; - - /** - * Number of array elements. - * - * @example - * var arr = new Float16Array( 10 ); - * - * var len = arr.length; - * // returns 10 - */ - readonly length: number; - - /** - * Copies a sequence of elements within the array to the position starting at `target`. - * - * @param target - index at which to start copying elements - * @param start - source index at which to copy elements from - * @param end - source index at which to stop copying elements from - * @returns modified array - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - * - * // Copy the first two elements to the last two elements: - * arr.copyWithin( 2, 0, 2 ); - * - * var v = arr[ 2 ]; - * // returns 1.0 - * - * v = arr[ 3 ]; - * // returns 2.0 - */ - copyWithin( target: number, start: number, end?: number ): Float16Array; - - /** - * Returns an iterator for iterating over array key-value pairs. - * - * @returns iterator - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var it = arr.entries(); - * - * var v = it.next().value; - * // returns [ 0, 1.0 ] - * - * v = it.next().value; - * // returns [ 1, 2.0 ] - * - * v = it.next().value; - * // returns [ 2, 3.0 ] - * - * var bool = it.next().done; - * // returns true - */ - entries(): TypedIterator<[number, number]>; - - /** - * Tests whether all elements in an array pass a test implemented by a predicate function. - * - * @param predicate - predicate function - * @param thisArg - predicate function execution context - * @returns boolean indicating whether all elements pass a test - * - * @example - * function predicate( v ) { - * return v >= 0.0; - * } - * - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var bool = arr.every( predicate ); - * // returns true - */ - every( predicate: Predicate, thisArg?: ThisParameterType> ): boolean; - - /** - * Returns a modified typed array filled with a fill value. - * - * @param value - fill value - * @param start - starting index (inclusive) - * @param end - ending index (exclusive) - * @returns modified typed array - * - * @example - * var arr = new Float16Array( 3 ); - * - * arr.fill( 1.0, 1 ); - * - * var v = arr[ 0 ]; - * // returns 0.0 - * - * v = arr[ 1 ]; - * // returns 1.0 - * - * v = arr[ 2 ]; - * // returns 1.0 - */ - fill( value: number, start?: number, end?: number ): Float16Array; - - /** - * Returns a new array containing the elements of an array which pass a test implemented by a predicate function. - * - * @param predicate - test function - * @param thisArg - execution context - * @returns new array containing elements which pass a test implemented by a predicate function - * - * @example - * function predicate( v ) { - * return ( v >= 2.0 ); - * } - * - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var out = arr.filter( predicate ); - * // returns - * - * var len = out.length; - * // returns 2 - * - * var v = out[ 0 ]; - * // returns 2.0 - * - * v = out[ 1 ]; - * // returns 3.0 - */ - filter( predicate: Predicate, thisArg?: ThisParameterType> ): Float16Array; - - /** - * Returns the first element in an array for which a predicate function returns a truthy value. - * - * @param predicate - predicate function - * @param thisArg - predicate function execution context - * @returns array element or undefined - * - * @example - * function predicate( v ) { - * return v > 1.0; - * } - * - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var v = arr.find( predicate ); - * // returns 2.0 - */ - find( predicate: Predicate, thisArg?: ThisParameterType> ): number | void; - - /** - * Returns the index of the first element in an array for which a predicate function returns a truthy value. - * - * @param predicate - predicate function - * @param thisArg - predicate function execution context - * @returns array index or -1 - * - * @example - * function predicate( v ) { - * return v > 1.0; - * } - * - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var v = arr.findIndex( predicate ); - * // returns 1 - */ - findIndex( predicate: Predicate, thisArg?: ThisParameterType> ): number; - - /** - * Returns the last element in an array for which a predicate function returns a truthy value. - * - * @param predicate - predicate function - * @param thisArg - predicate function execution context - * @returns array element or undefined - * - * @example - * function predicate( v ) { - * return v > 1.0; - * } - * - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var v = arr.findLast( predicate ); - * // returns 3.0 - */ - findLast( predicate: Predicate, thisArg?: ThisParameterType> ): number | void; - - /** - * Returns the index of the last element in an array for which a predicate function returns a truthy value. - * - * @param predicate - predicate function - * @param thisArg - predicate function execution context - * @returns array index or -1 - * - * @example - * function predicate( v ) { - * return v > 1.0; - * } - * - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var v = arr.findLastIndex( predicate ); - * // returns 2 - */ - findLastIndex( predicate: Predicate, thisArg?: ThisParameterType> ): number; - - /** - * Invokes a function once for each array element. - * - * @param fcn - function to invoke - * @param thisArg - execution context - * @returns undefined - * - * @example - * function log( v, i ) { - * console.log( '%s: %s', i, v.toString() ); - * } - * - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * arr.forEach( log ); - */ - forEach( fcn: Callback, thisArg?: ThisParameterType> ): void; - - /** - * Returns a boolean indicating whether an array includes a provided value. - * - * @param searchElement - element to search for - * @param fromIndex - starting index (inclusive) - * @returns boolean indicating whether an array includes a value - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - * - * var bool = arr.includes( 3.0 ); - * // returns true - * - * bool = arr.includes( 3.0, 3 ); - * // returns false - */ - includes( searchElement: number, fromIndex?: number ): boolean; - - /** - * Returns the first index at which a given element can be found. - * - * @param searchElement - element to find - * @param fromIndex - starting index (inclusive) - * @returns index or -1 - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - * - * var idx = arr.indexOf( 3.0 ); - * // returns 2 - * - * idx = arr.indexOf( 3.0, 3 ); - * // returns -1 - * - * idx = arr.indexOf( 6.0 ); - * // returns -1 - */ - indexOf( searchElement: number, fromIndex?: number ): number; - - /** - * Returns a new string by concatenating all array elements. - * - * @param separator - value separator (default: ',') - * @returns string - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var str = arr.join(); - * // returns '1,2,3' - * - * str = arr.join( '|' ); - * // returns '1|2|3' - */ - join( separator?: string ): string; - - /** - * Returns an iterator for iterating over each index key in a typed array. - * - * @returns iterator - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0 ] ); - * - * var iter = arr.keys(); - * - * var v = iter.next().value; - * // returns 0 - * - * v = iter.next().value; - * // returns 1 - * - * var bool = iter.next().done; - * // returns true - */ - keys(): TypedIterator; - - /** - * Returns the last index at which a given element can be found. - * - * @param searchElement - element to find - * @param fromIndex - index at which to start searching backward (inclusive) - * @returns index or -1 - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0, 3.0, 2.0, 1.0 ] ); - * - * var idx = arr.lastIndexOf( 2.0 ); - * // returns 3 - * - * idx = arr.lastIndexOf( 2.0, 2 ); - * // returns 1 - * - * idx = arr.lastIndexOf( 5.0 ); - * // returns -1 - */ - lastIndexOf( searchElement: number, fromIndex?: number ): number; - - /** - * Returns a new array with each element being the result of a provided callback function. - * - * @param fcn - callback function - * @param thisArg - callback function execution context - * @returns new half-precision floating-point number array - * - * @example - * function scale( v ) { - * return v * 2.0; - * } - * - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var out = arr.map( scale ); - * // returns - * - * var v = out[ 0 ]; - * // returns 2.0 - * - * v = out[ 1 ]; - * // returns 4.0 - * - * v = out[ 2 ]; - * // returns 6.0 - */ - map( fcn: MapFcn, thisArg?: ThisParameterType> ): Float16Array; - - /** - * Applies a provided callback function to each element of the array, in order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion. - * - * @param reducer - callback function - * @param initialValue - initial value - * @returns accumulated result - * - * @example - * function reducer( acc, v ) { - * return acc + v; - * } - * - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var out = arr.reduce( reducer, 0.0 ); - * // returns 6.0 - */ - reduce( reducer: Reducer, initialValue?: U ): U; - - /** - * Applies a provided callback function to each element of the array, in reverse order, passing in the return value from the calculation on the following element and returning the accumulated result upon completion. - * - * @param reducer - callback function - * @param initialValue - initial value - * @returns accumulated result - * - * @example - * function reducer( acc, v ) { - * return acc + v; - * } - * - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var out = arr.reduceRight( reducer, 0.0 ); - * // returns 6.0 - */ - reduceRight( reducer: Reducer, initialValue?: U ): U; - - /** - * Reverses an array in-place. - * - * @returns reversed array - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var out = arr.reverse(); - * // returns - * - * var v = out[ 0 ]; - * // returns 3.0 - * - * v = out[ 1 ]; - * // returns 2.0 - * - * v = out[ 2 ]; - * // returns 1.0 - */ - reverse(): Float16Array; - - /** - * Sets one or more array elements. - * - * ## Notes - * - * - When provided a typed array, we must check whether the source array shares the same buffer as the target array and whether the underlying memory overlaps. In particular, we are concerned with the following scenario: - * - * ```text - * buf: --------------------- - * src: --------------------- - * ``` - * - * In the above, as we copy values from `src`, we will overwrite values in the `src` view, resulting in duplicated values copied into the end of `buf`, which is not intended. Hence, to avoid overwriting source values, we must **copy** source values to a temporary array. - * - * In the other overlapping scenario, - * - * ```text - * buf: --------------------- - * src: --------------------- - * ``` - * - * by the time we begin copying into the overlapping region, we are copying from the end of `src`, a non-overlapping region, which means we don't run the risk of copying copied values, rather than the original `src` values as intended. - * - * - * @param value - value(s) - * @param i - element index at which to start writing values (default: 0) - * @throws index argument must be a nonnegative integer - * @throws index argument is out-of-bounds - * @throws target array lacks sufficient storage to accommodate source values - * - * @example - * var arr = new Float16Array( 10 ); - * - * var v = arr[ 0 ]; - * // returns 0.0 - * - * arr.set( [ 1.0 ], 0 ); - * - * v = arr[ 0 ]; - * // returns 1.0 - */ - set( value: ArrayLike, i?: number ): void; - - /** - * Copies a portion of a typed array to a new typed array. - * - * @param start - starting index (inclusive) - * @param end - ending index (exclusive) - * @throws indices must be integers - * @returns output array - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - * - * var out = arr.slice(); - * // returns - * - * var len = out.length; - * // returns 5 - * - * var v = out[ 0 ]; - * // returns 1.0 - * - * v = out[ len-1 ]; - * // returns 5.0 - * - * out = arr.slice( 1, -2 ); - * // returns - * - * len = out.length; - * // returns 2 - * - * v = out[ 0 ]; - * // returns 2.0 - * - * v = out[ len-1 ]; - * // returns 3.0 - */ - slice( start?: number, end?: number ): Float16Array; - - /** - * Tests whether at least one element in an array passes a test implemented by a predicate function. - * - * @param predicate - predicate function - * @param thisArg - predicate function execution context - * @returns boolean indicating whether at least one element passes a test - * - * @example - * function predicate( v ) { - * return v > 2.0; - * } - * - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var bool = arr.some( predicate ); - * // returns true - */ - some( predicate: Predicate, thisArg?: ThisParameterType> ): boolean; - - /** - * Sorts an array in-place. - * - * @param compareFcn - comparison function - * @returns sorted array - * - * @example - * function compare( a, b ) { - * if ( a < b ) { - * return -1; - * } - * if ( a > b ) { - * return 1; - * } - * return 0; - * } - * - * var arr = new Float16Array( [ 3.0, 1.0, 2.0 ] ); - * - * arr.sort( compare ); - * - * var v = arr[ 0 ]; - * // returns 1.0 - * - * v = arr[ 1 ]; - * // returns 2.0 - * - * v = arr[ 2 ]; - * // returns 3.0 - */ - sort( compareFcn?: CompareFcn ): Float16Array; - - /** - * Creates a new typed array view over the same underlying `ArrayBuffer` and with the same underlying data type as the host array. - * - * @param begin - starting index (inclusive) - * @param end - ending index (exclusive) - * @throws indices must be integers - * @returns subarray - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - * - * var subarr = arr.subarray(); - * // returns - * - * var len = subarr.length; - * // returns 5 - * - * var v = subarr[ 0 ]; - * // returns 1.0 - * - * v = subarr[ len-1 ]; - * // returns 5.0 - * - * subarr = arr.subarray( 1, -2 ); - * // returns - * - * len = subarr.length; - * // returns 2 - * - * v = subarr[ 0 ]; - * // returns 2.0 - * - * v = subarr[ len-1 ]; - * // returns 3.0 - */ - subarray( begin?: number, end?: number ): Float16Array; - - /** - * Serializes an array as a locale-specific string. - * - * @param locales - locale identifier(s) - * @param options - configuration options - * @returns string - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var str = arr.toLocaleString(); - * // returns '1,2,3' - */ - toLocaleString( locales?: string | Array, options?: LocaleOptions ): string; - - /** - * Returns a new typed array containing the elements in reversed order. - * - * @returns reversed array - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var out = arr.toReversed(); - * // returns - * - * var v = out[ 0 ]; - * // returns 3.0 - * - * v = out[ 1 ]; - * // returns 2.0 - * - * v = out[ 2 ]; - * // returns 1.0 - */ - toReversed(): Float16Array; - - /** - * Returns a new typed array containing the elements in sorted order. - * - * @param compareFcn - comparison function - * @returns sorted array - * - * @example - * function compare( a, b ) { - * if ( a < b ) { - * return -1; - * } - * if ( a > b ) { - * return 1; - * } - * return 0; - * } - * - * var arr = new Float16Array( [ 3.0, 1.0, 2.0 ] ); - * - * var out = arr.toSorted( compare ); - * // returns - * - * var v = out[ 0 ]; - * // returns 1.0 - * - * v = out[ 1 ]; - * // returns 2.0 - * - * v = out[ 2 ]; - * // returns 3.0 - */ - toSorted( compareFcn?: CompareFcn ): Float16Array; - - /** - * Serializes an array as a string. - * - * @returns string - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var str = arr.toString(); - * // returns '1,2,3' - */ - toString(): string; - - /** - * Returns an iterator for iterating over each value in a typed array. - * - * @returns iterator - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0 ] ); - * - * var iter = arr.values(); - * - * var v = iter.next().value; - * // returns 1.0 - * - * v = iter.next().value; - * // returns 2.0 - * - * var bool = iter.next().done; - * // returns true - */ - values(): TypedIterator; - - /** - * Returns a new typed array with the element at a provided index replaced with a provided value. - * - * @param index - element index - * @param value - new value - * @throws first argument must be an integer - * @throws second argument must be a number - * @throws index argument is out-of-bounds - * @returns modified typed array - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - * - * var out = arr.with( 0, 4.0 ); - * // returns - * - * var v = out[ 0 ]; - * // returns 4.0 - */ - with( index: number, value: number ): Float16Array; -} - -/** -* Interface defining a Float16Array constructor which is both "newable" and "callable". -*/ -interface Float16ArrayConstructor { - /** - * Half-precision floating-point number array constructor. - * - * @param arg - length, typed array, array-like object, or buffer - * @param byteOffset - byte offset (default: 0) - * @param length - view length - * @throws ArrayBuffer byte length must be a multiple of `2` - * @throws if provided only a single argument, must provide a valid argument - * @throws byte offset must be a nonnegative integer - * @throws byte offset must be a multiple of `2` - * @throws view length must be a positive multiple of `2` - * @throws must provide sufficient memory to accommodate byte offset and view length requirements - * @returns half-precision floating-point number array - * - * @example - * var arr = new Float16Array(); - * // returns - * - * var len = arr.length; - * // returns 0 - * - * @example - * var arr = new Float16Array( 2 ); - * // returns - * - * var len = arr.length; - * // returns 2 - * - * @example - * var arr = new Float16Array( [ 1.0, 2.0 ] ); - * // returns - * - * var len = arr.length; - * // returns 2 - * - * @example - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = new Float16Array( buf ); - * // returns - * - * var len = arr.length; - * // returns 8 - * - * @example - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = new Float16Array( buf, 8 ); - * // returns - * - * var len = arr.length; - * // returns 4 - * - * @example - * var ArrayBuffer = require( '@stdlib/array-buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = new Float16Array( buf, 8, 2 ); - * // returns - * - * var len = arr.length; - * // returns 2 - */ - new( arg?: number | ArrayLike | ArrayBuffer | Iterable, byteOffset?: number, length?: number ): Float16Array; - - /** - * Constructor name. - * - * @example - * var str = Float16Array.name; - * // returns 'Float16Array' - */ - readonly name: 'Float16Array'; - - /** - * Size (in bytes) of each array element. - * - * @example - * var nbytes = Float16Array.BYTES_PER_ELEMENT; - * // returns 2 - */ - readonly BYTES_PER_ELEMENT: 2; - - /** - * Creates a new half-precision floating-point number array from an array-like object or an iterable. - * - * @param src - array-like object or iterable - * @param clbk - callback to invoke for each source element - * @param thisArg - context - * @returns half-precision floating-point number array - * - * @example - * var arr = Float16Array.from( [ 1.0, 2.0 ] ); - * // returns - * - * var len = arr.length; - * // returns 2 - * - * @example - * function clbk( v ) { - * return v * 2.0; - * } - * - * var arr = Float16Array.from( [ 1.0, 2.0 ], clbk ); - * // returns - * - * var len = arr.length; - * // returns 2 - */ - from( src: ArrayLike | Iterable, clbk?: FromCallback, thisArg?: ThisParameterType> ): Float16Array; - - /** - * Creates a new half-precision floating-point number array from a variable number of arguments. - * - * @param elements - array elements - * @returns half-precision floating-point number array - * - * @example - * var arr = Float16Array.of( 1.0, 2.0, 3.0, 4.0 ); - * // returns - * - * var len = arr.length; - * // returns 4 - */ - of( ...elements: Array ): Float16Array; -} - -/** -* Half-precision floating-point number array constructor. -* -* @param arg - length, typed array, array-like object, or buffer -* @param byteOffset - byte offset (default: 0) -* @param length - view length -* @throws ArrayBuffer byte length must be a multiple of `2` -* @throws if provided only a single argument, must provide a valid argument -* @throws byte offset must be a nonnegative integer -* @throws byte offset must be a multiple of `2` -* @throws view length must be a positive multiple of `2` -* @throws must provide sufficient memory to accommodate byte offset and view length requirements -* @returns half-precision floating-point number array -* -* @example -* var arr = new Float16Array(); -* // returns -* -* var len = arr.length; -* // returns 0 -* -* @example -* var arr = new Float16Array( 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var arr = new Float16Array( [ 1.0, 2.0 ] ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float16Array( buf ); -* // returns -* -* var len = arr.length; -* // returns 8 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float16Array( buf, 8 ); -* // returns -* -* var len = arr.length; -* // returns 4 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = new Float16Array( buf, 8, 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -*/ -declare var ctor: Float16ArrayConstructor; - - -// EXPORTS // - -export = ctor; - -// eslint-doctest-alias: Float16Array diff --git a/index.mjs b/index.mjs deleted file mode 100644 index e1ce965..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-float16array-support@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.3-esm/index.mjs";import{isPrimitive as n}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.3-esm/index.mjs";import{primitives as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string-array@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.3-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.3-esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.3-esm/index.mjs";import{isPrimitive as h}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.3-esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.3-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-assert-is-nan@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.4-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.3-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@v0.2.4-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint16@v0.2.3-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-float16@v0.1.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float16-base-to-word@v0.1.1-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float16-base-from-word@v0.2.1-esm/index.mjs";import T from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-base-gcopy@v0.2.3-esm/index.mjs";function _(t){var r,n;for(r=[];!(n=t.next()).done;)r.push(b(m(n.value)));return r}var j=g.BYTES_PER_ELEMENT,x=r();function L(t){return"object"==typeof t&&null!==t&&"Float16Array"===t.constructor.name&&t.BYTES_PER_ELEMENT===j}function R(t){return t===P}function O(t,r){return function(){return t._get(r)}}function A(t,r){return function(n){t.set([n],r)}}function P(){var t,r,i,h,l,u;if(r=arguments.length,!(this instanceof P))return 0===r?new P:1===r?new P(arguments[0]):2===r?new P(arguments[0],arguments[1]):new P(arguments[0],arguments[1],arguments[2]);if(0===r)i=new g(0);else if(1===r)if(n(l=arguments[0]))i=new g(l);else if(e(l))L(l)?(i=new g(l.length),T.ndarray(l.length,new g(l.buffer,l.byteOffset,l.length),1,0,i,1,0)):i=function(t,r){var n,i;for(n=r.length,i=0;ii.byteLength-t)throw new RangeError(d("null2G",h*j));i=new g(i,t,h)}}for(y(this,"_buffer",i),y(this,"_length",i.length),u=0;u1){if(!s(i=arguments[1]))throw new TypeError(d("null2H",i));n>2&&(r=arguments[2])}if(e(t)){if(i){for(f=(o=new this(l=t.length))._buffer,u=0;u=this._length))return E(this._buffer[t])})),w(P.prototype,"buffer",(function(){return this._buffer.buffer})),w(P.prototype,"byteLength",(function(){return this._buffer.byteLength})),w(P.prototype,"byteOffset",(function(){return this._buffer.byteOffset})),y(P.prototype,"BYTES_PER_ELEMENT",P.BYTES_PER_ELEMENT),y(P.prototype,"copyWithin",(function(t,r){if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");return 2===arguments.length?this._buffer.copyWithin(t,r):this._buffer.copyWithin(t,r,arguments[2]),this})),y(P.prototype,"entries",(function(){var t,r,n,i,e,o;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");return t=this,i=this._buffer,n=this._length,o=-1,y(r={},"next",(function(){if(o+=1,e||o>=n)return{done:!0};return{value:[o,E(i[o])],done:!1}})),y(r,"return",(function(t){if(e=!0,arguments.length)return{value:t,done:!0};return{done:!0}})),p&&y(r,p,(function(){return t.entries()})),r})),y(P.prototype,"every",(function(t,r){var n,i;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!s(t))throw new TypeError(d("null3c",t));for(n=this._buffer,i=0;i1){if(!f(r))throw new TypeError(d("null7f",r));if(r<0&&(r+=e)<0&&(r=0),arguments.length>2){if(!f(n))throw new TypeError(d("null2z",n));n<0&&(n+=e)<0&&(n=0),n>e&&(n=e)}else n=e}else r=0,n=e;for(s=b(t),o=r;o=0;e--)if(i=E(n[e]),t.call(r,i,e,this))return i})),y(P.prototype,"findLastIndex",(function(t,r){var n,i,e;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!s(t))throw new TypeError(d("null3c",t));for(n=this._buffer,e=this._length-1;e>=0;e--)if(i=E(n[e]),t.call(r,i,e,this))return e;return-1})),y(P.prototype,"forEach",(function(t,r){var n,i;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!s(t))throw new TypeError(d("null3c",t));for(n=this._buffer,i=0;i=this._length))return E(this._buffer[t])})),y(P.prototype,"includes",(function(t,r){var n,i,e;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!h(t))throw new TypeError(d("null49",t));if(arguments.length>1){if(!f(r))throw new TypeError(d("null7f",r));r<0&&(r+=this._length)<0&&(r=0)}else r=0;for(n=this._buffer,e=b(t),i=r;i1){if(!f(r))throw new TypeError(d("null7f",r));r<0&&(r+=this._length)<0&&(r=0)}else r=0;for(n=this._buffer,e=b(t),i=r;i0){if(!l(t))throw new TypeError(d("null3F",t))}else t=",";for(r=this._buffer,n=[],i=0;i=n)return{done:!0};return{value:e,done:!1}})),y(r,"return",(function(t){if(i=!0,arguments.length)return{value:t,done:!0};return{done:!0}})),p&&y(r,p,(function(){return t.keys()})),r})),y(P.prototype,"lastIndexOf",(function(t,r){var n,i,e;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!h(t))throw new TypeError(d("null49",t));if(arguments.length>1){if(!f(r))throw new TypeError(d("null7f",r));r>=this._length?r=this._length-1:r<0&&(r+=this._length)}else r=this._length-1;for(n=this._buffer,e=b(t),i=r;i>=0;i--)if(e===n[i])return i;return-1})),w(P.prototype,"length",(function(){return this._length})),y(P.prototype,"map",(function(t,r){var n,i,e,o;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!s(t))throw new TypeError(d("null3c"),t);for(e=this._buffer,n=(i=new this.constructor(this._length))._buffer,o=0;o1)e=r,o=0;else{if(0===i)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");e=E(n[0]),o=1}for(;o1)e=r,o=i-1;else{if(0===i)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");e=E(n[i-1]),o=i-2}for(;o>=0;o--)e=t(e,E(n[o]),o,this);return e})),y(P.prototype,"reverse",(function(){var t,r,n,i,e,o;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");for(t=this._buffer,n=this._length,i=v(n/2),e=0;e1){if(!n(i=arguments[1]))throw new TypeError(d("null2L",i))}else i=0;if(i+(h=t.length)>this._length)throw new RangeError(d("null03"));if(L(t)?(r=t._buffer,f=!0):(r=t,f=!1),a=o.byteOffset+i*j,r.buffer===o.buffer&&r.byteOffseta){for(s=new g(r.length),l=0;ls&&(r=s)}}for(n=ti)return 1;return 0})),this;if(!s(t))throw new TypeError(d("null3c",t));return r.sort((function(r,n){return t(E(r),E(n))})),this})),y(P.prototype,"subarray",(function(t,r){var n,i,e;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(i=this._buffer,e=this._length,0===arguments.length)t=0,r=e;else{if(!f(t))throw new TypeError(d("null7e",t));if(t<0&&(t+=e)<0&&(t=0),1===arguments.length)r=e;else{if(!f(r))throw new TypeError(d("null7f",r));r<0?(r+=e)<0&&(r=0):r>e&&(r=e)}}return t>=e?(e=0,n=i.byteLength):t>=r?(e=0,n=i.byteOffset+t*j):(e=r-t,n=i.byteOffset+t*j),new this.constructor(i.buffer,n,e<0?0:e)})),y(P.prototype,"toLocaleString",(function(t,r){var n,e,o,s,f;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(0===arguments.length)e=[];else{if(!l(t)&&!i(t))throw new TypeError(d("invalid argument. First argument must be a string or an array of strings. Value: `%s`.",t));e=t}if(arguments.length<2)n={};else{if(!a(r))throw new TypeError(d("null2V",r));n=r}for(s=this._buffer,o=[],f=0;f=n)return{done:!0};return{value:E(e[o]),done:!1}})),y(t,"return",(function(t){if(i=!0,arguments.length)return{value:t,done:!0};return{done:!0}})),p&&y(t,p,(function(){return r.values()})),t})),y(P.prototype,"with",(function(t,r){var n,i;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!f(t))throw new TypeError(d("null7e",t));if(i=this._length,t<0&&(t+=i),t<0||t>=i)throw new RangeError(d("nullFP",t));if(!h(r))throw new TypeError(d("null4A",r));return(n=new this.constructor(this))[t]=r,n}));var S="function"==typeof Float16Array?Float16Array:void 0,F=t()?S:P;export{F as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 1b08c57..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/polyfill/from_iterator.js","../lib/polyfill/index.js","../lib/polyfill/from_array.js","../lib/polyfill/from_iterator_map.js","../lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport f16 from '@stdlib/number-float64-base-to-float16';\nimport toWord from '@stdlib/number-float16-base-to-word';\n\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @returns {Array} output array\n*/\nfunction fromIterator( it ) {\n\tvar out;\n\tvar v;\n\n\tout = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tout.push( toWord( f16( v.value ) ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIterator;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this, stdlib/jsdoc-typedef-typos, max-lines */\n\n'use strict';\n\n// MODULES //\n\nimport hasIteratorSymbolSupport from '@stdlib/assert-has-iterator-symbol-support';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport { primitives as isStringArray } from '@stdlib/assert-is-string-array';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isFunction from '@stdlib/assert-is-function';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isObject from '@stdlib/assert-is-object';\nimport isnan from '@stdlib/math-base-assert-is-nan';\nimport ITERATOR_SYMBOL from '@stdlib/symbol-iterator';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadWriteAccessor from '@stdlib/utils-define-read-write-accessor';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport Uint16Array from '@stdlib/array-uint16';\nimport f16 from '@stdlib/number-float64-base-to-float16';\nimport toWord from '@stdlib/number-float16-base-to-word';\nimport fromWord from '@stdlib/number-float16-base-from-word';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport fromArray from './from_array.js';\nimport fromIterator from './from_iterator.js';\nimport fromIteratorMap from './from_iterator_map.js';\n\n\n// VARIABLES //\n\nvar BYTES_PER_ELEMENT = Uint16Array.BYTES_PER_ELEMENT;\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\n\n\n// FUNCTIONS //\n\n/**\n* Returns a boolean indicating if a value is a `Float16Array`.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `Float16Array`\n*/\nfunction isFloat16Array( value ) {\n\treturn (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\tvalue.constructor.name === 'Float16Array' &&\n\t\tvalue.BYTES_PER_ELEMENT === BYTES_PER_ELEMENT\n\t);\n}\n\n/**\n* Returns a boolean indicating if a value is a floating-point typed array constructor.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a floating-point typed array constructor\n*/\nfunction isFloatingPointArrayConstructor( value ) { // eslint-disable-line id-length\n\treturn ( value === Float16Array );\n}\n\n/**\n* Returns a getter.\n*\n* @private\n* @param {Float16Array} ctx - typed array instance\n* @param {NonNegativeInteger} idx - element index\n* @returns {Function} getter\n*/\nfunction getter( ctx, idx ) {\n\treturn get;\n\n\t/**\n\t* Returns an array element.\n\t*\n\t* @private\n\t* @returns {(number|void)} array element\n\t*/\n\tfunction get() {\n\t\treturn ctx._get( idx ); // eslint-disable-line no-underscore-dangle\n\t}\n}\n\n/**\n* Returns a setter.\n*\n* @private\n* @param {Float16Array} ctx - typed array instance\n* @param {NonNegativeInteger} idx - element index\n* @returns {Function} setter\n*/\nfunction setter( ctx, idx ) {\n\treturn set;\n\n\t/**\n\t* Sets an array element.\n\t*\n\t* @private\n\t* @param {number} value - value to set\n\t*/\n\tfunction set( value ) {\n\t\tctx.set( [ value ], idx );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* 16-bit floating-point number array constructor.\n*\n* @constructor\n* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable\n* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n* @param {NonNegativeInteger} [length] - view length\n* @throws {RangeError} ArrayBuffer byte length must be a multiple of `2`\n* @throws {TypeError} if provided only a single argument, must provide a valid argument\n* @throws {TypeError} byte offset must be a nonnegative integer\n* @throws {RangeError} byte offset must be a multiple of `2`\n* @throws {TypeError} view length must be a positive multiple of `2`\n* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n* @returns {Float16Array} half-precision floating-point number array\n*\n* @example\n* var arr = new Float16Array();\n* // returns \n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var arr = new Float16Array( 5 );\n* // returns \n*\n* var len = arr.length;\n* // returns 5\n*\n* @example\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 5\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float16Array( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 8\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float16Array( buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 4\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Float16Array( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nfunction Float16Array() {\n\tvar byteOffset;\n\tvar nargs;\n\tvar buf;\n\tvar len;\n\tvar arg;\n\tvar i;\n\n\tnargs = arguments.length;\n\tif ( !(this instanceof Float16Array) ) {\n\t\tif ( nargs === 0 ) {\n\t\t\treturn new Float16Array();\n\t\t}\n\t\tif ( nargs === 1 ) {\n\t\t\treturn new Float16Array( arguments[0] );\n\t\t}\n\t\tif ( nargs === 2 ) {\n\t\t\treturn new Float16Array( arguments[0], arguments[1] );\n\t\t}\n\t\treturn new Float16Array( arguments[0], arguments[1], arguments[2] );\n\t}\n\t// Create the underlying data buffer...\n\tif ( nargs === 0 ) {\n\t\tbuf = new Uint16Array( 0 ); // backward-compatibility\n\t} else if ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\t\tif ( isNonNegativeInteger( arg ) ) {\n\t\t\tbuf = new Uint16Array( arg );\n\t\t} else if ( isCollection( arg ) ) {\n\t\t\tif ( isFloat16Array( arg ) ) {\n\t\t\t\tbuf = new Uint16Array( arg.length );\n\t\t\t\tgcopy.ndarray( arg.length, new Uint16Array( arg.buffer, arg.byteOffset, arg.length ), 1, 0, buf, 1, 0 ); // eslint-disable-line max-len\n\t\t\t} else {\n\t\t\t\tbuf = fromArray( new Uint16Array( arg.length ), arg );\n\t\t\t}\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tif ( !isInteger( arg.byteLength/BYTES_PER_ELEMENT ) ) {\n\t\t\t\tthrow new RangeError( format( 'nullE9', BYTES_PER_ELEMENT, arg.byteLength ) );\n\t\t\t}\n\t\t\tbuf = new Uint16Array( arg );\n\t\t} else if ( isObject( arg ) ) {\n\t\t\tif ( HAS_ITERATOR_SYMBOL === false ) {\n\t\t\t\tthrow new TypeError( format( 'null29', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2A', arg ) );\n\t\t\t}\n\t\t\tbuf = arg[ ITERATOR_SYMBOL ]();\n\t\t\tif ( !isFunction( buf.next ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2A', arg ) );\n\t\t\t}\n\t\t\tbuf = new Uint16Array( fromIterator( buf ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( 'null2A', arg ) );\n\t\t}\n\t} else {\n\t\tbuf = arguments[ 0 ];\n\t\tif ( !isArrayBuffer( buf ) ) {\n\t\t\tthrow new TypeError( format( 'null2B', buf ) );\n\t\t}\n\t\tbyteOffset = arguments[ 1 ];\n\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\tthrow new TypeError( format( 'null2C', byteOffset ) );\n\t\t}\n\t\tif ( !isInteger( byteOffset/BYTES_PER_ELEMENT ) ) {\n\t\t\tthrow new RangeError( format( 'nullEA', BYTES_PER_ELEMENT, byteOffset ) );\n\t\t}\n\t\tif ( nargs === 2 ) {\n\t\t\tlen = buf.byteLength - byteOffset;\n\t\t\tif ( !isInteger( len/BYTES_PER_ELEMENT ) ) {\n\t\t\t\tthrow new RangeError( format( 'null2E', BYTES_PER_ELEMENT, len ) );\n\t\t\t}\n\t\t\tbuf = new Uint16Array( buf, byteOffset );\n\t\t} else {\n\t\t\tlen = arguments[ 2 ];\n\t\t\tif ( !isNonNegativeInteger( len ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2F', len ) );\n\t\t\t}\n\t\t\tif ( (len*BYTES_PER_ELEMENT) > (buf.byteLength-byteOffset) ) {\n\t\t\t\tthrow new RangeError( format( 'null2G', len*BYTES_PER_ELEMENT ) );\n\t\t\t}\n\t\t\tbuf = new Uint16Array( buf, byteOffset, len );\n\t\t}\n\t}\n\tsetReadOnly( this, '_buffer', buf );\n\tsetReadOnly( this, '_length', buf.length );\n\tfor ( i = 0; i < buf.length; i++ ) {\n\t\tsetReadWriteAccessor( this, i, getter( this, i ), setter( this, i ) );\n\t}\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each array element.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Float16Array\n* @readonly\n* @type {PositiveInteger}\n* @default 2\n*\n* @example\n* var nbytes = Float16Array.BYTES_PER_ELEMENT;\n* // returns 2\n*/\nsetReadOnly( Float16Array, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT );\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof Float16Array\n* @readonly\n* @type {string}\n* @default 'Float16Array'\n*\n* @example\n* var str = Float16Array.name;\n* // returns 'Float16Array'\n*/\nsetReadOnly( Float16Array, 'name', 'Float16Array' );\n\n/**\n* Creates a new 16-bit floating-point number array from an array-like object or an iterable.\n*\n* @name from\n* @memberof Float16Array\n* @type {Function}\n* @param {(Collection|Iterable)} src - array-like object or iterable\n* @param {Function} [clbk] - callback to invoke for each source element\n* @param {*} [thisArg] - context\n* @throws {TypeError} `this` context must be a constructor\n* @throws {TypeError} `this` must be a floating-point array\n* @throws {TypeError} first argument must be an array-like object or an iterable\n* @throws {TypeError} second argument must be a function\n* @returns {Float16Array} half-precision floating-point number array\n*\n* @example\n* var arr = Float16Array.from( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* function clbk( v ) {\n* return v * 2.0;\n* }\n*\n* var arr = Float16Array.from( [ 1.0, 2.0 ], clbk );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nsetReadOnly( Float16Array, 'from', function from( src ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar clbk;\n\tvar out;\n\tvar buf;\n\tvar tmp;\n\tvar len;\n\tvar i;\n\tif ( !isFunction( this ) ) {\n\t\tthrow new TypeError( format('null01') );\n\t}\n\tif ( !isFloatingPointArrayConstructor( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs > 1 ) {\n\t\tclbk = arguments[ 1 ];\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'null2H', clbk ) );\n\t\t}\n\t\tif ( nargs > 2 ) {\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( isCollection( src ) ) {\n\t\tif ( clbk ) {\n\t\t\tlen = src.length;\n\t\t\tout = new this( len );\n\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tbuf[ i ] = toWord( f16( clbk.call( thisArg, src[ i ], i ) ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\treturn new this( src );\n\t}\n\tif ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) { // eslint-disable-line max-len\n\t\tbuf = src[ ITERATOR_SYMBOL ]();\n\t\tif ( !isFunction( buf.next ) ) {\n\t\t\tthrow new TypeError( format( 'null2J', src ) );\n\t\t}\n\t\tif ( clbk ) {\n\t\t\ttmp = fromIteratorMap( buf, clbk, thisArg );\n\t\t} else {\n\t\t\ttmp = fromIterator( buf );\n\t\t}\n\t\tif ( tmp instanceof Error ) {\n\t\t\tthrow tmp;\n\t\t}\n\t\tlen = tmp.length;\n\t\tout = new this( len );\n\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tbuf[ i ] = tmp[ i ];\n\t\t}\n\t\treturn out;\n\t}\n\tthrow new TypeError( format( 'null2J', src ) );\n});\n\n/**\n* Creates a new 16-bit floating-point number array from a variable number of arguments.\n*\n* @name of\n* @memberof Float16Array\n* @type {Function}\n* @param {...*} element - array elements\n* @throws {TypeError} `this` context must be a constructor\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Float16Array} half-precision floating-point number array\n*\n* @example\n* var arr = Float16Array.of( 1.0, 1.0, 1.0, 1.0 );\n* // returns \n*\n* var x = arr[ 0 ];\n* // returns 1.0\n*\n* var len = arr.length;\n* // returns 4\n*/\nsetReadOnly( Float16Array, 'of', function of() {\n\tvar args;\n\tvar i;\n\tif ( !isFunction( this ) ) {\n\t\tthrow new TypeError( format('null01') );\n\t}\n\tif ( !isFloatingPointArrayConstructor( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\targs = [];\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\targs.push( arguments[ i ] );\n\t}\n\treturn new this( args );\n});\n\n/**\n* Returns an array element with support for both nonnegative and negative integer indices.\n*\n* @name at\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} must provide an integer\n* @returns {(number|void)} array element\n*\n* @example\n* var arr = new Float16Array( [ 10.0, 20.0, 30.0 ] );\n*\n* var v = arr.at( 0 );\n* // returns 10.0\n*\n* v = arr.at( -1 );\n* // returns 30.0\n*\n* v = arr.at( 100 );\n* // returns undefined\n*/\nsetReadOnly( Float16Array.prototype, 'at', function at( idx ) {\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'null8A', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += this._length;\n\t}\n\tif ( idx < 0 || idx >= this._length ) {\n\t\treturn;\n\t}\n\treturn fromWord( this._buffer[ idx ] );\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name buffer\n* @memberof Float16Array.prototype\n* @readonly\n* @type {ArrayBuffer}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var buf = arr.buffer;\n* // returns \n*/\nsetReadOnlyAccessor( Float16Array.prototype, 'buffer', function get() {\n\treturn this._buffer.buffer;\n});\n\n/**\n* Size (in bytes) of the array.\n*\n* @name byteLength\n* @memberof Float16Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var byteLength = arr.byteLength;\n* // returns 20\n*/\nsetReadOnlyAccessor( Float16Array.prototype, 'byteLength', function get() {\n\treturn this._buffer.byteLength;\n});\n\n/**\n* Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`.\n*\n* @name byteOffset\n* @memberof Float16Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var byteOffset = arr.byteOffset;\n* // returns 0\n*/\nsetReadOnlyAccessor( Float16Array.prototype, 'byteOffset', function get() {\n\treturn this._buffer.byteOffset;\n});\n\n/**\n* Size (in bytes) of each array element.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Float16Array.prototype\n* @readonly\n* @type {PositiveInteger}\n* @default 2\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var nbytes = arr.BYTES_PER_ELEMENT;\n* // returns 2\n*/\nsetReadOnly( Float16Array.prototype, 'BYTES_PER_ELEMENT', Float16Array.BYTES_PER_ELEMENT );\n\n/**\n* Copies a sequence of elements within the array to the position starting at `target`.\n*\n* @name copyWithin\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} target - index at which to start copying elements\n* @param {integer} start - source index at which to copy elements from\n* @param {integer} [end] - source index at which to stop copying elements from\n* @throws {TypeError} `this` must be a floating-point array\n* @returns {Float16Array} modified array\n*\n* @example\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0 ] );\n*\n* // Copy the first two elements to the last two elements:\n* arr.copyWithin( 2, 0, 2 );\n*\n* var v = arr[ 2 ];\n* // returns 1.0\n*\n* v = arr[ 3 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'copyWithin', function copyWithin( target, start ) {\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\t// FIXME: prefer a functional `copyWithin` implementation which addresses lack of universal browser support (e.g., IE11 and Safari) or ensure that typed arrays are polyfilled\n\tif ( arguments.length === 2 ) {\n\t\tthis._buffer.copyWithin( target, start );\n\t} else {\n\t\tthis._buffer.copyWithin( target, start, arguments[2] );\n\t}\n\treturn this;\n});\n\n/**\n* Returns an iterator for iterating over array key-value pairs.\n*\n* @name entries\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] );\n*\n* var it = arr.entries();\n*\n* var v = it.next().value;\n* // returns [ 0, 1.0 ]\n*\n* v = it.next().value;\n* // returns [ 1, 2.0 ]\n*\n* v = it.next().value;\n* // returns [ 2, 3.0 ]\n*\n* var bool = it.next().done;\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'entries', function entries() {\n\tvar self;\n\tvar iter;\n\tvar len;\n\tvar buf;\n\tvar FLG;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tself = this;\n\tbuf = this._buffer;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': [ i, fromWord( buf[ i ] ) ],\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.entries();\n\t}\n});\n\n/**\n* Tests whether all elements in an array pass a test implemented by a predicate function.\n*\n* @name every\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {boolean} boolean indicating whether all elements pass a test\n*\n* @example\n* function predicate( v ) {\n* return v === 0.0;\n* }\n*\n* var arr = new Float16Array( 3 );\n*\n* var bool = arr.every( predicate );\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'every', function every( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( !predicate.call( thisArg, fromWord( buf[ i ] ), i, this ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n});\n\n/**\n* Returns a modified typed array filled with a fill value.\n*\n* @name fill\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {number} value - fill value\n* @param {integer} [start=0] - starting index (inclusive)\n* @param {integer} [end] - ending index (exclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a floating-point number\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be an integer\n* @returns {Float16Array} modified array\n*\n* @example\n* var arr = new Float16Array( 3 );\n*\n* arr.fill( 1.0, 1 );\n*\n* var v = arr[ 0 ];\n* // returns 0.0\n*\n* v = arr[ 1 ];\n* // returns 1.0\n*\n* v = arr[ 2 ];\n* // returns 1.0\n*/\nsetReadOnly( Float16Array.prototype, 'fill', function fill( value, start, end ) {\n\tvar buf;\n\tvar len;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNumber( value ) ) {\n\t\tthrow new TypeError( format( 'null49', value ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( start ) ) {\n\t\t\tthrow new TypeError( format( 'null7f', start ) );\n\t\t}\n\t\tif ( start < 0 ) {\n\t\t\tstart += len;\n\t\t\tif ( start < 0 ) {\n\t\t\t\tstart = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length > 2 ) {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2z', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t} else {\n\t\t\tend = len;\n\t\t}\n\t} else {\n\t\tstart = 0;\n\t\tend = len;\n\t}\n\tv = toWord( value );\n\tfor ( i = start; i < end; i++ ) {\n\t\tbuf[ i ] = v;\n\t}\n\treturn this;\n});\n\n/**\n* Returns a new array containing the elements of an array which pass a test implemented by a predicate function.\n*\n* @name filter\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {Float16Array} floating-point number array\n*\n* @example\n* function predicate( v ) {\n* return ( v === 0.0 );\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] );\n*\n* var out = arr.filter( predicate );\n* // returns \n*\n* var len = out.length;\n* // returns 2\n*\n* var v = out[ 0 ];\n* // returns 0.0\n*\n* v = out[ 1 ];\n* // returns 0.0\n*/\nsetReadOnly( Float16Array.prototype, 'filter', function filter( predicate, thisArg ) {\n\tvar buf;\n\tvar out;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\tout.push( v );\n\t\t}\n\t}\n\treturn new this.constructor( out );\n});\n\n/**\n* Returns the first element in an array for which a predicate function returns a truthy value.\n*\n* @name find\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {(boolean|void)} array element or undefined\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] );\n*\n* var v = arr.find( predicate );\n* // returns 1.0\n*/\nsetReadOnly( Float16Array.prototype, 'find', function find( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn v;\n\t\t}\n\t}\n});\n\n/**\n* Returns the index of the first element in an array for which a predicate function returns a truthy value.\n*\n* @name findIndex\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {integer} index or -1\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var v = arr.findIndex( predicate );\n* // returns 1\n*/\nsetReadOnly( Float16Array.prototype, 'findIndex', function findIndex( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Returns the last element in an array for which a predicate function returns a truthy value.\n*\n* @name findLast\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {(boolean|void)} array element or undefined\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] );\n*\n* var v = arr.findLast( predicate );\n* // returns 1.0\n*/\nsetReadOnly( Float16Array.prototype, 'findLast', function findLast( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = this._length-1; i >= 0; i-- ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn v;\n\t\t}\n\t}\n});\n\n/**\n* Returns the index of the last element in an array for which a predicate function returns a truthy value.\n*\n* @name findLastIndex\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {integer} index or -1\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] );\n*\n* var v = arr.findLastIndex( predicate );\n* // returns 1\n*/\nsetReadOnly( Float16Array.prototype, 'findLastIndex', function findLastIndex( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = this._length-1; i >= 0; i-- ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Invokes a function once for each array element.\n*\n* @name forEach\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} fcn - function to invoke\n* @param {*} [thisArg] - function invocation context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n*\n* @example\n* function log( v, i ) {\n* console.log( '%s: %s', i, v.toString() );\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* arr.forEach( log );\n*/\nsetReadOnly( Float16Array.prototype, 'forEach', function forEach( fcn, thisArg ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( fcn ) ) {\n\t\tthrow new TypeError( format( 'null3c', fcn ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tfcn.call( thisArg, fromWord( buf[ i ] ), i, this );\n\t}\n});\n\n/**\n* Returns an array element.\n*\n* @private\n* @name _get\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {NonNegativeInteger} idx - element index\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} must provide a nonnegative integer\n* @returns {(number|void)} array element\n*/\nsetReadOnly( Float16Array.prototype, '_get', function get( idx ) {\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNonNegativeInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'null2K', idx ) );\n\t}\n\tif ( idx >= this._length ) {\n\t\treturn;\n\t}\n\treturn fromWord( this._buffer[ idx ] );\n});\n\n/**\n* Returns a boolean indicating whether an array includes a provided value.\n*\n* @name includes\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {number} searchElement - search element\n* @param {integer} [fromIndex=0] - starting index (inclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a floating-point number\n* @throws {TypeError} second argument must be an integer\n* @returns {boolean} boolean indicating whether an array includes a value\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] );\n*\n* var bool = arr.includes( 1.0 );\n* // returns true\n*\n* bool = arr.includes( 1.0, 2 );\n* // returns false\n*\n* bool = arr.includes( 5.0 );\n* // returns false\n*/\nsetReadOnly( Float16Array.prototype, 'includes', function includes( searchElement, fromIndex ) {\n\tvar buf;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNumber( searchElement ) ) {\n\t\tthrow new TypeError( format( 'null49', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'null7f', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\tfromIndex = 0;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfromIndex = 0;\n\t}\n\tbuf = this._buffer;\n\tv = toWord( searchElement );\n\tfor ( i = fromIndex; i < this._length; i++ ) {\n\t\tif ( v === buf[ i ] ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n});\n\n/**\n* Returns the first index at which a given element can be found.\n*\n* @name indexOf\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {float16} searchElement - element to find\n* @param {integer} [fromIndex=0] - starting index (inclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a floating-point number\n* @throws {TypeError} second argument must be an integer\n* @returns {integer} index or -1\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] );\n*\n* var idx = arr.indexOf( 2.0 );\n* // returns 2\n*\n* idx = arr.indexOf( 2.0, 3 );\n* // returns -1\n*\n* idx = arr.indexOf( 3.0, 3 );\n* // returns 3\n*/\nsetReadOnly( Float16Array.prototype, 'indexOf', function indexOf( searchElement, fromIndex ) {\n\tvar buf;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNumber( searchElement ) ) {\n\t\tthrow new TypeError( format( 'null49', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'null7f', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\tfromIndex = 0;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfromIndex = 0;\n\t}\n\tbuf = this._buffer;\n\tv = toWord( searchElement );\n\tfor ( i = fromIndex; i < this._length; i++ ) {\n\t\tif ( v === buf[ i ] ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Returns a new string by concatenating all array elements.\n*\n* @name join\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {string} [separator=','] - element separator\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a string\n* @returns {string} string representation\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var str = arr.join();\n* // returns '0,1,2'\n*\n* str = arr.join( '|' );\n* // returns '0|1|2'\n*/\nsetReadOnly( Float16Array.prototype, 'join', function join( separator ) {\n\tvar buf;\n\tvar out;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( arguments.length > 0 ) {\n\t\tif ( !isString( separator ) ) {\n\t\t\tthrow new TypeError( format( 'null3F', separator ) );\n\t\t}\n\t} else {\n\t\tseparator = ',';\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( fromWord( buf[ i ] ) );\n\t}\n\treturn out.join( separator );\n});\n\n/**\n* Returns an iterator for iterating over each index key in a typed array.\n*\n* @name keys\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new Float16Array( [ 1.0, 2.0 ] );\n*\n* var iter = arr.keys();\n*\n* var v = iter.next().value;\n* // returns 0\n*\n* v = iter.next().value;\n* // returns 1\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'keys', function keys() {\n\tvar self;\n\tvar iter;\n\tvar len;\n\tvar FLG;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tself = this;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': i,\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.keys();\n\t}\n});\n\n/**\n* Returns the last index at which a given element can be found.\n*\n* @name lastIndexOf\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {number} searchElement - element to find\n* @param {integer} [fromIndex] - starting index (inclusive)\n* @throws {TypeError} `this` must be a floating-point number\n* @throws {TypeError} first argument must be a numeric value\n* @throws {TypeError} second argument must be an integer\n* @returns {integer} index or -1\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 2.0 ] );\n*\n* var idx = arr.lastIndexOf( 2.0 );\n* // returns 4\n*\n* idx = arr.lastIndexOf( 2.0, 3 );\n* // returns 2\n*\n* idx = arr.lastIndexOf( 4.0, 3 );\n* // returns -1\n*\n* idx = arr.lastIndexOf( 1.0, -3 );\n* // returns 1\n*/\nsetReadOnly( Float16Array.prototype, 'lastIndexOf', function lastIndexOf( searchElement, fromIndex ) {\n\tvar buf;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNumber( searchElement ) ) {\n\t\tthrow new TypeError( format( 'null49', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'null7f', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex >= this._length ) {\n\t\t\tfromIndex = this._length - 1;\n\t\t} else if ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t}\n\t} else {\n\t\tfromIndex = this._length - 1;\n\t}\n\tbuf = this._buffer;\n\tv = toWord( searchElement );\n\tfor ( i = fromIndex; i >= 0; i-- ) {\n\t\tif ( v === buf[ i ] ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Number of array elements.\n*\n* @name length\n* @memberof Float16Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var len = arr.length;\n* // returns 10\n*/\nsetReadOnlyAccessor( Float16Array.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Returns a new array with each element being the result of a provided callback function.\n*\n* @name map\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} fcn - callback function\n* @param {*} [thisArg] - callback function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {Float16Array} new floating-point number array\n*\n* @example\n* function scale( v ) {\n* return v * 2.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var out = arr.map( scale );\n* // returns \n*\n* var z = out[ 0 ];\n* // returns 0.0\n*\n* z = out[ 1 ];\n* // returns 2.0\n*\n* z = out[ 2 ];\n* // returns 4.0\n*/\nsetReadOnly( Float16Array.prototype, 'map', function map( fcn, thisArg ) {\n\tvar outbuf;\n\tvar out;\n\tvar buf;\n\tvar i;\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( fcn ) ) {\n\t\tthrow new TypeError( format('null3c'), fcn );\n\t}\n\tbuf = this._buffer;\n\tout = new this.constructor( this._length );\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\toutbuf[ i ] = toWord( fcn.call( thisArg, fromWord( buf[ i ] ), i, this ) ); // eslint-disable-line max-len\n\t}\n\treturn out;\n});\n\n/**\n* Applies a provided callback function to each element of the array, in order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion.\n*\n* @name reduce\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} reducer - callback function\n* @param {*} [initialValue] - initial value\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {Error} if not provided an initial value, the array must have at least one element\n* @returns {*} accumulated result\n*\n* @example\n* function add( acc, v ) {\n* return acc + v;\n* }\n*\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] );\n*\n* var out = arr.reduce( add, 0 );\n* // returns 6.0\n*/\nsetReadOnly( Float16Array.prototype, 'reduce', function reduce( reducer, initialValue ) {\n\tvar buf;\n\tvar len;\n\tvar acc;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( reducer ) ) {\n\t\tthrow new TypeError( format( 'null3c', reducer ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tacc = initialValue;\n\t\ti = 0;\n\t} else {\n\t\tif ( len === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' );\n\t\t}\n\t\tacc = fromWord( buf[ 0 ] );\n\t\ti = 1;\n\t}\n\tfor ( ; i < len; i++ ) {\n\t\tacc = reducer( acc, fromWord( buf[ i ] ), i, this );\n\t}\n\treturn acc;\n});\n\n/**\n* Applies a provided callback function to each element of the array, in reverse order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion.\n*\n* @name reduceRight\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} reducer - callback function\n* @param {*} [initialValue] - initial value\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {Error} if not provided an initial value, the array must have at least one element\n* @returns {*} accumulated result\n*\n* @example\n* function add( acc, v ) {\n* return acc + v;\n* }\n*\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] );\n*\n* var out = arr.reduceRight( add, 0 );\n* // returns 6.0\n*/\nsetReadOnly( Float16Array.prototype, 'reduceRight', function reduceRight( reducer, initialValue ) {\n\tvar buf;\n\tvar len;\n\tvar acc;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( reducer ) ) {\n\t\tthrow new TypeError( format( 'null3c', reducer ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tacc = initialValue;\n\t\ti = len - 1;\n\t} else {\n\t\tif ( len === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' );\n\t\t}\n\t\tacc = fromWord( buf[ len-1 ] );\n\t\ti = len - 2;\n\t}\n\tfor ( ; i >= 0; i-- ) {\n\t\tacc = reducer( acc, fromWord( buf[ i ] ), i, this );\n\t}\n\treturn acc;\n});\n\n/**\n* Reverses an array in-place.\n*\n* @name reverse\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Float16Array} reversed array\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var out = arr.reverse();\n* // returns \n*\n* var v = out[ 0 ];\n* // returns 2.0\n*\n* v = out[ 1 ];\n* // returns 1.0\n*\n* v = out[ 2 ];\n* // returns 0.0\n*/\nsetReadOnly( Float16Array.prototype, 'reverse', function reverse() {\n\tvar buf;\n\tvar tmp;\n\tvar len;\n\tvar N;\n\tvar i;\n\tvar j;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tN = floor( len / 2 );\n\tfor ( i = 0; i < N; i++ ) {\n\t\tj = len - i - 1;\n\t\ttmp = buf[ i ];\n\t\tbuf[ i ] = buf[ j ];\n\t\tbuf[ j ] = tmp;\n\t}\n\treturn this;\n});\n\n/**\n* Sets one or more array elements.\n*\n* ## Notes\n*\n* - When provided a typed array, we must check whether the source array shares the same buffer as the target array and whether the underlying memory overlaps. In particular, we are concerned with the following scenario:\n*\n* ```text\n* buf: ---------------------\n* src: ---------------------\n* ```\n*\n* In the above, as we copy values from `src`, we will overwrite values in the `src` view, resulting in duplicated values copied into the end of `buf`, which is not intended. Hence, to avoid overwriting source values, we must **copy** source values to a temporary array.\n*\n* In the other overlapping scenario,\n*\n* ```text\n* buf: ---------------------\n* src: ---------------------\n* ```\n*\n* by the time we begin copying into the overlapping region, we are copying from the end of `src`, a non-overlapping region, which means we don't run the risk of copying copied values, rather than the original `src` values, as intended.\n*\n* @name set\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {(Collection|Float16Array)} value - value(s)\n* @param {NonNegativeInteger} [i=0] - element index at which to start writing values\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a collection\n* @throws {TypeError} index argument must be a nonnegative integer\n* @throws {RangeError} index argument is out-of-bounds\n* @throws {RangeError} target array lacks sufficient storage to accommodate source values\n* @returns {void}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var v = arr[ 0 ];\n* // returns 0.0\n*\n* arr.set( [ 1.0, 2.0 ], 0 );\n*\n* v = arr[ 0 ];\n* // returns 1.0\n*/\nsetReadOnly( Float16Array.prototype, 'set', function set( value ) {\n\tvar sbuf;\n\tvar idx;\n\tvar buf;\n\tvar tmp;\n\tvar flg;\n\tvar N;\n\tvar i;\n\tvar j;\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isCollection( value ) ) {\n\t\tthrow new TypeError( format( 'null2O', value ) );\n\t}\n\tbuf = this._buffer;\n\tif ( arguments.length > 1 ) {\n\t\tidx = arguments[ 1 ];\n\t\tif ( !isNonNegativeInteger( idx ) ) {\n\t\t\tthrow new TypeError( format( 'null2L', idx ) );\n\t\t}\n\t} else {\n\t\tidx = 0;\n\t}\n\tN = value.length;\n\tif ( idx+N > this._length ) {\n\t\tthrow new RangeError( format('null03') );\n\t}\n\tif ( isFloat16Array( value ) ) {\n\t\tsbuf = value._buffer; // eslint-disable-line no-underscore-dangle\n\t\tflg = true;\n\t} else {\n\t\tsbuf = value;\n\t\tflg = false;\n\t}\n\t// Check for overlapping memory...\n\tj = buf.byteOffset + (idx*BYTES_PER_ELEMENT);\n\tif (\n\t\tsbuf.buffer === buf.buffer &&\n\t\t(\n\t\t\tsbuf.byteOffset < j &&\n\t\t\tsbuf.byteOffset+sbuf.byteLength > j\n\t\t)\n\t) {\n\t\t// We need to copy source values...\n\t\ttmp = new Uint16Array( sbuf.length );\n\t\tfor ( i = 0; i < sbuf.length; i++ ) {\n\t\t\ttmp[ i ] = sbuf[ i ];\n\t\t}\n\t\tsbuf = tmp;\n\t}\n\tif ( flg ) {\n\t\tfor ( i = 0; i < N; idx++, i++ ) {\n\t\t\tbuf[ idx ] = sbuf[ i ];\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < N; idx++, i++ ) {\n\t\t\tbuf[ idx ] = toWord( sbuf[ i ] );\n\t\t}\n\t}\n});\n\n/**\n* Copies a portion of a typed array to a new typed array.\n*\n* @name slice\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} [begin] - start index (inclusive)\n* @param {integer} [end] - end index (exclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be integer\n* @throws {TypeError} second argument must be integer\n* @returns {Float16Array} floating-point number array\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] );\n*\n* var out = arr.slice();\n* // returns \n*\n* var len = out.length;\n* // returns 5\n*\n* var v = out[ 0 ];\n* // returns 0.0\n*\n* v = out[ len-1 ];\n* // returns 4.0\n*\n* out = arr.slice( 1, -2 );\n* // returns \n*\n* len = out.length;\n* // returns 2\n*\n* v = out[ 0 ];\n* // returns 1.0\n*\n* v = out[ len-1 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'slice', function slice( begin, end ) {\n\tvar outlen;\n\tvar outbuf;\n\tvar out;\n\tvar buf;\n\tvar len;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length === 0 ) {\n\t\tbegin = 0;\n\t\tend = len;\n\t} else {\n\t\tif ( !isInteger( begin ) ) {\n\t\t\tthrow new TypeError( format( 'null7e', begin ) );\n\t\t}\n\t\tif ( begin < 0 ) {\n\t\t\tbegin += len;\n\t\t\tif ( begin < 0 ) {\n\t\t\t\tbegin = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\tend = len;\n\t\t} else {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'null7f', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t} else if ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t}\n\t}\n\tif ( begin < end ) {\n\t\toutlen = end - begin;\n\t} else {\n\t\toutlen = 0;\n\t}\n\tout = new this.constructor( outlen );\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < outlen; i++ ) {\n\t\toutbuf[ i ] = buf[ i+begin ];\n\t}\n\treturn out;\n});\n\n/**\n* Tests whether at least one element in an array passes a test implemented by a predicate function.\n*\n* @name some\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {boolean} boolean indicating whether at least one element passes a test\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var bool = arr.some( predicate );\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'some', function some( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( predicate.call( thisArg, fromWord( buf[ i ] ), i, this ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n});\n\n/**\n* Sorts an array in-place.\n*\n* @name sort\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} [compareFcn] - comparison function\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {Float16Array} sorted array\n*\n* @example\n* function compare( a, b ) {\n* if ( a < b ) {\n* return -1;\n* }\n* if ( a > b ) {\n* return 1;\n* }\n* return 0;\n* }\n*\n* var arr = new Float16Array( [ 1.0, 0.0, 2.0 ] );\n*\n* arr.sort( compare );\n*\n* var v = arr[ 0 ];\n* // returns 0.0\n*\n* v = arr[ 1 ];\n* // returns 1.0\n*\n* v = arr[ 2 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'sort', function sort( compareFcn ) {\n\tvar buf;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tif ( arguments.length === 0 ) {\n\t\tbuf.sort( defaultCompare );\n\t\treturn this;\n\t}\n\tif ( !isFunction( compareFcn ) ) {\n\t\tthrow new TypeError( format( 'null3c', compareFcn ) );\n\t}\n\tbuf.sort( compare );\n\treturn this;\n\n\t/**\n\t* Default comparison function for float16 values.\n\t*\n\t* @private\n\t* @param {unsigned16} a - unsigned 16-bit integer for comparison\n\t* @param {unsigned16} b - unsigned 16-bit integer for comparison\n\t* @returns {number} comparison result\n\t*/\n\tfunction defaultCompare( a, b ) { // eslint-disable-line stdlib/no-unnecessary-nested-functions\n\t\tvar x = fromWord( a );\n\t\tvar y = fromWord( b );\n\n\t\t// Handle NaN...\n\t\tif ( isnan( x ) && isnan( y ) ) {\n\t\t\treturn 0;\n\t\t}\n\t\tif ( isnan( x ) ) {\n\t\t\treturn 1;\n\t\t}\n\t\tif ( isnan( y ) ) {\n\t\t\treturn -1;\n\t\t}\n\t\t// Normal comparison\n\t\tif ( x < y ) {\n\t\t\treturn -1;\n\t\t}\n\t\tif ( x > y ) {\n\t\t\treturn 1;\n\t\t}\n\t\treturn 0;\n\t}\n\n\t/**\n\t* Comparison function wrapper.\n\t*\n\t* @private\n\t* @param {unsigned16} a - unsigned 16-bit integer for comparison\n\t* @param {unsigned16} b - unsigned 16-bit integer for comparison\n\t* @returns {number} comparison result\n\t*/\n\tfunction compare( a, b ) {\n\t\treturn compareFcn( fromWord( a ), fromWord( b ) );\n\t}\n});\n\n/**\n* Creates a new typed array view over the same underlying `ArrayBuffer` and with the same underlying data type as the host array.\n*\n* @name subarray\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} [begin] - start index (inclusive)\n* @param {integer} [end] - end index (exclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be an integer\n* @throws {TypeError} second argument must be an integer\n* @returns {Float16Array} subarray\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] );\n*\n* var subarr = arr.subarray();\n* // returns \n*\n* var len = subarr.length;\n* // returns 5\n*\n* var bool = subarr[ 0 ];\n* // returns 0.0\n*\n* bool = subarr[ len-1 ];\n* // returns 4.0\n*\n* subarr = arr.subarray( 1, -2 );\n* // returns \n*\n* len = subarr.length;\n* // returns 2\n*\n* bool = subarr[ 0 ];\n* // returns 1.0\n*\n* bool = subarr[ len-1 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'subarray', function subarray( begin, end ) {\n\tvar offset;\n\tvar buf;\n\tvar len;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length === 0 ) {\n\t\tbegin = 0;\n\t\tend = len;\n\t} else {\n\t\tif ( !isInteger( begin ) ) {\n\t\t\tthrow new TypeError( format( 'null7e', begin ) );\n\t\t}\n\t\tif ( begin < 0 ) {\n\t\t\tbegin += len;\n\t\t\tif ( begin < 0 ) {\n\t\t\t\tbegin = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\tend = len;\n\t\t} else {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'null7f', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t} else if ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t}\n\t}\n\tif ( begin >= len ) {\n\t\tlen = 0;\n\t\toffset = buf.byteLength;\n\t} else if ( begin >= end ) {\n\t\tlen = 0;\n\t\toffset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT );\n\t} else {\n\t\tlen = end - begin;\n\t\toffset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT );\n\t}\n\treturn new this.constructor( buf.buffer, offset, ( len < 0 ) ? 0 : len );\n});\n\n/**\n* Serializes an array as a locale-specific string.\n*\n* @name toLocaleString\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {(string|Array)} [locales] - locale identifier(s)\n* @param {Object} [options] - configuration options\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a string or an array of strings\n* @throws {TypeError} options argument must be an object\n* @returns {string} string representation\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var str = arr.toLocaleString();\n* // returns '0,1,2'\n*/\nsetReadOnly( Float16Array.prototype, 'toLocaleString', function toLocaleString( locales, options ) {\n\tvar opts;\n\tvar loc;\n\tvar out;\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( arguments.length === 0 ) {\n\t\tloc = [];\n\t} else if ( isString( locales ) || isStringArray( locales ) ) {\n\t\tloc = locales;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a string or an array of strings. Value: `%s`.', locales ) );\n\t}\n\tif ( arguments.length < 2 ) {\n\t\topts = {};\n\t} else if ( isObject( options ) ) {\n\t\topts = options;\n\t} else {\n\t\tthrow new TypeError( format( 'null2V', options ) );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( fromWord( buf[ i ] ) );\n\t}\n\treturn out.toLocaleString( loc, opts );\n});\n\n/**\n* Returns a new typed array containing the elements in reversed order.\n*\n* @name toReversed\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Float16Array} reversed array\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var out = arr.toReversed();\n* // returns \n*\n* var v = out[ 0 ];\n* // returns 2.0\n*\n* v = out[ 1 ];\n* // returns 1.0\n*\n* v = out[ 2 ];\n* // returns 0.0\n*/\nsetReadOnly( Float16Array.prototype, 'toReversed', function toReversed() {\n\tvar outbuf;\n\tvar out;\n\tvar len;\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tlen = this._length;\n\tout = new this.constructor( len );\n\tbuf = this._buffer;\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < len; i++ ) {\n\t\toutbuf[ i ] = buf[ len - i - 1 ];\n\t}\n\treturn out;\n});\n\n/**\n* Returns a new typed array containing the elements in sorted order.\n*\n* @name toSorted\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} [compareFcn] - comparison function\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {Float16Array} sorted array\n*\n* @example\n* function compare( a, b ) {\n* if ( a > b ) {\n* return 1;\n* }\n* if ( a < b ) {\n* return -1;\n* }\n* return 0;\n* }\n*\n* var arr = new Float16Array( [ 2.0, 0.0, 1.0 ] );\n*\n* var out = arr.toSorted( compare );\n* // returns \n*\n* var v = out[ 0 ];\n* // returns 0.0\n*\n* v = out[ 1 ];\n* // returns 1.0\n*\n* v = out[ 2 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'toSorted', function toSorted( compareFcn ) {\n\tvar out;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tout = new this.constructor( this );\n\tif ( arguments.length === 0 ) {\n\t\treturn out.sort();\n\t}\n\treturn out.sort( compareFcn );\n});\n\n/**\n* Serializes an array as a string.\n*\n* @name toString\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {string} string representation\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var str = arr.toString();\n* // returns '0,1,2'\n*/\nsetReadOnly( Float16Array.prototype, 'toString', function toString() {\n\tvar out;\n\tvar buf;\n\tvar i;\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( fromWord( buf[ i ] ) );\n\t}\n\treturn out.join( ',' );\n});\n\n/**\n* Returns an iterator for iterating over each value in a typed array.\n*\n* @name values\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0 ] );\n*\n* var iter = arr.values();\n*\n* var v = iter.next().value;\n* // returns 0.0\n*\n* v = iter.next().value;\n* // returns 1.0\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'values', function values() {\n\tvar iter;\n\tvar self;\n\tvar len;\n\tvar FLG;\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tself = this;\n\tbuf = this._buffer;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': fromWord( buf[ i ] ),\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.values();\n\t}\n});\n\n/**\n* Returns a new typed array with the element at a provided index replaced with a provided value.\n*\n* @name with\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} index - element index\n* @param {number} value - new value\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be an integer\n* @throws {RangeError} index argument is out-of-bounds\n* @throws {TypeError} second argument must be a floating-point number\n* @returns {Float16Array} new typed array\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var out = arr.with( 0, 3.0 );\n* // returns \n*\n* var v = out[ 0 ];\n* // returns 3.0\n*/\nsetReadOnly( Float16Array.prototype, 'with', function copyWith( index, value ) {\n\tvar out;\n\tvar len;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isInteger( index ) ) {\n\t\tthrow new TypeError( format( 'null7e', index ) );\n\t}\n\tlen = this._length;\n\tif ( index < 0 ) {\n\t\tindex += len;\n\t}\n\tif ( index < 0 || index >= len ) {\n\t\tthrow new RangeError( format( 'nullFP', index ) );\n\t}\n\tif ( !isNumber( value ) ) {\n\t\tthrow new TypeError( format( 'null4A', value ) );\n\t}\n\tout = new this.constructor( this );\n\tout[ index ] = value;\n\treturn out;\n});\n\n\n// EXPORTS //\n\nexport default Float16Array;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport f16 from '@stdlib/number-float64-base-to-float16';\nimport toWord from '@stdlib/number-float16-base-to-word';\n\n\n// MAIN //\n\n/**\n* Fills an output array with unsigned 16-bit integers corresponding to the IEEE 754 binary representation of respective half-precision floating-point numbers.\n*\n* @private\n* @param {Uint16Array} buf - output array\n* @param {Array} arr - input array\n* @returns {Uint16Array} output array\n*/\nfunction fromArray( buf, arr ) {\n\tvar len;\n\tvar i;\n\n\tlen = arr.length;\n\tfor ( i = 0; i < len; i++ ) {\n\t\tbuf[ i ] = toWord( f16( arr[ i ] ) );\n\t}\n\treturn buf;\n}\n\n\n// EXPORTS //\n\nexport default fromArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport f16 from '@stdlib/number-float64-base-to-float16';\nimport toWord from '@stdlib/number-float16-base-to-word';\n\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @param {Function} clbk - callback to invoke for each iterated value\n* @param {*} thisArg - invocation context\n* @returns {Array} output array\n*/\nfunction fromIteratorMap( it, clbk, thisArg ) {\n\tvar out;\n\tvar v;\n\tvar i;\n\n\tout = [];\n\ti = -1;\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\ti += 1;\n\t\tout.push( toWord( f16( clbk.call( thisArg, v.value, i ) ) ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIteratorMap;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Float16Array === 'function' ) ? Float16Array : void 0; // eslint-disable-line no-undef, stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* 16-bit floating-point number array constructor.\n*\n* @module @stdlib/array-float16\n*\n* @example\n* import Float16Array from '@stdlib/array-float16';\n*\n* var arr = new Float16Array();\n* // returns \n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* import Float16Array from '@stdlib/array-float16';\n*\n* var arr = new Float16Array( 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import Float16Array from '@stdlib/array-float16';\n*\n* var arr = new Float16Array( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n* import Float16Array from '@stdlib/array-float16';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float16Array( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 8\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n* import Float16Array from '@stdlib/array-float16';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float16Array( buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 4\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n* import Float16Array from '@stdlib/array-float16';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Float16Array( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\n\n// MODULES //\n\nimport hasFloat16ArraySupport from '@stdlib/assert-has-float16array-support';\nimport polyfill from './polyfill';\nimport builtin from './main.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasFloat16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n"],"names":["fromIterator","it","out","v","next","done","push","toWord","f16","value","BYTES_PER_ELEMENT","Uint16Array","HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","isFloat16Array","constructor","name","isFloatingPointArrayConstructor","Float16Array","getter","ctx","idx","_get","setter","set","byteOffset","nargs","buf","len","arg","i","arguments","length","this","isNonNegativeInteger","isCollection","gcopy","ndarray","buffer","arr","fromArray","isArrayBuffer","isInteger","byteLength","RangeError","format","isObject","TypeError","isFunction","ITERATOR_SYMBOL","setReadOnly","setReadWriteAccessor","src","thisArg","clbk","tmp","_buffer","call","fromIteratorMap","Error","args","prototype","_length","fromWord","setReadOnlyAccessor","target","start","copyWithin","self","iter","FLG","entries","predicate","end","isNumber","fcn","searchElement","fromIndex","separator","isString","join","keys","outbuf","reducer","initialValue","acc","N","j","floor","sbuf","flg","begin","outlen","compareFcn","sort","a","b","x","y","isnan","offset","locales","options","opts","loc","isStringArray","toLocaleString","values","index","ctor","ctor$1","hasFloat16ArraySupport","builtin","polyfill"],"mappings":"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"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index c9f26e2..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From beaffc787afd9b70df0d09834dcd2e4b7b01c025 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 2 Jun 2026 10:00:26 +0000 Subject: [PATCH 14/14] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 204 - .npmignore | 229 - .npmrc | 44 - CHANGELOG.md | 66 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 67 +- SECURITY.md | 5 - benchmark/benchmark.at.js | 79 - benchmark/benchmark.copy_within.js | 52 - benchmark/benchmark.copy_within.length.js | 95 - benchmark/benchmark.entries.js | 52 - benchmark/benchmark.every.js | 83 - benchmark/benchmark.every.length.js | 107 - benchmark/benchmark.fill.js | 53 - benchmark/benchmark.fill.length.js | 97 - benchmark/benchmark.filter.js | 82 - benchmark/benchmark.filter.length.js | 106 - benchmark/benchmark.find.js | 84 - benchmark/benchmark.find.length.js | 106 - benchmark/benchmark.find_index.js | 84 - benchmark/benchmark.find_index.length.js | 106 - benchmark/benchmark.find_last.js | 84 - benchmark/benchmark.find_last.length.js | 106 - benchmark/benchmark.find_last_index.js | 84 - benchmark/benchmark.find_last_index.length.js | 110 - benchmark/benchmark.for_each.js | 90 - benchmark/benchmark.for_each.length.js | 108 - benchmark/benchmark.from.js | 238 - benchmark/benchmark.get.js | 55 - benchmark/benchmark.includes.js | 54 - benchmark/benchmark.includes.length.js | 97 - benchmark/benchmark.index_of.js | 54 - benchmark/benchmark.index_of.length.js | 96 - benchmark/benchmark.join.js | 53 - benchmark/benchmark.join.length.js | 96 - benchmark/benchmark.js | 338 -- benchmark/benchmark.keys.js | 52 - benchmark/benchmark.keys.length.js | 96 - benchmark/benchmark.last_index_of.js | 53 - benchmark/benchmark.last_index_of.length.js | 95 - benchmark/benchmark.length.js | 93 - benchmark/benchmark.map.js | 82 - benchmark/benchmark.map.length.js | 106 - benchmark/benchmark.of.js | 48 - benchmark/benchmark.reduce.js | 82 - benchmark/benchmark.reduce.length.js | 107 - benchmark/benchmark.reduce_right.js | 82 - benchmark/benchmark.reduce_right.length.js | 107 - benchmark/benchmark.reverse.js | 53 - benchmark/benchmark.reverse.length.js | 96 - benchmark/benchmark.set.js | 95 - benchmark/benchmark.set.length.js | 110 - benchmark/benchmark.slice.js | 53 - benchmark/benchmark.slice.length.js | 96 - benchmark/benchmark.some.js | 83 - benchmark/benchmark.some.length.js | 107 - benchmark/benchmark.sort.js | 53 - benchmark/benchmark.sort.length.js | 96 - benchmark/benchmark.subarray.js | 52 - benchmark/benchmark.subarray.length.js | 95 - benchmark/benchmark.to_locale_string.js | 53 - .../benchmark.to_locale_string.length.js | 96 - benchmark/benchmark.to_reversed.js | 52 - benchmark/benchmark.to_reversed.length.js | 95 - benchmark/benchmark.to_sorted.js | 53 - benchmark/benchmark.to_sorted.length.js | 96 - benchmark/benchmark.to_string.js | 53 - benchmark/benchmark.to_string.length.js | 96 - benchmark/benchmark.values.js | 52 - benchmark/benchmark.values.length.js | 96 - benchmark/benchmark.with.js | 54 - benchmark/benchmark.with.length.js | 98 - benchmark/polyfill/benchmark.at.js | 79 - benchmark/polyfill/benchmark.copy_within.js | 52 - .../polyfill/benchmark.copy_within.length.js | 95 - benchmark/polyfill/benchmark.entries.js | 52 - benchmark/polyfill/benchmark.every.js | 83 - benchmark/polyfill/benchmark.every.length.js | 107 - benchmark/polyfill/benchmark.fill.js | 53 - benchmark/polyfill/benchmark.fill.length.js | 97 - benchmark/polyfill/benchmark.filter.js | 82 - benchmark/polyfill/benchmark.filter.length.js | 106 - benchmark/polyfill/benchmark.find.js | 84 - benchmark/polyfill/benchmark.find.length.js | 106 - benchmark/polyfill/benchmark.find_index.js | 84 - .../polyfill/benchmark.find_index.length.js | 106 - benchmark/polyfill/benchmark.find_last.js | 84 - .../polyfill/benchmark.find_last.length.js | 106 - .../polyfill/benchmark.find_last_index.js | 84 - .../benchmark.find_last_index.length.js | 110 - benchmark/polyfill/benchmark.for_each.js | 90 - .../polyfill/benchmark.for_each.length.js | 108 - benchmark/polyfill/benchmark.from.js | 238 - benchmark/polyfill/benchmark.get.js | 55 - benchmark/polyfill/benchmark.includes.js | 54 - .../polyfill/benchmark.includes.length.js | 97 - benchmark/polyfill/benchmark.index_of.js | 54 - .../polyfill/benchmark.index_of.length.js | 96 - benchmark/polyfill/benchmark.join.js | 53 - benchmark/polyfill/benchmark.join.length.js | 96 - benchmark/polyfill/benchmark.js | 338 -- benchmark/polyfill/benchmark.keys.js | 52 - benchmark/polyfill/benchmark.keys.length.js | 96 - benchmark/polyfill/benchmark.last_index_of.js | 53 - .../benchmark.last_index_of.length.js | 95 - benchmark/polyfill/benchmark.length.js | 93 - benchmark/polyfill/benchmark.map.js | 82 - benchmark/polyfill/benchmark.map.length.js | 106 - benchmark/polyfill/benchmark.of.js | 48 - benchmark/polyfill/benchmark.reduce.js | 82 - benchmark/polyfill/benchmark.reduce.length.js | 107 - benchmark/polyfill/benchmark.reduce_right.js | 82 - .../polyfill/benchmark.reduce_right.length.js | 107 - benchmark/polyfill/benchmark.reverse.js | 53 - .../polyfill/benchmark.reverse.length.js | 96 - benchmark/polyfill/benchmark.set.js | 95 - benchmark/polyfill/benchmark.set.length.js | 110 - benchmark/polyfill/benchmark.slice.js | 53 - benchmark/polyfill/benchmark.slice.length.js | 96 - benchmark/polyfill/benchmark.some.js | 83 - benchmark/polyfill/benchmark.some.length.js | 107 - benchmark/polyfill/benchmark.sort.js | 53 - benchmark/polyfill/benchmark.sort.length.js | 96 - benchmark/polyfill/benchmark.subarray.js | 52 - .../polyfill/benchmark.subarray.length.js | 95 - .../polyfill/benchmark.to_locale_string.js | 53 - .../benchmark.to_locale_string.length.js | 96 - benchmark/polyfill/benchmark.to_reversed.js | 52 - .../polyfill/benchmark.to_reversed.length.js | 95 - benchmark/polyfill/benchmark.to_sorted.js | 53 - .../polyfill/benchmark.to_sorted.length.js | 96 - benchmark/polyfill/benchmark.to_string.js | 53 - .../polyfill/benchmark.to_string.length.js | 96 - benchmark/polyfill/benchmark.values.js | 52 - benchmark/polyfill/benchmark.values.length.js | 96 - benchmark/polyfill/benchmark.with.js | 54 - benchmark/polyfill/benchmark.with.length.js | 98 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 19 - dist/index.js.map | 7 - docs/repl.txt | 1222 ----- docs/types/test.ts | 129 - examples/index.js | 42 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 106 - lib/main.js | 28 - lib/polyfill/from_array.js | 51 - lib/polyfill/from_iterator.js | 54 - lib/polyfill/from_iterator_map.js | 59 - lib/polyfill/index.js | 2410 -------- package.json | 86 +- stats.html | 4842 +++++++++++++++++ test/dist/test.js | 33 - test/polyfill/test.at.js | 144 - test/polyfill/test.copy_within.js | 281 - test/polyfill/test.entries.js | 238 - test/polyfill/test.every.js | 174 - test/polyfill/test.fill.js | 305 -- test/polyfill/test.filter.js | 226 - test/polyfill/test.find.js | 174 - test/polyfill/test.find_index.js | 173 - test/polyfill/test.find_last.js | 174 - test/polyfill/test.find_last_index.js | 173 - test/polyfill/test.for_each.js | 196 - test/polyfill/test.from.js | 654 --- test/polyfill/test.includes.js | 222 - test/polyfill/test.index_of.js | 222 - test/polyfill/test.join.js | 173 - test/polyfill/test.js | 740 --- test/polyfill/test.keys.js | 261 - test/polyfill/test.last_index_of.js | 211 - test/polyfill/test.map.js | 178 - test/polyfill/test.of.js | 130 - test/polyfill/test.reduce.js | 189 - test/polyfill/test.reduce_right.js | 192 - test/polyfill/test.reverse.js | 122 - test/polyfill/test.set.js | 259 - test/polyfill/test.slice.js | 311 -- test/polyfill/test.some.js | 196 - test/polyfill/test.sort.js | 189 - test/polyfill/test.subarray.js | 308 -- test/polyfill/test.to_locale_string.js | 187 - test/polyfill/test.to_reversed.js | 121 - test/polyfill/test.to_sorted.js | 172 - test/polyfill/test.to_string.js | 97 - test/polyfill/test.values.js | 264 - test/polyfill/test.with.js | 213 - test/test.at.js | 111 - test/test.copy_within.js | 279 - test/test.entries.js | 96 - test/test.every.js | 172 - test/test.fill.js | 212 - test/test.filter.js | 224 - test/test.find.js | 172 - test/test.find_index.js | 171 - test/test.find_last.js | 172 - test/test.find_last_index.js | 171 - test/test.for_each.js | 194 - test/test.from.js | 309 -- test/test.includes.js | 160 - test/test.index_of.js | 160 - test/test.join.js | 141 - test/test.js | 320 -- test/test.keys.js | 144 - test/test.last_index_of.js | 149 - test/test.map.js | 176 - test/test.of.js | 128 - test/test.polyfill.js | 80 - test/test.reduce.js | 187 - test/test.reduce_right.js | 190 - test/test.reverse.js | 120 - test/test.set.js | 225 - test/test.slice.js | 249 - test/test.some.js | 194 - test/test.sort.js | 186 - test/test.subarray.js | 246 - test/test.to_locale_string.js | 95 - test/test.to_reversed.js | 119 - test/test.to_sorted.js | 169 - test/test.to_string.js | 87 - test/test.values.js | 147 - test/test.with.js | 151 - 244 files changed, 4879 insertions(+), 33268 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.at.js delete mode 100644 benchmark/benchmark.copy_within.js delete mode 100644 benchmark/benchmark.copy_within.length.js delete mode 100644 benchmark/benchmark.entries.js delete mode 100644 benchmark/benchmark.every.js delete mode 100644 benchmark/benchmark.every.length.js delete mode 100644 benchmark/benchmark.fill.js delete mode 100644 benchmark/benchmark.fill.length.js delete mode 100644 benchmark/benchmark.filter.js delete mode 100644 benchmark/benchmark.filter.length.js delete mode 100644 benchmark/benchmark.find.js delete mode 100644 benchmark/benchmark.find.length.js delete mode 100644 benchmark/benchmark.find_index.js delete mode 100644 benchmark/benchmark.find_index.length.js delete mode 100644 benchmark/benchmark.find_last.js delete mode 100644 benchmark/benchmark.find_last.length.js delete mode 100644 benchmark/benchmark.find_last_index.js delete mode 100644 benchmark/benchmark.find_last_index.length.js delete mode 100644 benchmark/benchmark.for_each.js delete mode 100644 benchmark/benchmark.for_each.length.js delete mode 100644 benchmark/benchmark.from.js delete mode 100644 benchmark/benchmark.get.js delete mode 100644 benchmark/benchmark.includes.js delete mode 100644 benchmark/benchmark.includes.length.js delete mode 100644 benchmark/benchmark.index_of.js delete mode 100644 benchmark/benchmark.index_of.length.js delete mode 100644 benchmark/benchmark.join.js delete mode 100644 benchmark/benchmark.join.length.js delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.keys.js delete mode 100644 benchmark/benchmark.keys.length.js delete mode 100644 benchmark/benchmark.last_index_of.js delete mode 100644 benchmark/benchmark.last_index_of.length.js delete mode 100644 benchmark/benchmark.length.js delete mode 100644 benchmark/benchmark.map.js delete mode 100644 benchmark/benchmark.map.length.js delete mode 100644 benchmark/benchmark.of.js delete mode 100644 benchmark/benchmark.reduce.js delete mode 100644 benchmark/benchmark.reduce.length.js delete mode 100644 benchmark/benchmark.reduce_right.js delete mode 100644 benchmark/benchmark.reduce_right.length.js delete mode 100644 benchmark/benchmark.reverse.js delete mode 100644 benchmark/benchmark.reverse.length.js delete mode 100644 benchmark/benchmark.set.js delete mode 100644 benchmark/benchmark.set.length.js delete mode 100644 benchmark/benchmark.slice.js delete mode 100644 benchmark/benchmark.slice.length.js delete mode 100644 benchmark/benchmark.some.js delete mode 100644 benchmark/benchmark.some.length.js delete mode 100644 benchmark/benchmark.sort.js delete mode 100644 benchmark/benchmark.sort.length.js delete mode 100644 benchmark/benchmark.subarray.js delete mode 100644 benchmark/benchmark.subarray.length.js delete mode 100644 benchmark/benchmark.to_locale_string.js delete mode 100644 benchmark/benchmark.to_locale_string.length.js delete mode 100644 benchmark/benchmark.to_reversed.js delete mode 100644 benchmark/benchmark.to_reversed.length.js delete mode 100644 benchmark/benchmark.to_sorted.js delete mode 100644 benchmark/benchmark.to_sorted.length.js delete mode 100644 benchmark/benchmark.to_string.js delete mode 100644 benchmark/benchmark.to_string.length.js delete mode 100644 benchmark/benchmark.values.js delete mode 100644 benchmark/benchmark.values.length.js delete mode 100644 benchmark/benchmark.with.js delete mode 100644 benchmark/benchmark.with.length.js delete mode 100644 benchmark/polyfill/benchmark.at.js delete mode 100644 benchmark/polyfill/benchmark.copy_within.js delete mode 100644 benchmark/polyfill/benchmark.copy_within.length.js delete mode 100644 benchmark/polyfill/benchmark.entries.js delete mode 100644 benchmark/polyfill/benchmark.every.js delete mode 100644 benchmark/polyfill/benchmark.every.length.js delete mode 100644 benchmark/polyfill/benchmark.fill.js delete mode 100644 benchmark/polyfill/benchmark.fill.length.js delete mode 100644 benchmark/polyfill/benchmark.filter.js delete mode 100644 benchmark/polyfill/benchmark.filter.length.js delete mode 100644 benchmark/polyfill/benchmark.find.js delete mode 100644 benchmark/polyfill/benchmark.find.length.js delete mode 100644 benchmark/polyfill/benchmark.find_index.js delete mode 100644 benchmark/polyfill/benchmark.find_index.length.js delete mode 100644 benchmark/polyfill/benchmark.find_last.js delete mode 100644 benchmark/polyfill/benchmark.find_last.length.js delete mode 100644 benchmark/polyfill/benchmark.find_last_index.js delete mode 100644 benchmark/polyfill/benchmark.find_last_index.length.js delete mode 100644 benchmark/polyfill/benchmark.for_each.js delete mode 100644 benchmark/polyfill/benchmark.for_each.length.js delete mode 100644 benchmark/polyfill/benchmark.from.js delete mode 100644 benchmark/polyfill/benchmark.get.js delete mode 100644 benchmark/polyfill/benchmark.includes.js delete mode 100644 benchmark/polyfill/benchmark.includes.length.js delete mode 100644 benchmark/polyfill/benchmark.index_of.js delete mode 100644 benchmark/polyfill/benchmark.index_of.length.js delete mode 100644 benchmark/polyfill/benchmark.join.js delete mode 100644 benchmark/polyfill/benchmark.join.length.js delete mode 100644 benchmark/polyfill/benchmark.js delete mode 100644 benchmark/polyfill/benchmark.keys.js delete mode 100644 benchmark/polyfill/benchmark.keys.length.js delete mode 100644 benchmark/polyfill/benchmark.last_index_of.js delete mode 100644 benchmark/polyfill/benchmark.last_index_of.length.js delete mode 100644 benchmark/polyfill/benchmark.length.js delete mode 100644 benchmark/polyfill/benchmark.map.js delete mode 100644 benchmark/polyfill/benchmark.map.length.js delete mode 100644 benchmark/polyfill/benchmark.of.js delete mode 100644 benchmark/polyfill/benchmark.reduce.js delete mode 100644 benchmark/polyfill/benchmark.reduce.length.js delete mode 100644 benchmark/polyfill/benchmark.reduce_right.js delete mode 100644 benchmark/polyfill/benchmark.reduce_right.length.js delete mode 100644 benchmark/polyfill/benchmark.reverse.js delete mode 100644 benchmark/polyfill/benchmark.reverse.length.js delete mode 100644 benchmark/polyfill/benchmark.set.js delete mode 100644 benchmark/polyfill/benchmark.set.length.js delete mode 100644 benchmark/polyfill/benchmark.slice.js delete mode 100644 benchmark/polyfill/benchmark.slice.length.js delete mode 100644 benchmark/polyfill/benchmark.some.js delete mode 100644 benchmark/polyfill/benchmark.some.length.js delete mode 100644 benchmark/polyfill/benchmark.sort.js delete mode 100644 benchmark/polyfill/benchmark.sort.length.js delete mode 100644 benchmark/polyfill/benchmark.subarray.js delete mode 100644 benchmark/polyfill/benchmark.subarray.length.js delete mode 100644 benchmark/polyfill/benchmark.to_locale_string.js delete mode 100644 benchmark/polyfill/benchmark.to_locale_string.length.js delete mode 100644 benchmark/polyfill/benchmark.to_reversed.js delete mode 100644 benchmark/polyfill/benchmark.to_reversed.length.js delete mode 100644 benchmark/polyfill/benchmark.to_sorted.js delete mode 100644 benchmark/polyfill/benchmark.to_sorted.length.js delete mode 100644 benchmark/polyfill/benchmark.to_string.js delete mode 100644 benchmark/polyfill/benchmark.to_string.length.js delete mode 100644 benchmark/polyfill/benchmark.values.js delete mode 100644 benchmark/polyfill/benchmark.values.length.js delete mode 100644 benchmark/polyfill/benchmark.with.js delete mode 100644 benchmark/polyfill/benchmark.with.length.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/polyfill/from_array.js delete mode 100644 lib/polyfill/from_iterator.js delete mode 100644 lib/polyfill/from_iterator_map.js delete mode 100644 lib/polyfill/index.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/polyfill/test.at.js delete mode 100644 test/polyfill/test.copy_within.js delete mode 100644 test/polyfill/test.entries.js delete mode 100644 test/polyfill/test.every.js delete mode 100644 test/polyfill/test.fill.js delete mode 100644 test/polyfill/test.filter.js delete mode 100644 test/polyfill/test.find.js delete mode 100644 test/polyfill/test.find_index.js delete mode 100644 test/polyfill/test.find_last.js delete mode 100644 test/polyfill/test.find_last_index.js delete mode 100644 test/polyfill/test.for_each.js delete mode 100644 test/polyfill/test.from.js delete mode 100644 test/polyfill/test.includes.js delete mode 100644 test/polyfill/test.index_of.js delete mode 100644 test/polyfill/test.join.js delete mode 100644 test/polyfill/test.js delete mode 100644 test/polyfill/test.keys.js delete mode 100644 test/polyfill/test.last_index_of.js delete mode 100644 test/polyfill/test.map.js delete mode 100644 test/polyfill/test.of.js delete mode 100644 test/polyfill/test.reduce.js delete mode 100644 test/polyfill/test.reduce_right.js delete mode 100644 test/polyfill/test.reverse.js delete mode 100644 test/polyfill/test.set.js delete mode 100644 test/polyfill/test.slice.js delete mode 100644 test/polyfill/test.some.js delete mode 100644 test/polyfill/test.sort.js delete mode 100644 test/polyfill/test.subarray.js delete mode 100644 test/polyfill/test.to_locale_string.js delete mode 100644 test/polyfill/test.to_reversed.js delete mode 100644 test/polyfill/test.to_sorted.js delete mode 100644 test/polyfill/test.to_string.js delete mode 100644 test/polyfill/test.values.js delete mode 100644 test/polyfill/test.with.js delete mode 100644 test/test.at.js delete mode 100644 test/test.copy_within.js delete mode 100644 test/test.entries.js delete mode 100644 test/test.every.js delete mode 100644 test/test.fill.js delete mode 100644 test/test.filter.js delete mode 100644 test/test.find.js delete mode 100644 test/test.find_index.js delete mode 100644 test/test.find_last.js delete mode 100644 test/test.find_last_index.js delete mode 100644 test/test.for_each.js delete mode 100644 test/test.from.js delete mode 100644 test/test.includes.js delete mode 100644 test/test.index_of.js delete mode 100644 test/test.join.js delete mode 100644 test/test.js delete mode 100644 test/test.keys.js delete mode 100644 test/test.last_index_of.js delete mode 100644 test/test.map.js delete mode 100644 test/test.of.js delete mode 100644 test/test.polyfill.js delete mode 100644 test/test.reduce.js delete mode 100644 test/test.reduce_right.js delete mode 100644 test/test.reverse.js delete mode 100644 test/test.set.js delete mode 100644 test/test.slice.js delete mode 100644 test/test.some.js delete mode 100644 test/test.sort.js delete mode 100644 test/test.subarray.js delete mode 100644 test/test.to_locale_string.js delete mode 100644 test/test.to_reversed.js delete mode 100644 test/test.to_sorted.js delete mode 100644 test/test.to_string.js delete mode 100644 test/test.values.js delete mode 100644 test/test.with.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 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. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index f756a5e..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/float16) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 44e2d76..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/float16) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 2984901..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 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. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 4584730..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '9 21 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 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. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -1602,7 +1593,7 @@ logEach( '%s', out ); ## Notice -This package is part of [stdlib][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. +This package is part of [stdlib][stdlib], a standard library 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][stdlib], see the main project [repository][stdlib]. @@ -1667,29 +1658,29 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. [mdn-iterator-protocol]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterator_protocol -[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed +[@stdlib/array/typed]: https://github.com/stdlib-js/array-typed/tree/esm -[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer +[@stdlib/array/buffer]: https://github.com/stdlib-js/array-buffer/tree/esm -[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32 +[@stdlib/array/float32]: https://github.com/stdlib-js/array-float32/tree/esm -[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64 +[@stdlib/array/float64]: https://github.com/stdlib-js/array-float64/tree/esm -[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16 +[@stdlib/array/int16]: https://github.com/stdlib-js/array-int16/tree/esm -[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32 +[@stdlib/array/int32]: https://github.com/stdlib-js/array-int32/tree/esm -[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8 +[@stdlib/array/int8]: https://github.com/stdlib-js/array-int8/tree/esm -[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16 +[@stdlib/array/uint16]: https://github.com/stdlib-js/array-uint16/tree/esm -[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32 +[@stdlib/array/uint32]: https://github.com/stdlib-js/array-uint32/tree/esm -[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8 +[@stdlib/array/uint8]: https://github.com/stdlib-js/array-uint8/tree/esm -[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c +[@stdlib/array/uint8c]: https://github.com/stdlib-js/array-uint8c/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.at.js b/benchmark/benchmark.at.js deleted file mode 100644 index 7068020..0000000 --- a/benchmark/benchmark.at.js +++ /dev/null @@ -1,79 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s::nonnegative_indices:at', pkg ), function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float16Array( uniform( 10, 0.0, 10.0 ) ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.at( i%N ); - if ( typeof v !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNumber( v ) ) { - b.fail( 'should return a number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::negative_indices:at', pkg ), function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float16Array( uniform( 10, 1.0, 10.0 ) ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.at( -(i%N)-1 ); - if ( typeof v !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNumber( v ) ) { - b.fail( 'should return a number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.copy_within.js b/benchmark/benchmark.copy_within.js deleted file mode 100644 index 2182e0d..0000000 --- a/benchmark/benchmark.copy_within.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:copyWithin', pkg ), function benchmark( b ) { - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.copy_within.length.js b/benchmark/benchmark.copy_within.length.js deleted file mode 100644 index 9c952bb..0000000 --- a/benchmark/benchmark.copy_within.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - 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( format( '%s:copyWithin:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.entries.js b/benchmark/benchmark.entries.js deleted file mode 100644 index ddef73f..0000000 --- a/benchmark/benchmark.entries.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:entries', pkg ), function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.every.js b/benchmark/benchmark.every.js deleted file mode 100644 index ec830e9..0000000 --- a/benchmark/benchmark.every.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:every', pkg ), function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0.0; - } -}); - -bench( format( '%s::this_context:every', pkg ), function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0.0; - } -}); diff --git a/benchmark/benchmark.every.length.js b/benchmark/benchmark.every.length.js deleted file mode 100644 index a0f3d94..0000000 --- a/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,107 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - 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( format( '%s:every:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.fill.js b/benchmark/benchmark.fill.js deleted file mode 100644 index 7b27d39..0000000 --- a/benchmark/benchmark.fill.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:fill', pkg ), function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = [ 1.0, 2.0, 3.0 ]; - arr = new Float16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.fill( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.fill.length.js b/benchmark/benchmark.fill.length.js deleted file mode 100644 index 612d1b9..0000000 --- a/benchmark/benchmark.fill.length.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var values; - var out; - var i; - - values = [ 1.0, 2.0, 3.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.fill( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s:fill:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.filter.js b/benchmark/benchmark.filter.js deleted file mode 100644 index 555ad11..0000000 --- a/benchmark/benchmark.filter.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:filter', pkg ), function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0.0; - } -}); - -bench( format( '%s::this_context:filter', pkg ), function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0.0; - } -}); diff --git a/benchmark/benchmark.filter.length.js b/benchmark/benchmark.filter.length.js deleted file mode 100644 index 89f5124..0000000 --- a/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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 = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:filter:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.find.js b/benchmark/benchmark.find.js deleted file mode 100644 index b15c9fa..0000000 --- a/benchmark/benchmark.find.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:find', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); - -bench( format( '%s::this_context:find', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); diff --git a/benchmark/benchmark.find.length.js b/benchmark/benchmark.find.length.js deleted file mode 100644 index 58997d9..0000000 --- a/benchmark/benchmark.find.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value < 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - 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( format( '%s:find:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.find_index.js b/benchmark/benchmark.find_index.js deleted file mode 100644 index 4491bb3..0000000 --- a/benchmark/benchmark.find_index.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:findIndex', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); - -bench( format( '%s::this_context:findIndex', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); diff --git a/benchmark/benchmark.find_index.length.js b/benchmark/benchmark.find_index.length.js deleted file mode 100644 index 4bed308..0000000 --- a/benchmark/benchmark.find_index.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value < 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - 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( format( '%s:findIndex:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.find_last.js b/benchmark/benchmark.find_last.js deleted file mode 100644 index e134fbb..0000000 --- a/benchmark/benchmark.find_last.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:findLast', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findLast( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); - -bench( format( '%s::this_context:findLast', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findLast( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); diff --git a/benchmark/benchmark.find_last.length.js b/benchmark/benchmark.find_last.length.js deleted file mode 100644 index 50aad42..0000000 --- a/benchmark/benchmark.find_last.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value < 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.findLast( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - 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( format( '%s:findLast:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.find_last_index.js b/benchmark/benchmark.find_last_index.js deleted file mode 100644 index 85217bd..0000000 --- a/benchmark/benchmark.find_last_index.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:findLastIndex', pkg ), function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findLastIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -bench( format( '%s::this_context:findLastIndex', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findLastIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); diff --git a/benchmark/benchmark.find_last_index.length.js b/benchmark/benchmark.find_last_index.length.js deleted file mode 100644 index 69468cd..0000000 --- a/benchmark/benchmark.find_last_index.length.js +++ /dev/null @@ -1,110 +0,0 @@ -/** - * @license Apache-2.0 -* -* Copyright (c) 2026 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. -*/ - -/* eslint-disable stdlib/jsdoc-typedef-typos */ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {boolean} value - array element -* @param {NonNegativeInteger} idx - array element index -* @param {Float16Array} arr - array instance -* @returns {boolean} boolean indicating whether a value passes a test -*/ -function predicate( value ) { - return value < 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.findLastIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - 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( format( '%s:findLastIndex:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.for_each.js b/benchmark/benchmark.for_each.js deleted file mode 100644 index af73bce..0000000 --- a/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:forEach', pkg ), function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( format( '%s::this_context:forEach', pkg ), function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/benchmark/benchmark.for_each.length.js b/benchmark/benchmark.for_each.length.js deleted file mode 100644 index 935da80..0000000 --- a/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// 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( format( '%s:forEach:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.from.js b/benchmark/benchmark.from.js deleted file mode 100644 index 2242134..0000000 --- a/benchmark/benchmark.from.js +++ /dev/null @@ -1,238 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( format( '%s::typed_array:from', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::typed_array,clbk:from', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1.0; - } -}); - -bench( format( '%s::array:from', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1.0, 2.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::array,clbk:from', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1.0, 2.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1.0; - } -}); - -bench( format( '%s::iterable:from', pkg ), opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0.0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( format( '%s::iterable,clbk:from:', pkg ), opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1.0, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1.0; - } -}); diff --git a/benchmark/benchmark.get.js b/benchmark/benchmark.get.js deleted file mode 100644 index 90788e1..0000000 --- a/benchmark/benchmark.get.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:get', pkg ), function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float16Array( uniform( 10, 0.0, 10.0 ) ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( typeof v !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNumber( v ) ) { - b.fail( 'should return a number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.includes.js b/benchmark/benchmark.includes.js deleted file mode 100644 index c24dcc3..0000000 --- a/benchmark/benchmark.includes.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:includes', pkg ), function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Float16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1.0; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.includes.length.js b/benchmark/benchmark.includes.length.js deleted file mode 100644 index db686a1..0000000 --- a/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1.0; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - 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( format( '%s:includes:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.index_of.js b/benchmark/benchmark.index_of.js deleted file mode 100644 index 222370c..0000000 --- a/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:indexOf', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.indexOf( 11.0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( out ) ) { - b.fail( 'should return an integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.index_of.length.js b/benchmark/benchmark.index_of.length.js deleted file mode 100644 index ca2c5ee..0000000 --- a/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.indexOf( 11.0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( out ) ) { - b.fail( 'should return an integer' ); - } - 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( format( '%s:indexOf:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.join.js b/benchmark/benchmark.join.js deleted file mode 100644 index ce25730..0000000 --- a/benchmark/benchmark.join.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:join', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.join.length.js b/benchmark/benchmark.join.length.js deleted file mode 100644 index 26092d0..0000000 --- a/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - 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( format( '%s:join:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 1d756ec..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,338 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( format( '%s::instantiation,new', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array(); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::instantiation,no_new', pkg ), function benchmark( b ) { - var ctor; - var arr; - var i; - - ctor = Float16Array; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = ctor(); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::instantiation,length', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::instantiation,typed_array', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::instantiation,array', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = []; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::instantiation,iterable', pkg ), opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( createIterable() ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - return { - 'done': true - }; - } - } -}); - -bench( format( '%s::instantiation,arraybuffer', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::instantiation,arraybuffer,byte_offset', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 8 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( buf, 8 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::instantiation,arraybuffer,byte_offset,length', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 8 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( buf, 8, 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::get:buffer', pkg ), function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float16Array(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::get:byteLength', pkg ), function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float16Array(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::get:byteOffset', pkg ), function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float16Array(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::get:length', pkg ), function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float16Array(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.keys.js b/benchmark/benchmark.keys.js deleted file mode 100644 index 9bd4d5f..0000000 --- a/benchmark/benchmark.keys.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:keys', pkg ), function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.keys.length.js b/benchmark/benchmark.keys.length.js deleted file mode 100644 index a9b25c9..0000000 --- a/benchmark/benchmark.keys.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var iter; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isIteratorLike( iter ) ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - 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( format( '%s:keys:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.last_index_of.js b/benchmark/benchmark.last_index_of.js deleted file mode 100644 index 96d9d71..0000000 --- a/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:lastIndexOf', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.lastIndexOf( 11.0 ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.last_index_of.length.js b/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index 230c543..0000000 --- a/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.lastIndexOf( 11.0 ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - 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( format( '%s:lastIndexOf:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index c67eb26..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.map.js b/benchmark/benchmark.map.js deleted file mode 100644 index 7968e8c..0000000 --- a/benchmark/benchmark.map.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:map', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1.0; - } -}); - -bench( format( '%s::this_context:map', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1.0; - } -}); diff --git a/benchmark/benchmark.map.length.js b/benchmark/benchmark.map.length.js deleted file mode 100644 index 3948193..0000000 --- a/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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 = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:map:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.of.js b/benchmark/benchmark.of.js deleted file mode 100644 index 3b8ae26..0000000 --- a/benchmark/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:of', pkg ), function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.of( i, 2.0 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reduce.js b/benchmark/benchmark.reduce.js deleted file mode 100644 index 39ce31c..0000000 --- a/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:reduce', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1.0; - } -}); - -bench( format( '%s::initial_value:reduce', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3.14 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1.0; - } -}); diff --git a/benchmark/benchmark.reduce.length.js b/benchmark/benchmark.reduce.length.js deleted file mode 100644 index 763b4c2..0000000 --- a/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,107 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - 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( format( '%s:reduce:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.reduce_right.js b/benchmark/benchmark.reduce_right.js deleted file mode 100644 index 8a71b79..0000000 --- a/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:reduceRight', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1.0; - } -}); - -bench( format( '%s::initial_value:reduceRight', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3.14 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1.0; - } -}); diff --git a/benchmark/benchmark.reduce_right.length.js b/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index 2001fe5..0000000 --- a/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,107 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - 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( format( '%s:reduceRight:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.reverse.js b/benchmark/benchmark.reverse.js deleted file mode 100644 index a2a239c..0000000 --- a/benchmark/benchmark.reverse.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:reverse', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.reverse.length.js b/benchmark/benchmark.reverse.length.js deleted file mode 100644 index 3b526c7..0000000 --- a/benchmark/benchmark.reverse.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s:reverse:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.set.js b/benchmark/benchmark.set.js deleted file mode 100644 index 7648c39..0000000 --- a/benchmark/benchmark.set.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s::array:set', pkg ), function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Float16Array( 2 ); - buf = [ 0.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::typed_array:set', pkg ), function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Float16Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Float16Array( 2 ); - buf = new Float16Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.set.length.js b/benchmark/benchmark.set.length.js deleted file mode 100644 index f174a4a..0000000 --- a/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - - arr1 = uniform( len, 0.0, 10.0 ); - arr2 = uniform( len, 0.0, 10.0 ); - arr = new Float16Array( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - 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( format( '%s:set:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.slice.js b/benchmark/benchmark.slice.js deleted file mode 100644 index 9f5005a..0000000 --- a/benchmark/benchmark.slice.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:slice', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.slice.length.js b/benchmark/benchmark.slice.length.js deleted file mode 100644 index 2374b1b..0000000 --- a/benchmark/benchmark.slice.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s:slice:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.some.js b/benchmark/benchmark.some.js deleted file mode 100644 index 0c81afa..0000000 --- a/benchmark/benchmark.some.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:some', pkg ), function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); - -bench( format( '%s::this_context:some', pkg ), function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); diff --git a/benchmark/benchmark.some.length.js b/benchmark/benchmark.some.length.js deleted file mode 100644 index dd32df4..0000000 --- a/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,107 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value < 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - 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( format( '%s:some:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.sort.js b/benchmark/benchmark.sort.js deleted file mode 100644 index d9e6c30..0000000 --- a/benchmark/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:sort', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.sort.length.js b/benchmark/benchmark.sort.length.js deleted file mode 100644 index 508049c..0000000 --- a/benchmark/benchmark.sort.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ i%len ] = i; - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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 = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:sort:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.subarray.js b/benchmark/benchmark.subarray.js deleted file mode 100644 index 9d6a26b..0000000 --- a/benchmark/benchmark.subarray.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:subarray', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.subarray.length.js b/benchmark/benchmark.subarray.length.js deleted file mode 100644 index c40760b..0000000 --- a/benchmark/benchmark.subarray.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s:subarray:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_locale_string.js b/benchmark/benchmark.to_locale_string.js deleted file mode 100644 index 682ca77..0000000 --- a/benchmark/benchmark.to_locale_string.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:toLocaleString', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_locale_string.length.js b/benchmark/benchmark.to_locale_string.length.js deleted file mode 100644 index 20f510e..0000000 --- a/benchmark/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - 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 = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:toLocaleString:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_reversed.js b/benchmark/benchmark.to_reversed.js deleted file mode 100644 index 1b78c11..0000000 --- a/benchmark/benchmark.to_reversed.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:toReversed', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - 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 ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_reversed.length.js b/benchmark/benchmark.to_reversed.length.js deleted file mode 100644 index 66bf5dc..0000000 --- a/benchmark/benchmark.to_reversed.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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 ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s:toReversed:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_sorted.js b/benchmark/benchmark.to_sorted.js deleted file mode 100644 index d2021b5..0000000 --- a/benchmark/benchmark.to_sorted.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:toSorted', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toSorted(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_sorted.length.js b/benchmark/benchmark.to_sorted.length.js deleted file mode 100644 index b74ea43..0000000 --- a/benchmark/benchmark.to_sorted.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ i%len ] = i; - out = arr.toSorted(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a isFloat16Array' ); - } - 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( format( '%s:toSorted:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.to_string.js b/benchmark/benchmark.to_string.js deleted file mode 100644 index 6a31520..0000000 --- a/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:toString', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.to_string.length.js b/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 375cc12..0000000 --- a/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - 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 = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s:toString:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.values.js b/benchmark/benchmark.values.js deleted file mode 100644 index 4352d26..0000000 --- a/benchmark/benchmark.values.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:values', pkg ), function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.values.length.js b/benchmark/benchmark.values.length.js deleted file mode 100644 index e0ac1ed..0000000 --- a/benchmark/benchmark.values.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var iter; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isIteratorLike( iter ) ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - 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( format( '%s:values:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.with.js b/benchmark/benchmark.with.js deleted file mode 100644 index 0ca8231..0000000 --- a/benchmark/benchmark.with.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:with', pkg ), function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = uniform( 2, 0.0, 1.0 ); - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.with( i%arr.length, values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.with.length.js b/benchmark/benchmark.with.length.js deleted file mode 100644 index efdf808..0000000 --- a/benchmark/benchmark.with.length.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var values; - var out; - var i; - - values = uniform( 2, 0.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.with( i%len, values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s:with:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.at.js b/benchmark/polyfill/benchmark.at.js deleted file mode 100644 index f0b2b78..0000000 --- a/benchmark/polyfill/benchmark.at.js +++ /dev/null @@ -1,79 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill::nonnegative_indices:at', pkg ), function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float16Array( uniform( 10, 0.0, 10.0 ) ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.at( i%N ); - if ( typeof v !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNumber( v ) ) { - b.fail( 'should return a number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::negative_indices:at', pkg ), function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float16Array( uniform( 10, 1.0, 10.0 ) ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.at( -(i%N)-1 ); - if ( typeof v !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNumber( v ) ) { - b.fail( 'should return a number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.copy_within.js b/benchmark/polyfill/benchmark.copy_within.js deleted file mode 100644 index 867e40a..0000000 --- a/benchmark/polyfill/benchmark.copy_within.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:copyWithin', pkg ), function benchmark( b ) { - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.copy_within.length.js b/benchmark/polyfill/benchmark.copy_within.length.js deleted file mode 100644 index 86bd362..0000000 --- a/benchmark/polyfill/benchmark.copy_within.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - 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( format( '%s::polyfill:copyWithin:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.entries.js b/benchmark/polyfill/benchmark.entries.js deleted file mode 100644 index 013036c..0000000 --- a/benchmark/polyfill/benchmark.entries.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:entries', pkg ), function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.every.js b/benchmark/polyfill/benchmark.every.js deleted file mode 100644 index 2b505c5..0000000 --- a/benchmark/polyfill/benchmark.every.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:every', pkg ), function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0.0; - } -}); - -bench( format( '%s::polyfill::this_context:every', pkg ), function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0.0; - } -}); diff --git a/benchmark/polyfill/benchmark.every.length.js b/benchmark/polyfill/benchmark.every.length.js deleted file mode 100644 index df08cff..0000000 --- a/benchmark/polyfill/benchmark.every.length.js +++ /dev/null @@ -1,107 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - 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( format( '%s::polyfill:every:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.fill.js b/benchmark/polyfill/benchmark.fill.js deleted file mode 100644 index 0c6e740..0000000 --- a/benchmark/polyfill/benchmark.fill.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:fill', pkg ), function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = [ 1.0, 2.0, 3.0 ]; - arr = new Float16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.fill( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.fill.length.js b/benchmark/polyfill/benchmark.fill.length.js deleted file mode 100644 index 6e72c6a..0000000 --- a/benchmark/polyfill/benchmark.fill.length.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var values; - var out; - var i; - - values = [ 1.0, 2.0, 3.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.fill( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s::polyfill:fill:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.filter.js b/benchmark/polyfill/benchmark.filter.js deleted file mode 100644 index 328c3d1..0000000 --- a/benchmark/polyfill/benchmark.filter.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:filter', pkg ), function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0.0; - } -}); - -bench( format( '%s::polyfill::this_context:filter', pkg ), function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0.0; - } -}); diff --git a/benchmark/polyfill/benchmark.filter.length.js b/benchmark/polyfill/benchmark.filter.length.js deleted file mode 100644 index 8673396..0000000 --- a/benchmark/polyfill/benchmark.filter.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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 = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s::polyfill:filter:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.find.js b/benchmark/polyfill/benchmark.find.js deleted file mode 100644 index aef5da9..0000000 --- a/benchmark/polyfill/benchmark.find.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:find', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); - -bench( format( '%s::polyfill::this_context:find', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); diff --git a/benchmark/polyfill/benchmark.find.length.js b/benchmark/polyfill/benchmark.find.length.js deleted file mode 100644 index 0059567..0000000 --- a/benchmark/polyfill/benchmark.find.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value < 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - 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( format( '%s::polyfill:find:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.find_index.js b/benchmark/polyfill/benchmark.find_index.js deleted file mode 100644 index 183c1e4..0000000 --- a/benchmark/polyfill/benchmark.find_index.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:findIndex', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); - -bench( format( '%s::polyfill::this_context:findIndex', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); diff --git a/benchmark/polyfill/benchmark.find_index.length.js b/benchmark/polyfill/benchmark.find_index.length.js deleted file mode 100644 index c9d2887..0000000 --- a/benchmark/polyfill/benchmark.find_index.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value < 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - 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( format( '%s::polyfill:findIndex:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.find_last.js b/benchmark/polyfill/benchmark.find_last.js deleted file mode 100644 index 1d79bb8..0000000 --- a/benchmark/polyfill/benchmark.find_last.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:findLast', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findLast( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); - -bench( format( '%s::polyfill::this_context:findLast', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findLast( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); diff --git a/benchmark/polyfill/benchmark.find_last.length.js b/benchmark/polyfill/benchmark.find_last.length.js deleted file mode 100644 index 5abddac..0000000 --- a/benchmark/polyfill/benchmark.find_last.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value < 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.findLast( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - 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( format( '%s::polyfill:findLast:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.find_last_index.js b/benchmark/polyfill/benchmark.find_last_index.js deleted file mode 100644 index 9fc8543..0000000 --- a/benchmark/polyfill/benchmark.find_last_index.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:findLastIndex', pkg ), function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findLastIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -bench( format( '%s::polyfill::this_context:findLastIndex', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findLastIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); diff --git a/benchmark/polyfill/benchmark.find_last_index.length.js b/benchmark/polyfill/benchmark.find_last_index.length.js deleted file mode 100644 index cd49c40..0000000 --- a/benchmark/polyfill/benchmark.find_last_index.length.js +++ /dev/null @@ -1,110 +0,0 @@ -/** - * @license Apache-2.0 -* -* Copyright (c) 2026 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. -*/ - -/* eslint-disable stdlib/jsdoc-typedef-typos */ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {boolean} value - array element -* @param {NonNegativeInteger} idx - array element index -* @param {Float16Array} arr - array instance -* @returns {boolean} boolean indicating whether a value passes a test -*/ -function predicate( value ) { - return value < 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.findLastIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - 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( format( '%s::polyfill:findLastIndex:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.for_each.js b/benchmark/polyfill/benchmark.for_each.js deleted file mode 100644 index d16383b..0000000 --- a/benchmark/polyfill/benchmark.for_each.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:forEach', pkg ), function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( format( '%s::polyfill::this_context:forEach', pkg ), function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/benchmark/polyfill/benchmark.for_each.length.js b/benchmark/polyfill/benchmark.for_each.length.js deleted file mode 100644 index 5b4f977..0000000 --- a/benchmark/polyfill/benchmark.for_each.length.js +++ /dev/null @@ -1,108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// 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( format( '%s::polyfill:forEach:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.from.js b/benchmark/polyfill/benchmark.from.js deleted file mode 100644 index 8af766a..0000000 --- a/benchmark/polyfill/benchmark.from.js +++ /dev/null @@ -1,238 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( format( '%s::polyfill::typed_array:from', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::typed_array,clbk:from', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1.0; - } -}); - -bench( format( '%s::polyfill::array:from', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1.0, 2.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::array,clbk:from', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1.0, 2.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1.0; - } -}); - -bench( format( '%s::polyfill::iterable:from', pkg ), opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0.0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( format( '%s::polyfill::iterable,clbk:from:', pkg ), opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1.0, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1.0; - } -}); diff --git a/benchmark/polyfill/benchmark.get.js b/benchmark/polyfill/benchmark.get.js deleted file mode 100644 index 2bc111b..0000000 --- a/benchmark/polyfill/benchmark.get.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:get', pkg ), function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float16Array( uniform( 10, 0.0, 10.0 ) ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( typeof v !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNumber( v ) ) { - b.fail( 'should return a number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.includes.js b/benchmark/polyfill/benchmark.includes.js deleted file mode 100644 index 30fc8c4..0000000 --- a/benchmark/polyfill/benchmark.includes.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:includes', pkg ), function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Float16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1.0; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.includes.length.js b/benchmark/polyfill/benchmark.includes.length.js deleted file mode 100644 index 8ac1374..0000000 --- a/benchmark/polyfill/benchmark.includes.length.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1.0; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - 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( format( '%s::polyfill:includes:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.index_of.js b/benchmark/polyfill/benchmark.index_of.js deleted file mode 100644 index c11797c..0000000 --- a/benchmark/polyfill/benchmark.index_of.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:indexOf', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.indexOf( 11.0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( out ) ) { - b.fail( 'should return an integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.index_of.length.js b/benchmark/polyfill/benchmark.index_of.length.js deleted file mode 100644 index 96dfe78..0000000 --- a/benchmark/polyfill/benchmark.index_of.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.indexOf( 11.0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( out ) ) { - b.fail( 'should return an integer' ); - } - 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( format( '%s::polyfill:indexOf:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.join.js b/benchmark/polyfill/benchmark.join.js deleted file mode 100644 index d3d5a47..0000000 --- a/benchmark/polyfill/benchmark.join.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:join', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.join.length.js b/benchmark/polyfill/benchmark.join.length.js deleted file mode 100644 index ca50459..0000000 --- a/benchmark/polyfill/benchmark.join.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - 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( format( '%s::polyfill:join:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.js b/benchmark/polyfill/benchmark.js deleted file mode 100644 index 7c38bae..0000000 --- a/benchmark/polyfill/benchmark.js +++ /dev/null @@ -1,338 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( format( '%s::polyfill::instantiation,new', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array(); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::instantiation,no_new', pkg ), function benchmark( b ) { - var ctor; - var arr; - var i; - - ctor = Float16Array; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = ctor(); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::instantiation,length', pkg ), function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::instantiation,typed_array', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::instantiation,array', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = []; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::instantiation,iterable', pkg ), opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( createIterable() ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - return { - 'done': true - }; - } - } -}); - -bench( format( '%s::polyfill::instantiation,arraybuffer', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::instantiation,arraybuffer,byte_offset', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 8 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( buf, 8 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::instantiation,arraybuffer,byte_offset,length', pkg ), function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 8 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( buf, 8, 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float16Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::get:buffer', pkg ), function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float16Array(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::get:byteLength', pkg ), function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float16Array(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::get:byteOffset', pkg ), function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float16Array(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::get:length', pkg ), function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float16Array(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.keys.js b/benchmark/polyfill/benchmark.keys.js deleted file mode 100644 index b51d241..0000000 --- a/benchmark/polyfill/benchmark.keys.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:keys', pkg ), function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.keys.length.js b/benchmark/polyfill/benchmark.keys.length.js deleted file mode 100644 index c6ac13c..0000000 --- a/benchmark/polyfill/benchmark.keys.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var iter; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isIteratorLike( iter ) ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - 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( format( '%s::polyfill:keys:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.last_index_of.js b/benchmark/polyfill/benchmark.last_index_of.js deleted file mode 100644 index 950c98b..0000000 --- a/benchmark/polyfill/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:lastIndexOf', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.lastIndexOf( 11.0 ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.last_index_of.length.js b/benchmark/polyfill/benchmark.last_index_of.length.js deleted file mode 100644 index bf069bb..0000000 --- a/benchmark/polyfill/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.lastIndexOf( 11.0 ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - 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( format( '%s::polyfill:lastIndexOf:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.length.js b/benchmark/polyfill/benchmark.length.js deleted file mode 100644 index 488b91b..0000000 --- a/benchmark/polyfill/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float16Array( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s::polyfill:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.map.js b/benchmark/polyfill/benchmark.map.js deleted file mode 100644 index 810ce41..0000000 --- a/benchmark/polyfill/benchmark.map.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:map', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1.0; - } -}); - -bench( format( '%s::polyfill::this_context:map', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1.0; - } -}); diff --git a/benchmark/polyfill/benchmark.map.length.js b/benchmark/polyfill/benchmark.map.length.js deleted file mode 100644 index 6156472..0000000 --- a/benchmark/polyfill/benchmark.map.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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 = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s::polyfill:map:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.of.js b/benchmark/polyfill/benchmark.of.js deleted file mode 100644 index 165e244..0000000 --- a/benchmark/polyfill/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:of', pkg ), function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float16Array.of( i, 2.0 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( typeof arr !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.reduce.js b/benchmark/polyfill/benchmark.reduce.js deleted file mode 100644 index b8215bd..0000000 --- a/benchmark/polyfill/benchmark.reduce.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:reduce', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1.0; - } -}); - -bench( format( '%s::polyfill::initial_value:reduce', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3.14 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1.0; - } -}); diff --git a/benchmark/polyfill/benchmark.reduce.length.js b/benchmark/polyfill/benchmark.reduce.length.js deleted file mode 100644 index 6d74ccc..0000000 --- a/benchmark/polyfill/benchmark.reduce.length.js +++ /dev/null @@ -1,107 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - 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( format( '%s::polyfill:reduce:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.reduce_right.js b/benchmark/polyfill/benchmark.reduce_right.js deleted file mode 100644 index f2686f6..0000000 --- a/benchmark/polyfill/benchmark.reduce_right.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:reduceRight', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1.0; - } -}); - -bench( format( '%s::polyfill::initial_value:reduceRight', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3.14 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1.0; - } -}); diff --git a/benchmark/polyfill/benchmark.reduce_right.length.js b/benchmark/polyfill/benchmark.reduce_right.length.js deleted file mode 100644 index 62948e3..0000000 --- a/benchmark/polyfill/benchmark.reduce_right.length.js +++ /dev/null @@ -1,107 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - 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( format( '%s::polyfill:reduceRight:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.reverse.js b/benchmark/polyfill/benchmark.reverse.js deleted file mode 100644 index 386b361..0000000 --- a/benchmark/polyfill/benchmark.reverse.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:reverse', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.reverse.length.js b/benchmark/polyfill/benchmark.reverse.length.js deleted file mode 100644 index 5f051b7..0000000 --- a/benchmark/polyfill/benchmark.reverse.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s::polyfill:reverse:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.set.js b/benchmark/polyfill/benchmark.set.js deleted file mode 100644 index e2394cf..0000000 --- a/benchmark/polyfill/benchmark.set.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill::array:set', pkg ), function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Float16Array( 2 ); - buf = [ 0.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::polyfill::typed_array:set', pkg ), function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Float16Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Float16Array( 2 ); - buf = new Float16Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.set.length.js b/benchmark/polyfill/benchmark.set.length.js deleted file mode 100644 index 72a56e7..0000000 --- a/benchmark/polyfill/benchmark.set.length.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - - arr1 = uniform( len, 0.0, 10.0 ); - arr2 = uniform( len, 0.0, 10.0 ); - arr = new Float16Array( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - 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( format( '%s::polyfill:set:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.slice.js b/benchmark/polyfill/benchmark.slice.js deleted file mode 100644 index 8ee2df0..0000000 --- a/benchmark/polyfill/benchmark.slice.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:slice', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.slice.length.js b/benchmark/polyfill/benchmark.slice.length.js deleted file mode 100644 index 232cff3..0000000 --- a/benchmark/polyfill/benchmark.slice.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s::polyfill:slice:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.some.js b/benchmark/polyfill/benchmark.some.js deleted file mode 100644 index c987ef3..0000000 --- a/benchmark/polyfill/benchmark.some.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:some', pkg ), function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); - -bench( format( '%s::polyfill::this_context:some', pkg ), function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v < 0.0; - } -}); diff --git a/benchmark/polyfill/benchmark.some.length.js b/benchmark/polyfill/benchmark.some.length.js deleted file mode 100644 index fb689b5..0000000 --- a/benchmark/polyfill/benchmark.some.length.js +++ /dev/null @@ -1,107 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value < 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - 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( format( '%s::polyfill:some:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.sort.js b/benchmark/polyfill/benchmark.sort.js deleted file mode 100644 index 1ffaac3..0000000 --- a/benchmark/polyfill/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:sort', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.sort.length.js b/benchmark/polyfill/benchmark.sort.length.js deleted file mode 100644 index ec66cc2..0000000 --- a/benchmark/polyfill/benchmark.sort.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ i%len ] = i; - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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 = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s::polyfill:sort:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.subarray.js b/benchmark/polyfill/benchmark.subarray.js deleted file mode 100644 index b07f552..0000000 --- a/benchmark/polyfill/benchmark.subarray.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:subarray', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.subarray.length.js b/benchmark/polyfill/benchmark.subarray.length.js deleted file mode 100644 index 7313db0..0000000 --- a/benchmark/polyfill/benchmark.subarray.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s::polyfill:subarray:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.to_locale_string.js b/benchmark/polyfill/benchmark.to_locale_string.js deleted file mode 100644 index 7add18e..0000000 --- a/benchmark/polyfill/benchmark.to_locale_string.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:toLocaleString', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.to_locale_string.length.js b/benchmark/polyfill/benchmark.to_locale_string.length.js deleted file mode 100644 index 3f98d03..0000000 --- a/benchmark/polyfill/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - 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 = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s::polyfill:toLocaleString:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.to_reversed.js b/benchmark/polyfill/benchmark.to_reversed.js deleted file mode 100644 index ca7d6b5..0000000 --- a/benchmark/polyfill/benchmark.to_reversed.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:toReversed', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - 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 ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.to_reversed.length.js b/benchmark/polyfill/benchmark.to_reversed.length.js deleted file mode 100644 index e9fee39..0000000 --- a/benchmark/polyfill/benchmark.to_reversed.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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 ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s::polyfill:toReversed:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.to_sorted.js b/benchmark/polyfill/benchmark.to_sorted.js deleted file mode 100644 index 736fcf1..0000000 --- a/benchmark/polyfill/benchmark.to_sorted.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:toSorted', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toSorted(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.to_sorted.length.js b/benchmark/polyfill/benchmark.to_sorted.length.js deleted file mode 100644 index 32884b3..0000000 --- a/benchmark/polyfill/benchmark.to_sorted.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ i%len ] = i; - out = arr.toSorted(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a isFloat16Array' ); - } - 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( format( '%s::polyfill:toSorted:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.to_string.js b/benchmark/polyfill/benchmark.to_string.js deleted file mode 100644 index a2f7647..0000000 --- a/benchmark/polyfill/benchmark.to_string.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:toString', pkg ), function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.to_string.length.js b/benchmark/polyfill/benchmark.to_string.length.js deleted file mode 100644 index a772983..0000000 --- a/benchmark/polyfill/benchmark.to_string.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - 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++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - 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 = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( format( '%s::polyfill:toString:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.values.js b/benchmark/polyfill/benchmark.values.js deleted file mode 100644 index 59a4470..0000000 --- a/benchmark/polyfill/benchmark.values.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:values', pkg ), function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.values.length.js b/benchmark/polyfill/benchmark.values.length.js deleted file mode 100644 index f300b23..0000000 --- a/benchmark/polyfill/benchmark.values.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var iter; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isIteratorLike( iter ) ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - 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( format( '%s::polyfill:values:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/benchmark/polyfill/benchmark.with.js b/benchmark/polyfill/benchmark.with.js deleted file mode 100644 index 05edb05..0000000 --- a/benchmark/polyfill/benchmark.with.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// MAIN // - -bench( format( '%s::polyfill:with', pkg ), function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = uniform( 2, 0.0, 1.0 ); - arr = new Float16Array( uniform( 2, 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.with( i%arr.length, values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/polyfill/benchmark.with.length.js b/benchmark/polyfill/benchmark.with.length.js deleted file mode 100644 index cf76a7d..0000000 --- a/benchmark/polyfill/benchmark.with.length.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var uniform = require( '@stdlib/random-array-uniform' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../../package.json' ).name; -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float16Array( uniform( len, 0.0, 10.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var values; - var out; - var i; - - values = uniform( 2, 0.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.with( i%len, values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return a Float16Array' ); - } - 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( format( '%s::polyfill:with:len=%d', pkg, len ), f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 62eb7f0..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/float16" -%% click B href "https://github.com/stdlib-js/array-float16/tree/main" -%% click C href "https://github.com/stdlib-js/array-float16/tree/production" -%% click D href "https://github.com/stdlib-js/array-float16/tree/esm" -%% click E href "https://github.com/stdlib-js/array-float16/tree/deno" -%% click F href "https://github.com/stdlib-js/array-float16/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/float16 -[production-url]: https://github.com/stdlib-js/array-float16/tree/production -[deno-url]: https://github.com/stdlib-js/array-float16/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-float16/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-float16/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-float16/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-float16/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-float16/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 0b44231..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ctor from '../docs/types/index'; -export = ctor; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 8ef619b..0000000 --- a/dist/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict";var T=function(o,r){return function(){return r||o((r={exports:{}}).exports,r),r.exports}};var O=T(function(pr,R){"use strict";var D=require("@stdlib/number-float64-base-to-float16"),J=require("@stdlib/number-float16-base-to-word");function K(o,r){var t,i;for(t=r.length,i=0;it.byteLength-o)throw new RangeError(s("invalid arguments. ArrayBuffer has insufficient capacity. Either decrease the array length or provide a bigger buffer. Minimum capacity: `%u`.",i*w));t=new b(t,o,i)}}for(f(this,"_buffer",t),f(this,"_length",t.length),n=0;n1){if(e=arguments[1],!p(e))throw new TypeError(s("invalid argument. Second argument must be a function. Value: `%s`.",e));i>2&&(t=arguments[2])}if(S(r)){if(e){for(h=r.length,n=new this(h),a=n._buffer,y=0;y=this._length))return g(this._buffer[r])});F(u.prototype,"buffer",function(){return this._buffer.buffer});F(u.prototype,"byteLength",function(){return this._buffer.byteLength});F(u.prototype,"byteOffset",function(){return this._buffer.byteOffset});f(u.prototype,"BYTES_PER_ELEMENT",u.BYTES_PER_ELEMENT);f(u.prototype,"copyWithin",function(r,t){if(!v(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");return arguments.length===2?this._buffer.copyWithin(r,t):this._buffer.copyWithin(r,t,arguments[2]),this});f(u.prototype,"entries",function(){var r,t,i,e,n,a;if(!v(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");return r=this,e=this._buffer,i=this._length,a=-1,t={},f(t,"next",l),f(t,"return",h),c&&f(t,c,y),t;function l(){return a+=1,n||a>=i?{done:!0}:{value:[a,g(e[a])],done:!1}}function h(q){return n=!0,arguments.length?{value:q,done:!0}:{done:!0}}function y(){return r.entries()}});f(u.prototype,"every",function(r,t){var i,e;if(!v(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!p(r))throw new TypeError(s("invalid argument. First argument must be a function. Value: `%s`.",r));for(i=this._buffer,e=0;e1){if(!m(t))throw new TypeError(s("invalid argument. Second argument must be an integer. Value: `%s`.",t));if(t<0&&(t+=n,t<0&&(t=0)),arguments.length>2){if(!m(i))throw new TypeError(s("invalid argument. Third argument must be an integer. Value: `%s`.",i));i<0&&(i+=n,i<0&&(i=0)),i>n&&(i=n)}else i=n}else t=0,i=n;for(l=E(r),a=t;a=0;n--)if(e=g(i[n]),r.call(t,e,n,this))return e});f(u.prototype,"findLastIndex",function(r,t){var i,e,n;if(!v(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!p(r))throw new TypeError(s("invalid argument. First argument must be a function. Value: `%s`.",r));for(i=this._buffer,n=this._length-1;n>=0;n--)if(e=g(i[n]),r.call(t,e,n,this))return n;return-1});f(u.prototype,"forEach",function(r,t){var i,e;if(!v(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!p(r))throw new TypeError(s("invalid argument. First argument must be a function. Value: `%s`.",r));for(i=this._buffer,e=0;e=this._length))return g(this._buffer[r])});f(u.prototype,"includes",function(r,t){var i,e,n;if(!v(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!d(r))throw new TypeError(s("invalid argument. First argument must be a number. Value: `%s`.",r));if(arguments.length>1){if(!m(t))throw new TypeError(s("invalid argument. Second argument must be an integer. Value: `%s`.",t));t<0&&(t+=this._length,t<0&&(t=0))}else t=0;for(i=this._buffer,n=E(r),e=t;e1){if(!m(t))throw new TypeError(s("invalid argument. Second argument must be an integer. Value: `%s`.",t));t<0&&(t+=this._length,t<0&&(t=0))}else t=0;for(i=this._buffer,n=E(r),e=t;e0){if(!P(r))throw new TypeError(s("invalid argument. First argument must be a string. Value: `%s`.",r))}else r=",";for(t=this._buffer,i=[],e=0;e=i?{done:!0}:{value:n,done:!1}}function l(y){return e=!0,arguments.length?{value:y,done:!0}:{done:!0}}function h(){return r.keys()}});f(u.prototype,"lastIndexOf",function(r,t){var i,e,n;if(!v(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!d(r))throw new TypeError(s("invalid argument. First argument must be a number. Value: `%s`.",r));if(arguments.length>1){if(!m(t))throw new TypeError(s("invalid argument. Second argument must be an integer. Value: `%s`.",t));t>=this._length?t=this._length-1:t<0&&(t+=this._length)}else t=this._length-1;for(i=this._buffer,n=E(r),e=t;e>=0;e--)if(n===i[e])return e;return-1});F(u.prototype,"length",function(){return this._length});f(u.prototype,"map",function(r,t){var i,e,n,a;if(!v(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!p(r))throw new TypeError("invalid argument. First argument must be a function. Value: `%s`.",r);for(n=this._buffer,e=new this.constructor(this._length),i=e._buffer,a=0;a1)n=t,a=0;else{if(e===0)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");n=g(i[0]),a=1}for(;a1)n=t,a=e-1;else{if(e===0)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");n=g(i[e-1]),a=e-2}for(;a>=0;a--)n=r(n,g(i[a]),a,this);return n});f(u.prototype,"reverse",function(){var r,t,i,e,n,a;if(!v(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");for(r=this._buffer,i=this._length,e=ir(i/2),n=0;n1){if(i=arguments[1],!_(i))throw new TypeError(s("invalid argument. Index argument must be a nonnegative integer. Value: `%s`.",i))}else i=0;if(l=r.length,i+l>this._length)throw new RangeError("invalid arguments. Target array lacks sufficient storage to accommodate source values.");if(v(r)?(t=r._buffer,a=!0):(t=r,a=!1),y=e.byteOffset+i*w,t.buffer===e.buffer&&t.byteOffsety){for(n=new b(t.length),h=0;hl&&(t=l)}}for(rh?1:0}function e(n,a){return r(g(n),g(a))}});f(u.prototype,"subarray",function(r,t){var i,e,n;if(!v(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(e=this._buffer,n=this._length,arguments.length===0)r=0,t=n;else{if(!m(r))throw new TypeError(s("invalid argument. First argument must be an integer. Value: `%s`.",r));if(r<0&&(r+=n,r<0&&(r=0)),arguments.length===1)t=n;else{if(!m(t))throw new TypeError(s("invalid argument. Second argument must be an integer. Value: `%s`.",t));t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n)}}return r>=n?(n=0,i=e.byteLength):r>=t?(n=0,i=e.byteOffset+r*w):(n=t-r,i=e.byteOffset+r*w),new this.constructor(e.buffer,i,n<0?0:n)});f(u.prototype,"toLocaleString",function(r,t){var i,e,n,a,l;if(!v(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(arguments.length===0)e=[];else if(P(r)||tr(r))e=r;else throw new TypeError(s("invalid argument. First argument must be a string or an array of strings. Value: `%s`.",r));if(arguments.length<2)i={};else if(A(t))i=t;else throw new TypeError(s("invalid argument. Options argument must be an object. Value: `%s`.",t));for(a=this._buffer,n=[],l=0;l=i?{done:!0}:{value:g(n[a]),done:!1}}function h(q){return e=!0,arguments.length?{value:q,done:!0}:{done:!0}}function y(){return t.values()}});f(u.prototype,"with",function(r,t){var i,e;if(!v(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!m(r))throw new TypeError(s("invalid argument. First argument must be an integer. Value: `%s`.",r));if(e=this._length,r<0&&(r+=e),r<0||r>=e)throw new RangeError(s("invalid argument. Index argument is out-of-bounds. Value: `%s`.",r));if(!d(t))throw new TypeError(s("invalid argument. Second argument must be a number. Value: `%s`.",t));return i=new this.constructor(this),i[r]=t,i});G.exports=u});var z=T(function(cr,U){"use strict";var lr=typeof Float16Array=="function"?Float16Array:void 0;U.exports=lr});var hr=require("@stdlib/assert-has-float16array-support"),vr=H(),gr=z(),L;hr()?L=gr:L=vr;module.exports=L; -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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. -*/ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 00e84dc..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/polyfill/from_array.js", "../lib/polyfill/from_iterator.js", "../lib/polyfill/from_iterator_map.js", "../lib/polyfill/index.js", "../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar f16 = require( '@stdlib/number-float64-base-to-float16' );\nvar toWord = require( '@stdlib/number-float16-base-to-word' );\n\n\n// MAIN //\n\n/**\n* Fills an output array with unsigned 16-bit integers corresponding to the IEEE 754 binary representation of respective half-precision floating-point numbers.\n*\n* @private\n* @param {Uint16Array} buf - output array\n* @param {Array} arr - input array\n* @returns {Uint16Array} output array\n*/\nfunction fromArray( buf, arr ) {\n\tvar len;\n\tvar i;\n\n\tlen = arr.length;\n\tfor ( i = 0; i < len; i++ ) {\n\t\tbuf[ i ] = toWord( f16( arr[ i ] ) );\n\t}\n\treturn buf;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fromArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar f16 = require( '@stdlib/number-float64-base-to-float16' );\nvar toWord = require( '@stdlib/number-float16-base-to-word' );\n\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @returns {Array} output array\n*/\nfunction fromIterator( it ) {\n\tvar out;\n\tvar v;\n\n\tout = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tout.push( toWord( f16( v.value ) ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fromIterator;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar f16 = require( '@stdlib/number-float64-base-to-float16' );\nvar toWord = require( '@stdlib/number-float16-base-to-word' );\n\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @param {Function} clbk - callback to invoke for each iterated value\n* @param {*} thisArg - invocation context\n* @returns {Array} output array\n*/\nfunction fromIteratorMap( it, clbk, thisArg ) {\n\tvar out;\n\tvar v;\n\tvar i;\n\n\tout = [];\n\ti = -1;\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\ti += 1;\n\t\tout.push( toWord( f16( clbk.call( thisArg, v.value, i ) ) ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = fromIteratorMap;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this, stdlib/jsdoc-typedef-typos, max-lines */\n\n'use strict';\n\n// MODULES //\n\nvar hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' );\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar isStringArray = require( '@stdlib/assert-is-string-array' ).primitives;\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive;\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isObject = require( '@stdlib/assert-is-object' );\nvar isnan = require( '@stdlib/math-base-assert-is-nan' );\nvar ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' );\nvar setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' );\nvar floor = require( '@stdlib/math-base-special-floor' );\nvar format = require( '@stdlib/string-format' );\nvar Uint16Array = require( '@stdlib/array-uint16' );\nvar f16 = require( '@stdlib/number-float64-base-to-float16' );\nvar toWord = require( '@stdlib/number-float16-base-to-word' );\nvar fromWord = require( '@stdlib/number-float16-base-from-word' );\nvar gcopy = require( '@stdlib/blas-base-gcopy' );\nvar fromArray = require( './from_array.js' );\nvar fromIterator = require( './from_iterator.js' );\nvar fromIteratorMap = require( './from_iterator_map.js' );\n\n\n// VARIABLES //\n\nvar BYTES_PER_ELEMENT = Uint16Array.BYTES_PER_ELEMENT;\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\n\n\n// FUNCTIONS //\n\n/**\n* Returns a boolean indicating if a value is a `Float16Array`.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `Float16Array`\n*/\nfunction isFloat16Array( value ) {\n\treturn (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\tvalue.constructor.name === 'Float16Array' &&\n\t\tvalue.BYTES_PER_ELEMENT === BYTES_PER_ELEMENT\n\t);\n}\n\n/**\n* Returns a boolean indicating if a value is a floating-point typed array constructor.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a floating-point typed array constructor\n*/\nfunction isFloatingPointArrayConstructor( value ) { // eslint-disable-line id-length\n\treturn ( value === Float16Array );\n}\n\n/**\n* Returns a getter.\n*\n* @private\n* @param {Float16Array} ctx - typed array instance\n* @param {NonNegativeInteger} idx - element index\n* @returns {Function} getter\n*/\nfunction getter( ctx, idx ) {\n\treturn get;\n\n\t/**\n\t* Returns an array element.\n\t*\n\t* @private\n\t* @returns {(number|void)} array element\n\t*/\n\tfunction get() {\n\t\treturn ctx._get( idx ); // eslint-disable-line no-underscore-dangle\n\t}\n}\n\n/**\n* Returns a setter.\n*\n* @private\n* @param {Float16Array} ctx - typed array instance\n* @param {NonNegativeInteger} idx - element index\n* @returns {Function} setter\n*/\nfunction setter( ctx, idx ) {\n\treturn set;\n\n\t/**\n\t* Sets an array element.\n\t*\n\t* @private\n\t* @param {number} value - value to set\n\t*/\n\tfunction set( value ) {\n\t\tctx.set( [ value ], idx );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* 16-bit floating-point number array constructor.\n*\n* @constructor\n* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable\n* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n* @param {NonNegativeInteger} [length] - view length\n* @throws {RangeError} ArrayBuffer byte length must be a multiple of `2`\n* @throws {TypeError} if provided only a single argument, must provide a valid argument\n* @throws {TypeError} byte offset must be a nonnegative integer\n* @throws {RangeError} byte offset must be a multiple of `2`\n* @throws {TypeError} view length must be a positive multiple of `2`\n* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n* @returns {Float16Array} half-precision floating-point number array\n*\n* @example\n* var arr = new Float16Array();\n* // returns \n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var arr = new Float16Array( 5 );\n* // returns \n*\n* var len = arr.length;\n* // returns 5\n*\n* @example\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 5\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float16Array( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 8\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float16Array( buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 4\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Float16Array( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nfunction Float16Array() {\n\tvar byteOffset;\n\tvar nargs;\n\tvar buf;\n\tvar len;\n\tvar arg;\n\tvar i;\n\n\tnargs = arguments.length;\n\tif ( !(this instanceof Float16Array) ) {\n\t\tif ( nargs === 0 ) {\n\t\t\treturn new Float16Array();\n\t\t}\n\t\tif ( nargs === 1 ) {\n\t\t\treturn new Float16Array( arguments[0] );\n\t\t}\n\t\tif ( nargs === 2 ) {\n\t\t\treturn new Float16Array( arguments[0], arguments[1] );\n\t\t}\n\t\treturn new Float16Array( arguments[0], arguments[1], arguments[2] );\n\t}\n\t// Create the underlying data buffer...\n\tif ( nargs === 0 ) {\n\t\tbuf = new Uint16Array( 0 ); // backward-compatibility\n\t} else if ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\t\tif ( isNonNegativeInteger( arg ) ) {\n\t\t\tbuf = new Uint16Array( arg );\n\t\t} else if ( isCollection( arg ) ) {\n\t\t\tif ( isFloat16Array( arg ) ) {\n\t\t\t\tbuf = new Uint16Array( arg.length );\n\t\t\t\tgcopy.ndarray( arg.length, new Uint16Array( arg.buffer, arg.byteOffset, arg.length ), 1, 0, buf, 1, 0 ); // eslint-disable-line max-len\n\t\t\t} else {\n\t\t\t\tbuf = fromArray( new Uint16Array( arg.length ), arg );\n\t\t\t}\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tif ( !isInteger( arg.byteLength/BYTES_PER_ELEMENT ) ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer byte length must be a multiple of %u. Byte length: `%u`.', BYTES_PER_ELEMENT, arg.byteLength ) );\n\t\t\t}\n\t\t\tbuf = new Uint16Array( arg );\n\t\t} else if ( isObject( arg ) ) {\n\t\t\tif ( HAS_ITERATOR_SYMBOL === false ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, ArrayBuffer, typed array, or array-like object. Value: `%s`.', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t\t}\n\t\t\tbuf = arg[ ITERATOR_SYMBOL ]();\n\t\t\tif ( !isFunction( buf.next ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t\t}\n\t\t\tbuf = new Uint16Array( fromIterator( buf ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t}\n\t} else {\n\t\tbuf = arguments[ 0 ];\n\t\tif ( !isArrayBuffer( buf ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', buf ) );\n\t\t}\n\t\tbyteOffset = arguments[ 1 ];\n\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) );\n\t\t}\n\t\tif ( !isInteger( byteOffset/BYTES_PER_ELEMENT ) ) {\n\t\t\tthrow new RangeError( format( 'invalid argument. Byte offset must be a multiple of %u. Value: `%u`.', BYTES_PER_ELEMENT, byteOffset ) );\n\t\t}\n\t\tif ( nargs === 2 ) {\n\t\t\tlen = buf.byteLength - byteOffset;\n\t\t\tif ( !isInteger( len/BYTES_PER_ELEMENT ) ) {\n\t\t\t\tthrow new RangeError( format( 'invalid arguments. ArrayBuffer view byte length must be a multiple of %u. View byte length: `%u`.', BYTES_PER_ELEMENT, len ) );\n\t\t\t}\n\t\t\tbuf = new Uint16Array( buf, byteOffset );\n\t\t} else {\n\t\t\tlen = arguments[ 2 ];\n\t\t\tif ( !isNonNegativeInteger( len ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', len ) );\n\t\t\t}\n\t\t\tif ( (len*BYTES_PER_ELEMENT) > (buf.byteLength-byteOffset) ) {\n\t\t\t\tthrow new RangeError( format( 'invalid arguments. ArrayBuffer has insufficient capacity. Either decrease the array length or provide a bigger buffer. Minimum capacity: `%u`.', len*BYTES_PER_ELEMENT ) );\n\t\t\t}\n\t\t\tbuf = new Uint16Array( buf, byteOffset, len );\n\t\t}\n\t}\n\tsetReadOnly( this, '_buffer', buf );\n\tsetReadOnly( this, '_length', buf.length );\n\tfor ( i = 0; i < buf.length; i++ ) {\n\t\tsetReadWriteAccessor( this, i, getter( this, i ), setter( this, i ) );\n\t}\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each array element.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Float16Array\n* @readonly\n* @type {PositiveInteger}\n* @default 2\n*\n* @example\n* var nbytes = Float16Array.BYTES_PER_ELEMENT;\n* // returns 2\n*/\nsetReadOnly( Float16Array, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT );\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof Float16Array\n* @readonly\n* @type {string}\n* @default 'Float16Array'\n*\n* @example\n* var str = Float16Array.name;\n* // returns 'Float16Array'\n*/\nsetReadOnly( Float16Array, 'name', 'Float16Array' );\n\n/**\n* Creates a new 16-bit floating-point number array from an array-like object or an iterable.\n*\n* @name from\n* @memberof Float16Array\n* @type {Function}\n* @param {(Collection|Iterable)} src - array-like object or iterable\n* @param {Function} [clbk] - callback to invoke for each source element\n* @param {*} [thisArg] - context\n* @throws {TypeError} `this` context must be a constructor\n* @throws {TypeError} `this` must be a floating-point array\n* @throws {TypeError} first argument must be an array-like object or an iterable\n* @throws {TypeError} second argument must be a function\n* @returns {Float16Array} half-precision floating-point number array\n*\n* @example\n* var arr = Float16Array.from( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* function clbk( v ) {\n* return v * 2.0;\n* }\n*\n* var arr = Float16Array.from( [ 1.0, 2.0 ], clbk );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nsetReadOnly( Float16Array, 'from', function from( src ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar clbk;\n\tvar out;\n\tvar buf;\n\tvar tmp;\n\tvar len;\n\tvar i;\n\tif ( !isFunction( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` context must be a constructor.' );\n\t}\n\tif ( !isFloatingPointArrayConstructor( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs > 1 ) {\n\t\tclbk = arguments[ 1 ];\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t\tif ( nargs > 2 ) {\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( isCollection( src ) ) {\n\t\tif ( clbk ) {\n\t\t\tlen = src.length;\n\t\t\tout = new this( len );\n\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tbuf[ i ] = toWord( f16( clbk.call( thisArg, src[ i ], i ) ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\treturn new this( src );\n\t}\n\tif ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) { // eslint-disable-line max-len\n\t\tbuf = src[ ITERATOR_SYMBOL ]();\n\t\tif ( !isFunction( buf.next ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) );\n\t\t}\n\t\tif ( clbk ) {\n\t\t\ttmp = fromIteratorMap( buf, clbk, thisArg );\n\t\t} else {\n\t\t\ttmp = fromIterator( buf );\n\t\t}\n\t\tif ( tmp instanceof Error ) {\n\t\t\tthrow tmp;\n\t\t}\n\t\tlen = tmp.length;\n\t\tout = new this( len );\n\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tbuf[ i ] = tmp[ i ];\n\t\t}\n\t\treturn out;\n\t}\n\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) );\n});\n\n/**\n* Creates a new 16-bit floating-point number array from a variable number of arguments.\n*\n* @name of\n* @memberof Float16Array\n* @type {Function}\n* @param {...*} element - array elements\n* @throws {TypeError} `this` context must be a constructor\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Float16Array} half-precision floating-point number array\n*\n* @example\n* var arr = Float16Array.of( 1.0, 1.0, 1.0, 1.0 );\n* // returns \n*\n* var x = arr[ 0 ];\n* // returns 1.0\n*\n* var len = arr.length;\n* // returns 4\n*/\nsetReadOnly( Float16Array, 'of', function of() {\n\tvar args;\n\tvar i;\n\tif ( !isFunction( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` context must be a constructor.' );\n\t}\n\tif ( !isFloatingPointArrayConstructor( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\targs = [];\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\targs.push( arguments[ i ] );\n\t}\n\treturn new this( args );\n});\n\n/**\n* Returns an array element with support for both nonnegative and negative integer indices.\n*\n* @name at\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} must provide an integer\n* @returns {(number|void)} array element\n*\n* @example\n* var arr = new Float16Array( [ 10.0, 20.0, 30.0 ] );\n*\n* var v = arr.at( 0 );\n* // returns 10.0\n*\n* v = arr.at( -1 );\n* // returns 30.0\n*\n* v = arr.at( 100 );\n* // returns undefined\n*/\nsetReadOnly( Float16Array.prototype, 'at', function at( idx ) {\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += this._length;\n\t}\n\tif ( idx < 0 || idx >= this._length ) {\n\t\treturn;\n\t}\n\treturn fromWord( this._buffer[ idx ] );\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name buffer\n* @memberof Float16Array.prototype\n* @readonly\n* @type {ArrayBuffer}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var buf = arr.buffer;\n* // returns \n*/\nsetReadOnlyAccessor( Float16Array.prototype, 'buffer', function get() {\n\treturn this._buffer.buffer;\n});\n\n/**\n* Size (in bytes) of the array.\n*\n* @name byteLength\n* @memberof Float16Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var byteLength = arr.byteLength;\n* // returns 20\n*/\nsetReadOnlyAccessor( Float16Array.prototype, 'byteLength', function get() {\n\treturn this._buffer.byteLength;\n});\n\n/**\n* Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`.\n*\n* @name byteOffset\n* @memberof Float16Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var byteOffset = arr.byteOffset;\n* // returns 0\n*/\nsetReadOnlyAccessor( Float16Array.prototype, 'byteOffset', function get() {\n\treturn this._buffer.byteOffset;\n});\n\n/**\n* Size (in bytes) of each array element.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Float16Array.prototype\n* @readonly\n* @type {PositiveInteger}\n* @default 2\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var nbytes = arr.BYTES_PER_ELEMENT;\n* // returns 2\n*/\nsetReadOnly( Float16Array.prototype, 'BYTES_PER_ELEMENT', Float16Array.BYTES_PER_ELEMENT );\n\n/**\n* Copies a sequence of elements within the array to the position starting at `target`.\n*\n* @name copyWithin\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} target - index at which to start copying elements\n* @param {integer} start - source index at which to copy elements from\n* @param {integer} [end] - source index at which to stop copying elements from\n* @throws {TypeError} `this` must be a floating-point array\n* @returns {Float16Array} modified array\n*\n* @example\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0 ] );\n*\n* // Copy the first two elements to the last two elements:\n* arr.copyWithin( 2, 0, 2 );\n*\n* var v = arr[ 2 ];\n* // returns 1.0\n*\n* v = arr[ 3 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'copyWithin', function copyWithin( target, start ) {\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\t// FIXME: prefer a functional `copyWithin` implementation which addresses lack of universal browser support (e.g., IE11 and Safari) or ensure that typed arrays are polyfilled\n\tif ( arguments.length === 2 ) {\n\t\tthis._buffer.copyWithin( target, start );\n\t} else {\n\t\tthis._buffer.copyWithin( target, start, arguments[2] );\n\t}\n\treturn this;\n});\n\n/**\n* Returns an iterator for iterating over array key-value pairs.\n*\n* @name entries\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] );\n*\n* var it = arr.entries();\n*\n* var v = it.next().value;\n* // returns [ 0, 1.0 ]\n*\n* v = it.next().value;\n* // returns [ 1, 2.0 ]\n*\n* v = it.next().value;\n* // returns [ 2, 3.0 ]\n*\n* var bool = it.next().done;\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'entries', function entries() {\n\tvar self;\n\tvar iter;\n\tvar len;\n\tvar buf;\n\tvar FLG;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tself = this;\n\tbuf = this._buffer;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': [ i, fromWord( buf[ i ] ) ],\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.entries();\n\t}\n});\n\n/**\n* Tests whether all elements in an array pass a test implemented by a predicate function.\n*\n* @name every\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {boolean} boolean indicating whether all elements pass a test\n*\n* @example\n* function predicate( v ) {\n* return v === 0.0;\n* }\n*\n* var arr = new Float16Array( 3 );\n*\n* var bool = arr.every( predicate );\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'every', function every( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( !predicate.call( thisArg, fromWord( buf[ i ] ), i, this ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n});\n\n/**\n* Returns a modified typed array filled with a fill value.\n*\n* @name fill\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {number} value - fill value\n* @param {integer} [start=0] - starting index (inclusive)\n* @param {integer} [end] - ending index (exclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a floating-point number\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be an integer\n* @returns {Float16Array} modified array\n*\n* @example\n* var arr = new Float16Array( 3 );\n*\n* arr.fill( 1.0, 1 );\n*\n* var v = arr[ 0 ];\n* // returns 0.0\n*\n* v = arr[ 1 ];\n* // returns 1.0\n*\n* v = arr[ 2 ];\n* // returns 1.0\n*/\nsetReadOnly( Float16Array.prototype, 'fill', function fill( value, start, end ) {\n\tvar buf;\n\tvar len;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNumber( value ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a number. Value: `%s`.', value ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( start ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', start ) );\n\t\t}\n\t\tif ( start < 0 ) {\n\t\t\tstart += len;\n\t\t\tif ( start < 0 ) {\n\t\t\t\tstart = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length > 2 ) {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t} else {\n\t\t\tend = len;\n\t\t}\n\t} else {\n\t\tstart = 0;\n\t\tend = len;\n\t}\n\tv = toWord( value );\n\tfor ( i = start; i < end; i++ ) {\n\t\tbuf[ i ] = v;\n\t}\n\treturn this;\n});\n\n/**\n* Returns a new array containing the elements of an array which pass a test implemented by a predicate function.\n*\n* @name filter\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {Float16Array} floating-point number array\n*\n* @example\n* function predicate( v ) {\n* return ( v === 0.0 );\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] );\n*\n* var out = arr.filter( predicate );\n* // returns \n*\n* var len = out.length;\n* // returns 2\n*\n* var v = out[ 0 ];\n* // returns 0.0\n*\n* v = out[ 1 ];\n* // returns 0.0\n*/\nsetReadOnly( Float16Array.prototype, 'filter', function filter( predicate, thisArg ) {\n\tvar buf;\n\tvar out;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\tout.push( v );\n\t\t}\n\t}\n\treturn new this.constructor( out );\n});\n\n/**\n* Returns the first element in an array for which a predicate function returns a truthy value.\n*\n* @name find\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {(boolean|void)} array element or undefined\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] );\n*\n* var v = arr.find( predicate );\n* // returns 1.0\n*/\nsetReadOnly( Float16Array.prototype, 'find', function find( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn v;\n\t\t}\n\t}\n});\n\n/**\n* Returns the index of the first element in an array for which a predicate function returns a truthy value.\n*\n* @name findIndex\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {integer} index or -1\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var v = arr.findIndex( predicate );\n* // returns 1\n*/\nsetReadOnly( Float16Array.prototype, 'findIndex', function findIndex( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Returns the last element in an array for which a predicate function returns a truthy value.\n*\n* @name findLast\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {(boolean|void)} array element or undefined\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] );\n*\n* var v = arr.findLast( predicate );\n* // returns 1.0\n*/\nsetReadOnly( Float16Array.prototype, 'findLast', function findLast( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = this._length-1; i >= 0; i-- ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn v;\n\t\t}\n\t}\n});\n\n/**\n* Returns the index of the last element in an array for which a predicate function returns a truthy value.\n*\n* @name findLastIndex\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {integer} index or -1\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] );\n*\n* var v = arr.findLastIndex( predicate );\n* // returns 1\n*/\nsetReadOnly( Float16Array.prototype, 'findLastIndex', function findLastIndex( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = this._length-1; i >= 0; i-- ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Invokes a function once for each array element.\n*\n* @name forEach\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} fcn - function to invoke\n* @param {*} [thisArg] - function invocation context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n*\n* @example\n* function log( v, i ) {\n* console.log( '%s: %s', i, v.toString() );\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* arr.forEach( log );\n*/\nsetReadOnly( Float16Array.prototype, 'forEach', function forEach( fcn, thisArg ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( fcn ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tfcn.call( thisArg, fromWord( buf[ i ] ), i, this );\n\t}\n});\n\n/**\n* Returns an array element.\n*\n* @private\n* @name _get\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {NonNegativeInteger} idx - element index\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} must provide a nonnegative integer\n* @returns {(number|void)} array element\n*/\nsetReadOnly( Float16Array.prototype, '_get', function get( idx ) {\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNonNegativeInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a nonnegative integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx >= this._length ) {\n\t\treturn;\n\t}\n\treturn fromWord( this._buffer[ idx ] );\n});\n\n/**\n* Returns a boolean indicating whether an array includes a provided value.\n*\n* @name includes\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {number} searchElement - search element\n* @param {integer} [fromIndex=0] - starting index (inclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a floating-point number\n* @throws {TypeError} second argument must be an integer\n* @returns {boolean} boolean indicating whether an array includes a value\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] );\n*\n* var bool = arr.includes( 1.0 );\n* // returns true\n*\n* bool = arr.includes( 1.0, 2 );\n* // returns false\n*\n* bool = arr.includes( 5.0 );\n* // returns false\n*/\nsetReadOnly( Float16Array.prototype, 'includes', function includes( searchElement, fromIndex ) {\n\tvar buf;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNumber( searchElement ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a number. Value: `%s`.', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\tfromIndex = 0;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfromIndex = 0;\n\t}\n\tbuf = this._buffer;\n\tv = toWord( searchElement );\n\tfor ( i = fromIndex; i < this._length; i++ ) {\n\t\tif ( v === buf[ i ] ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n});\n\n/**\n* Returns the first index at which a given element can be found.\n*\n* @name indexOf\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {float16} searchElement - element to find\n* @param {integer} [fromIndex=0] - starting index (inclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a floating-point number\n* @throws {TypeError} second argument must be an integer\n* @returns {integer} index or -1\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] );\n*\n* var idx = arr.indexOf( 2.0 );\n* // returns 2\n*\n* idx = arr.indexOf( 2.0, 3 );\n* // returns -1\n*\n* idx = arr.indexOf( 3.0, 3 );\n* // returns 3\n*/\nsetReadOnly( Float16Array.prototype, 'indexOf', function indexOf( searchElement, fromIndex ) {\n\tvar buf;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNumber( searchElement ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a number. Value: `%s`.', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\tfromIndex = 0;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfromIndex = 0;\n\t}\n\tbuf = this._buffer;\n\tv = toWord( searchElement );\n\tfor ( i = fromIndex; i < this._length; i++ ) {\n\t\tif ( v === buf[ i ] ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Returns a new string by concatenating all array elements.\n*\n* @name join\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {string} [separator=','] - element separator\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a string\n* @returns {string} string representation\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var str = arr.join();\n* // returns '0,1,2'\n*\n* str = arr.join( '|' );\n* // returns '0|1|2'\n*/\nsetReadOnly( Float16Array.prototype, 'join', function join( separator ) {\n\tvar buf;\n\tvar out;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( arguments.length > 0 ) {\n\t\tif ( !isString( separator ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', separator ) );\n\t\t}\n\t} else {\n\t\tseparator = ',';\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( fromWord( buf[ i ] ) );\n\t}\n\treturn out.join( separator );\n});\n\n/**\n* Returns an iterator for iterating over each index key in a typed array.\n*\n* @name keys\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new Float16Array( [ 1.0, 2.0 ] );\n*\n* var iter = arr.keys();\n*\n* var v = iter.next().value;\n* // returns 0\n*\n* v = iter.next().value;\n* // returns 1\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'keys', function keys() {\n\tvar self;\n\tvar iter;\n\tvar len;\n\tvar FLG;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tself = this;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': i,\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.keys();\n\t}\n});\n\n/**\n* Returns the last index at which a given element can be found.\n*\n* @name lastIndexOf\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {number} searchElement - element to find\n* @param {integer} [fromIndex] - starting index (inclusive)\n* @throws {TypeError} `this` must be a floating-point number\n* @throws {TypeError} first argument must be a numeric value\n* @throws {TypeError} second argument must be an integer\n* @returns {integer} index or -1\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 2.0 ] );\n*\n* var idx = arr.lastIndexOf( 2.0 );\n* // returns 4\n*\n* idx = arr.lastIndexOf( 2.0, 3 );\n* // returns 2\n*\n* idx = arr.lastIndexOf( 4.0, 3 );\n* // returns -1\n*\n* idx = arr.lastIndexOf( 1.0, -3 );\n* // returns 1\n*/\nsetReadOnly( Float16Array.prototype, 'lastIndexOf', function lastIndexOf( searchElement, fromIndex ) {\n\tvar buf;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNumber( searchElement ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a number. Value: `%s`.', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex >= this._length ) {\n\t\t\tfromIndex = this._length - 1;\n\t\t} else if ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t}\n\t} else {\n\t\tfromIndex = this._length - 1;\n\t}\n\tbuf = this._buffer;\n\tv = toWord( searchElement );\n\tfor ( i = fromIndex; i >= 0; i-- ) {\n\t\tif ( v === buf[ i ] ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Number of array elements.\n*\n* @name length\n* @memberof Float16Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var len = arr.length;\n* // returns 10\n*/\nsetReadOnlyAccessor( Float16Array.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Returns a new array with each element being the result of a provided callback function.\n*\n* @name map\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} fcn - callback function\n* @param {*} [thisArg] - callback function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {Float16Array} new floating-point number array\n*\n* @example\n* function scale( v ) {\n* return v * 2.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var out = arr.map( scale );\n* // returns \n*\n* var z = out[ 0 ];\n* // returns 0.0\n*\n* z = out[ 1 ];\n* // returns 2.0\n*\n* z = out[ 2 ];\n* // returns 4.0\n*/\nsetReadOnly( Float16Array.prototype, 'map', function map( fcn, thisArg ) {\n\tvar outbuf;\n\tvar out;\n\tvar buf;\n\tvar i;\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( fcn ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be a function. Value: `%s`.', fcn );\n\t}\n\tbuf = this._buffer;\n\tout = new this.constructor( this._length );\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\toutbuf[ i ] = toWord( fcn.call( thisArg, fromWord( buf[ i ] ), i, this ) ); // eslint-disable-line max-len\n\t}\n\treturn out;\n});\n\n/**\n* Applies a provided callback function to each element of the array, in order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion.\n*\n* @name reduce\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} reducer - callback function\n* @param {*} [initialValue] - initial value\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {Error} if not provided an initial value, the array must have at least one element\n* @returns {*} accumulated result\n*\n* @example\n* function add( acc, v ) {\n* return acc + v;\n* }\n*\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] );\n*\n* var out = arr.reduce( add, 0 );\n* // returns 6.0\n*/\nsetReadOnly( Float16Array.prototype, 'reduce', function reduce( reducer, initialValue ) {\n\tvar buf;\n\tvar len;\n\tvar acc;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( reducer ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', reducer ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tacc = initialValue;\n\t\ti = 0;\n\t} else {\n\t\tif ( len === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' );\n\t\t}\n\t\tacc = fromWord( buf[ 0 ] );\n\t\ti = 1;\n\t}\n\tfor ( ; i < len; i++ ) {\n\t\tacc = reducer( acc, fromWord( buf[ i ] ), i, this );\n\t}\n\treturn acc;\n});\n\n/**\n* Applies a provided callback function to each element of the array, in reverse order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion.\n*\n* @name reduceRight\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} reducer - callback function\n* @param {*} [initialValue] - initial value\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {Error} if not provided an initial value, the array must have at least one element\n* @returns {*} accumulated result\n*\n* @example\n* function add( acc, v ) {\n* return acc + v;\n* }\n*\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] );\n*\n* var out = arr.reduceRight( add, 0 );\n* // returns 6.0\n*/\nsetReadOnly( Float16Array.prototype, 'reduceRight', function reduceRight( reducer, initialValue ) {\n\tvar buf;\n\tvar len;\n\tvar acc;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( reducer ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', reducer ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tacc = initialValue;\n\t\ti = len - 1;\n\t} else {\n\t\tif ( len === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' );\n\t\t}\n\t\tacc = fromWord( buf[ len-1 ] );\n\t\ti = len - 2;\n\t}\n\tfor ( ; i >= 0; i-- ) {\n\t\tacc = reducer( acc, fromWord( buf[ i ] ), i, this );\n\t}\n\treturn acc;\n});\n\n/**\n* Reverses an array in-place.\n*\n* @name reverse\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Float16Array} reversed array\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var out = arr.reverse();\n* // returns \n*\n* var v = out[ 0 ];\n* // returns 2.0\n*\n* v = out[ 1 ];\n* // returns 1.0\n*\n* v = out[ 2 ];\n* // returns 0.0\n*/\nsetReadOnly( Float16Array.prototype, 'reverse', function reverse() {\n\tvar buf;\n\tvar tmp;\n\tvar len;\n\tvar N;\n\tvar i;\n\tvar j;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tN = floor( len / 2 );\n\tfor ( i = 0; i < N; i++ ) {\n\t\tj = len - i - 1;\n\t\ttmp = buf[ i ];\n\t\tbuf[ i ] = buf[ j ];\n\t\tbuf[ j ] = tmp;\n\t}\n\treturn this;\n});\n\n/**\n* Sets one or more array elements.\n*\n* ## Notes\n*\n* - When provided a typed array, we must check whether the source array shares the same buffer as the target array and whether the underlying memory overlaps. In particular, we are concerned with the following scenario:\n*\n* ```text\n* buf: ---------------------\n* src: ---------------------\n* ```\n*\n* In the above, as we copy values from `src`, we will overwrite values in the `src` view, resulting in duplicated values copied into the end of `buf`, which is not intended. Hence, to avoid overwriting source values, we must **copy** source values to a temporary array.\n*\n* In the other overlapping scenario,\n*\n* ```text\n* buf: ---------------------\n* src: ---------------------\n* ```\n*\n* by the time we begin copying into the overlapping region, we are copying from the end of `src`, a non-overlapping region, which means we don't run the risk of copying copied values, rather than the original `src` values, as intended.\n*\n* @name set\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {(Collection|Float16Array)} value - value(s)\n* @param {NonNegativeInteger} [i=0] - element index at which to start writing values\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a collection\n* @throws {TypeError} index argument must be a nonnegative integer\n* @throws {RangeError} index argument is out-of-bounds\n* @throws {RangeError} target array lacks sufficient storage to accommodate source values\n* @returns {void}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var v = arr[ 0 ];\n* // returns 0.0\n*\n* arr.set( [ 1.0, 2.0 ], 0 );\n*\n* v = arr[ 0 ];\n* // returns 1.0\n*/\nsetReadOnly( Float16Array.prototype, 'set', function set( value ) {\n\tvar sbuf;\n\tvar idx;\n\tvar buf;\n\tvar tmp;\n\tvar flg;\n\tvar N;\n\tvar i;\n\tvar j;\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isCollection( value ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', value ) );\n\t}\n\tbuf = this._buffer;\n\tif ( arguments.length > 1 ) {\n\t\tidx = arguments[ 1 ];\n\t\tif ( !isNonNegativeInteger( idx ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Index argument must be a nonnegative integer. Value: `%s`.', idx ) );\n\t\t}\n\t} else {\n\t\tidx = 0;\n\t}\n\tN = value.length;\n\tif ( idx+N > this._length ) {\n\t\tthrow new RangeError( 'invalid arguments. Target array lacks sufficient storage to accommodate source values.' );\n\t}\n\tif ( isFloat16Array( value ) ) {\n\t\tsbuf = value._buffer; // eslint-disable-line no-underscore-dangle\n\t\tflg = true;\n\t} else {\n\t\tsbuf = value;\n\t\tflg = false;\n\t}\n\t// Check for overlapping memory...\n\tj = buf.byteOffset + (idx*BYTES_PER_ELEMENT);\n\tif (\n\t\tsbuf.buffer === buf.buffer &&\n\t\t(\n\t\t\tsbuf.byteOffset < j &&\n\t\t\tsbuf.byteOffset+sbuf.byteLength > j\n\t\t)\n\t) {\n\t\t// We need to copy source values...\n\t\ttmp = new Uint16Array( sbuf.length );\n\t\tfor ( i = 0; i < sbuf.length; i++ ) {\n\t\t\ttmp[ i ] = sbuf[ i ];\n\t\t}\n\t\tsbuf = tmp;\n\t}\n\tif ( flg ) {\n\t\tfor ( i = 0; i < N; idx++, i++ ) {\n\t\t\tbuf[ idx ] = sbuf[ i ];\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < N; idx++, i++ ) {\n\t\t\tbuf[ idx ] = toWord( sbuf[ i ] );\n\t\t}\n\t}\n});\n\n/**\n* Copies a portion of a typed array to a new typed array.\n*\n* @name slice\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} [begin] - start index (inclusive)\n* @param {integer} [end] - end index (exclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be integer\n* @throws {TypeError} second argument must be integer\n* @returns {Float16Array} floating-point number array\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] );\n*\n* var out = arr.slice();\n* // returns \n*\n* var len = out.length;\n* // returns 5\n*\n* var v = out[ 0 ];\n* // returns 0.0\n*\n* v = out[ len-1 ];\n* // returns 4.0\n*\n* out = arr.slice( 1, -2 );\n* // returns \n*\n* len = out.length;\n* // returns 2\n*\n* v = out[ 0 ];\n* // returns 1.0\n*\n* v = out[ len-1 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'slice', function slice( begin, end ) {\n\tvar outlen;\n\tvar outbuf;\n\tvar out;\n\tvar buf;\n\tvar len;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length === 0 ) {\n\t\tbegin = 0;\n\t\tend = len;\n\t} else {\n\t\tif ( !isInteger( begin ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', begin ) );\n\t\t}\n\t\tif ( begin < 0 ) {\n\t\t\tbegin += len;\n\t\t\tif ( begin < 0 ) {\n\t\t\t\tbegin = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\tend = len;\n\t\t} else {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t} else if ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t}\n\t}\n\tif ( begin < end ) {\n\t\toutlen = end - begin;\n\t} else {\n\t\toutlen = 0;\n\t}\n\tout = new this.constructor( outlen );\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < outlen; i++ ) {\n\t\toutbuf[ i ] = buf[ i+begin ];\n\t}\n\treturn out;\n});\n\n/**\n* Tests whether at least one element in an array passes a test implemented by a predicate function.\n*\n* @name some\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {boolean} boolean indicating whether at least one element passes a test\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var bool = arr.some( predicate );\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'some', function some( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( predicate.call( thisArg, fromWord( buf[ i ] ), i, this ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n});\n\n/**\n* Sorts an array in-place.\n*\n* @name sort\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} [compareFcn] - comparison function\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {Float16Array} sorted array\n*\n* @example\n* function compare( a, b ) {\n* if ( a < b ) {\n* return -1;\n* }\n* if ( a > b ) {\n* return 1;\n* }\n* return 0;\n* }\n*\n* var arr = new Float16Array( [ 1.0, 0.0, 2.0 ] );\n*\n* arr.sort( compare );\n*\n* var v = arr[ 0 ];\n* // returns 0.0\n*\n* v = arr[ 1 ];\n* // returns 1.0\n*\n* v = arr[ 2 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'sort', function sort( compareFcn ) {\n\tvar buf;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tif ( arguments.length === 0 ) {\n\t\tbuf.sort( defaultCompare );\n\t\treturn this;\n\t}\n\tif ( !isFunction( compareFcn ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', compareFcn ) );\n\t}\n\tbuf.sort( compare );\n\treturn this;\n\n\t/**\n\t* Default comparison function for float16 values.\n\t*\n\t* @private\n\t* @param {unsigned16} a - unsigned 16-bit integer for comparison\n\t* @param {unsigned16} b - unsigned 16-bit integer for comparison\n\t* @returns {number} comparison result\n\t*/\n\tfunction defaultCompare( a, b ) { // eslint-disable-line stdlib/no-unnecessary-nested-functions\n\t\tvar x = fromWord( a );\n\t\tvar y = fromWord( b );\n\n\t\t// Handle NaN...\n\t\tif ( isnan( x ) && isnan( y ) ) {\n\t\t\treturn 0;\n\t\t}\n\t\tif ( isnan( x ) ) {\n\t\t\treturn 1;\n\t\t}\n\t\tif ( isnan( y ) ) {\n\t\t\treturn -1;\n\t\t}\n\t\t// Normal comparison\n\t\tif ( x < y ) {\n\t\t\treturn -1;\n\t\t}\n\t\tif ( x > y ) {\n\t\t\treturn 1;\n\t\t}\n\t\treturn 0;\n\t}\n\n\t/**\n\t* Comparison function wrapper.\n\t*\n\t* @private\n\t* @param {unsigned16} a - unsigned 16-bit integer for comparison\n\t* @param {unsigned16} b - unsigned 16-bit integer for comparison\n\t* @returns {number} comparison result\n\t*/\n\tfunction compare( a, b ) {\n\t\treturn compareFcn( fromWord( a ), fromWord( b ) );\n\t}\n});\n\n/**\n* Creates a new typed array view over the same underlying `ArrayBuffer` and with the same underlying data type as the host array.\n*\n* @name subarray\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} [begin] - start index (inclusive)\n* @param {integer} [end] - end index (exclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be an integer\n* @throws {TypeError} second argument must be an integer\n* @returns {Float16Array} subarray\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] );\n*\n* var subarr = arr.subarray();\n* // returns \n*\n* var len = subarr.length;\n* // returns 5\n*\n* var bool = subarr[ 0 ];\n* // returns 0.0\n*\n* bool = subarr[ len-1 ];\n* // returns 4.0\n*\n* subarr = arr.subarray( 1, -2 );\n* // returns \n*\n* len = subarr.length;\n* // returns 2\n*\n* bool = subarr[ 0 ];\n* // returns 1.0\n*\n* bool = subarr[ len-1 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'subarray', function subarray( begin, end ) {\n\tvar offset;\n\tvar buf;\n\tvar len;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length === 0 ) {\n\t\tbegin = 0;\n\t\tend = len;\n\t} else {\n\t\tif ( !isInteger( begin ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', begin ) );\n\t\t}\n\t\tif ( begin < 0 ) {\n\t\t\tbegin += len;\n\t\t\tif ( begin < 0 ) {\n\t\t\t\tbegin = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\tend = len;\n\t\t} else {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t} else if ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t}\n\t}\n\tif ( begin >= len ) {\n\t\tlen = 0;\n\t\toffset = buf.byteLength;\n\t} else if ( begin >= end ) {\n\t\tlen = 0;\n\t\toffset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT );\n\t} else {\n\t\tlen = end - begin;\n\t\toffset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT );\n\t}\n\treturn new this.constructor( buf.buffer, offset, ( len < 0 ) ? 0 : len );\n});\n\n/**\n* Serializes an array as a locale-specific string.\n*\n* @name toLocaleString\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {(string|Array)} [locales] - locale identifier(s)\n* @param {Object} [options] - configuration options\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a string or an array of strings\n* @throws {TypeError} options argument must be an object\n* @returns {string} string representation\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var str = arr.toLocaleString();\n* // returns '0,1,2'\n*/\nsetReadOnly( Float16Array.prototype, 'toLocaleString', function toLocaleString( locales, options ) {\n\tvar opts;\n\tvar loc;\n\tvar out;\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( arguments.length === 0 ) {\n\t\tloc = [];\n\t} else if ( isString( locales ) || isStringArray( locales ) ) {\n\t\tloc = locales;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a string or an array of strings. Value: `%s`.', locales ) );\n\t}\n\tif ( arguments.length < 2 ) {\n\t\topts = {};\n\t} else if ( isObject( options ) ) {\n\t\topts = options;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( fromWord( buf[ i ] ) );\n\t}\n\treturn out.toLocaleString( loc, opts );\n});\n\n/**\n* Returns a new typed array containing the elements in reversed order.\n*\n* @name toReversed\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Float16Array} reversed array\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var out = arr.toReversed();\n* // returns \n*\n* var v = out[ 0 ];\n* // returns 2.0\n*\n* v = out[ 1 ];\n* // returns 1.0\n*\n* v = out[ 2 ];\n* // returns 0.0\n*/\nsetReadOnly( Float16Array.prototype, 'toReversed', function toReversed() {\n\tvar outbuf;\n\tvar out;\n\tvar len;\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tlen = this._length;\n\tout = new this.constructor( len );\n\tbuf = this._buffer;\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < len; i++ ) {\n\t\toutbuf[ i ] = buf[ len - i - 1 ];\n\t}\n\treturn out;\n});\n\n/**\n* Returns a new typed array containing the elements in sorted order.\n*\n* @name toSorted\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} [compareFcn] - comparison function\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {Float16Array} sorted array\n*\n* @example\n* function compare( a, b ) {\n* if ( a > b ) {\n* return 1;\n* }\n* if ( a < b ) {\n* return -1;\n* }\n* return 0;\n* }\n*\n* var arr = new Float16Array( [ 2.0, 0.0, 1.0 ] );\n*\n* var out = arr.toSorted( compare );\n* // returns \n*\n* var v = out[ 0 ];\n* // returns 0.0\n*\n* v = out[ 1 ];\n* // returns 1.0\n*\n* v = out[ 2 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'toSorted', function toSorted( compareFcn ) {\n\tvar out;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tout = new this.constructor( this );\n\tif ( arguments.length === 0 ) {\n\t\treturn out.sort();\n\t}\n\treturn out.sort( compareFcn );\n});\n\n/**\n* Serializes an array as a string.\n*\n* @name toString\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {string} string representation\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var str = arr.toString();\n* // returns '0,1,2'\n*/\nsetReadOnly( Float16Array.prototype, 'toString', function toString() {\n\tvar out;\n\tvar buf;\n\tvar i;\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( fromWord( buf[ i ] ) );\n\t}\n\treturn out.join( ',' );\n});\n\n/**\n* Returns an iterator for iterating over each value in a typed array.\n*\n* @name values\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0 ] );\n*\n* var iter = arr.values();\n*\n* var v = iter.next().value;\n* // returns 0.0\n*\n* v = iter.next().value;\n* // returns 1.0\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'values', function values() {\n\tvar iter;\n\tvar self;\n\tvar len;\n\tvar FLG;\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tself = this;\n\tbuf = this._buffer;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': fromWord( buf[ i ] ),\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.values();\n\t}\n});\n\n/**\n* Returns a new typed array with the element at a provided index replaced with a provided value.\n*\n* @name with\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} index - element index\n* @param {number} value - new value\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be an integer\n* @throws {RangeError} index argument is out-of-bounds\n* @throws {TypeError} second argument must be a floating-point number\n* @returns {Float16Array} new typed array\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var out = arr.with( 0, 3.0 );\n* // returns \n*\n* var v = out[ 0 ];\n* // returns 3.0\n*/\nsetReadOnly( Float16Array.prototype, 'with', function copyWith( index, value ) {\n\tvar out;\n\tvar len;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isInteger( index ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', index ) );\n\t}\n\tlen = this._length;\n\tif ( index < 0 ) {\n\t\tindex += len;\n\t}\n\tif ( index < 0 || index >= len ) {\n\t\tthrow new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%s`.', index ) );\n\t}\n\tif ( !isNumber( value ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a number. Value: `%s`.', value ) );\n\t}\n\tout = new this.constructor( this );\n\tout[ index ] = value;\n\treturn out;\n});\n\n\n// EXPORTS //\n\nmodule.exports = Float16Array;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Float16Array === 'function' ) ? Float16Array : void 0; // eslint-disable-line no-undef, stdlib/require-globals\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* 16-bit floating-point number array constructor.\n*\n* @module @stdlib/array-float16\n*\n* @example\n* var Float16Array = require( '@stdlib/array-float16' );\n*\n* var arr = new Float16Array();\n* // returns \n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var Float16Array = require( '@stdlib/array-float16' );\n*\n* var arr = new Float16Array( 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var Float16Array = require( '@stdlib/array-float16' );\n*\n* var arr = new Float16Array( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var Float16Array = require( '@stdlib/array-float16' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float16Array( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 8\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var Float16Array = require( '@stdlib/array-float16' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float16Array( buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 4\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var Float16Array = require( '@stdlib/array-float16' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Float16Array( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\n\n// MODULES //\n\nvar hasFloat16ArraySupport = require( '@stdlib/assert-has-float16array-support' );\nvar polyfill = require( './polyfill' );\nvar builtin = require( './main.js' );\n\n\n// MAIN //\n\nvar ctor;\nif ( hasFloat16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nmodule.exports = ctor;\n"], - "mappings": "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", - "names": ["require_from_array", "__commonJSMin", "exports", "module", "f16", "toWord", "fromArray", "buf", "arr", "len", "require_from_iterator", "__commonJSMin", "exports", "module", "f16", "toWord", "fromIterator", "it", "out", "v", "require_from_iterator_map", "__commonJSMin", "exports", "module", "f16", "toWord", "fromIteratorMap", "it", "clbk", "thisArg", "out", "v", "i", "require_polyfill", "__commonJSMin", "exports", "module", "hasIteratorSymbolSupport", "isNonNegativeInteger", "isStringArray", "isCollection", "isArrayBuffer", "isFunction", "isInteger", "isNumber", "isString", "isObject", "isnan", "ITERATOR_SYMBOL", "setReadOnlyAccessor", "setReadOnly", "setReadWriteAccessor", "floor", "format", "Uint16Array", "f16", "toWord", "fromWord", "gcopy", "fromArray", "fromIterator", "fromIteratorMap", "BYTES_PER_ELEMENT", "HAS_ITERATOR_SYMBOL", "isFloat16Array", "value", "isFloatingPointArrayConstructor", "Float16Array", "getter", "ctx", "idx", "get", "setter", "set", "byteOffset", "nargs", "buf", "len", "arg", "i", "src", "thisArg", "clbk", "out", "tmp", "args", "target", "start", "self", "iter", "FLG", "next", "end", "factory", "predicate", "v", "fcn", "searchElement", "fromIndex", "separator", "outbuf", "reducer", "initialValue", "acc", "N", "j", "sbuf", "flg", "begin", "outlen", "compareFcn", "defaultCompare", "compare", "a", "b", "x", "y", "offset", "locales", "options", "opts", "loc", "index", "require_main", "__commonJSMin", "exports", "module", "ctor", "hasFloat16ArraySupport", "polyfill", "builtin", "ctor"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index e311742..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,1222 +0,0 @@ - -{{alias}}() - A 16-bit half-precision floating-point number array. - - Returns - ------- - out: Float16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Creates a half-precision floating-point number array having a specified - length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: Float16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - - > var len = arr.length - 5 - - -{{alias}}( typedarray ) - Creates a half-precision floating-point number array from a typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate a half-precision floating-point - number array. - - Returns - ------- - out: Float16Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/float64}}( [ 0.5, 0.5, 0.5 ] ) - - > var arr = new {{alias}}( buf ) - - > var len = arr.length - 3 - - -{{alias}}( obj ) - Creates a half-precision floating-point number array from an array-like - object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a half-precision - floating-point number array. - - Returns - ------- - out: Float16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( [ 0.5, 0.5, 0.5 ] ) - - > var len = arr.length - 3 - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a half-precision floating-point number array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - Returns - ------- - out: Float16Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 8 ); - > var arr1 = new {{alias}}( buf ) - - > var len = arr1.length - 4 - > var arr2 = new {{alias}}( buf, 2 ) - - > len = arr2.length - 3 - > var arr3 = new {{alias}}( buf, 2, 2 ) - - > len = arr3.length - 2 - - -{{alias}}.from( src[, clbk[, thisArg]] ) - Creates a new half-precision floating-point number array from an array-like - object or an iterable. - - A callback function is provided two arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - clbk: Function (optional) - Callback to invoke for each source element. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Float16Array - A typed array. - - Examples - -------- - > function clbkFcn( v ) { return v * 2.0 }; - > var arr = {{alias}}.from( [ 1.0, -1.0 ], clbkFcn ) - - > var len = arr.length - 2 - > var v = arr[ 0 ] - 2.0 - > v = arr[ 1 ] - -2.0 - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new half-precision floating-point number array from a variable - number of arguments. - - Parameters - ---------- - element0: number - Array element. - - element1: number (optional) - Array element. - - elementN: ...number (optional) - Array elements. - - Returns - ------- - out: Float16Array - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( 1.0, -1.0 ) - - > var len = arr.length - 2 - > var v = arr[ 0 ] - 1.0 - > v = arr[ 1 ] - -1.0 - - -{{alias}}.BYTES_PER_ELEMENT - The size of each array element in bytes. - - Examples - -------- - > var nbytes = {{alias}}.BYTES_PER_ELEMENT - 2 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > var str = {{alias}}.name - 'Float16Array' - - -{{alias}}.prototype.buffer - Pointer to the underlying data buffer. - - Examples - -------- - > var arr = new {{alias}}( 2 ) - - > var buf = arr.buffer - - - -{{alias}}.prototype.byteLength - Length of the array in bytes. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - - > var nbytes = arr.byteLength - 10 - - -{{alias}}.prototype.byteOffset - Offset (in bytes) of the array from the start of its underlying ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - - > var offset = arr.byteOffset - 0 - > var buf = new {{alias:@stdlib/array/buffer}}( 20 ); - > arr = new {{alias}}( buf, 10 ) - - > offset = arr.byteOffset - 10 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each array element. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - - > arr.BYTES_PER_ELEMENT - 2 - - -{{alias}}.prototype.length - The number of array elements. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - - > var len = arr.length - 5 - - -{{alias}}.prototype.at( i ) - Returns an array element located at integer position (index) `i`, with - support for both nonnegative and negative integer positions. - - If provided an index outside the array index range, the method returns - `undefined`. - - Parameters - ---------- - i: integer - Element index. - - Returns - ------- - out: float|void - An array element. - - Examples - -------- - > var arr = new {{alias}}( [ 10.0, 20.0, 30.0 ] ) - - > var v = arr.at( 0 ) - 10.0 - > v = arr.at( -1 ) - 30.0 - - -{{alias}}.prototype.copyWithin( target, start[, end] ) - Copies a sequence of elements within the array starting at `start` and - ending at `end` (non-inclusive) to the position starting at `target`. - - Parameters - ---------- - target: integer - Target start index position. - - start: integer - Source start index position. - - end: integer (optional) - Source end index position. Default: out.length. - - Returns - ------- - out: Float16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ) - - > arr.copyWithin( 0, 3 ) - - > var v = arr[ 0 ] - 4.0 - > v = arr[ 1 ] - 5.0 - - -{{alias}}.prototype.entries() - Returns an iterator for iterating over array key-value pairs. - - Returns - ------- - iterator: Iterator - Iterator for iterating over array key-value pairs. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var it = arr.entries(); - > var v = it.next().value - [ 0, 1.0 ] - > v = it.next().value - [ 1, 2.0 ] - > v = it.next().value - [ 2, 3.0 ] - > var bool = it.next().done - true - - -{{alias}}.prototype.every( predicate[, thisArg] ) - Returns a boolean indicating whether all elements in the array pass a test. - - A predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether all elements pass the test. - - Examples - -------- - > function predicate( v ) { return ( v > 0.0 ); }; - > var arr = new {{alias}}( [ 1.0, 2.0 ] ) - - > var bool = arr.every( predicate ) - true - - -{{alias}}.prototype.fill( value[, start[, end]] ) - Returns a modified typed array filled with a fill value. - - Parameters - ---------- - value: number - Fill value. - - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Float16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( 3 ) - - > arr.fill( 2.0 ); - > var v = arr[ 0 ] - 2.0 - > v = arr[ 1 ] - 2.0 - > v = arr[ 2 ] - 2.0 - - -{{alias}}.prototype.filter( predicate[, thisArg] ) - Returns a new array containing the elements of an array which pass a test - implemented by a predicate function. - - A predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - The returned array has the same data type as the host array. - - Parameters - ---------- - predicate: Function - Predicate function which filters array elements. If a predicate function - returns a truthy value, an array element is included in the output - array; otherwise, an array element is not included in the output array. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - out: Float16Array - A new typed array. - - Examples - -------- - > function predicate( v ) { return ( v > 1.0 ); }; - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var out = arr.filter( predicate ) - - > var len = out.length - 2 - > var v = out[ 0 ] - 2.0 - > v = out[ 1 ] - 3.0 - - -{{alias}}.prototype.find( predicate[, thisArg] ) - Returns the first element in an array for which a predicate function - returns a truthy value. - - A predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - out: number|void - Array element or `undefined`. - - Examples - -------- - > function predicate( v ) { return ( v > 1.0 ); }; - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var v = arr.find( predicate ) - 2.0 - - -{{alias}}.prototype.findIndex( predicate[, thisArg] ) - Returns the index of the first element in an array for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - out: integer - Array index or `-1`. - - Examples - -------- - > function predicate( v ) { return ( v > 2.0 ); }; - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var idx = arr.findIndex( predicate ) - 2 - - -{{alias}}.prototype.findLast( predicate[, thisArg] ) - Returns the last element in an array for which a predicate function returns - a truthy value. - - A predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - out: number|void - Array element or `undefined`. - - Examples - -------- - > function predicate( v ) { return ( v > 1.0 ); }; - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var v = arr.findLast( predicate ) - 3.0 - - -{{alias}}.prototype.findLastIndex( predicate[, thisArg] ) - Returns the index of the last element in an array for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - out: integer - Array index or `-1`. - - Examples - -------- - > function predicate( v ) { return ( v > 1.0 ); }; - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var idx = arr.findLastIndex( predicate ) - 2 - - -{{alias}}.prototype.forEach( clbk[, thisArg] ) - Invokes a function once for each array element. - - A callback function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - Parameters - ---------- - clbk: Function - Function to invoke for each array element. - - thisArg: Any (optional) - Execution context. - - Examples - -------- - > var str = '%'; - > function clbk( v ) { str += v.toString() + '%'; }; - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > arr.forEach( clbk ); - > str - '%1%2%3%' - - -{{alias}}.prototype.includes( searchElement[, fromIndex] ) - Returns a boolean indicating whether an array includes a provided value. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index at which to start the search. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - bool: boolean - Boolean indicating whether an array includes a search element. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var bool = arr.includes( 3.0 ) - true - > bool = arr.includes( 3.0, 3 ) - false - - -{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) - Returns the first index at which a given element can be found. - - If method does not find a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index at which to start the search. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - out: integer - Array index or `-1`. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var idx = arr.indexOf( 2.0 ) - 1 - > idx = arr.indexOf( 2.0, 2 ) - -1 - - -{{alias}}.prototype.join( [separator] ) - Returns a new string by concatenating all array elements separated by a - separator string. - - Parameters - ---------- - separator: string (optional) - Separator string. Default: ','. - - Returns - ------- - out: string - Array serialized as a string. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var str = arr.join() - '1,2,3' - > str = arr.join( '|' ) - '1|2|3' - - -{{alias}}.prototype.keys() - Returns an iterator for iterating over each index key in a typed array. - - Returns - ------- - iterator: Iterator - Iterator for iterating over array index keys. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0 ] ) - - > var it = arr.keys(); - > var v = it.next().value - 0 - > v = it.next().value - 1 - > v = it.next().done - true - - -{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) - Returns the last index at which a given element can be found. - - If method does not find a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index at which to start the search. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: out.length-1. - - Returns - ------- - out: integer - Array index or `-1`. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0, 1.0 ] ) - - > var idx = arr.lastIndexOf( 1.0 ) - 3 - > idx = arr.lastIndexOf( 1.0, 2 ) - 0 - - -{{alias}}.prototype.map( clbk[, thisArg] ) - Returns a new array with each element being the result of a provided - callback function. - - A callback function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - The returned array has the same data type as the host array. - - Parameters - ---------- - clbk: Function - Function which maps array elements to elements in the new array. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - out: Float16Array - A new typed array. - - Examples - -------- - > function clbk( v ) { return v * 2.0; }; - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var out = arr.map( clbk ) - - > var v = out[ 0 ] - 2.0 - > v = out[ 1 ] - 4.0 - > v = out[ 2 ] - 6.0 - - -{{alias}}.prototype.reduce( reducerFn[, initialValue] ) - Applies a provided function to each element of the array, in order, passing - in the return value from the calculation on the preceding element and - returning the accumulated result upon completion. - - A reducer function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the first array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the first array element as the first argument and the second array - element as the second argument. - - Parameters - ---------- - reducerFn: Function - Function to apply to each array element. - - initialValue: any (optional) - Initial accumulation value. - - Returns - ------- - out: any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > function reducerFn( acc, v ) { return acc + v; }; - > var v = arr.reduce( reducerFn, 0.0 ) - 6.0 - - -{{alias}}.prototype.reduceRight( reducerFn[, initialValue] ) - Applies a provided function to each element of the array, in reverse order, - passing in the return value from the calculation on the preceding element - and returning the accumulated result upon completion. - - A reducer function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the last array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the last array element as the first argument and the second-to-last - array element as the second argument. - - Parameters - ---------- - reducerFn: Function - Function to apply to each array element. - - initialValue: any (optional) - Initial accumulation value. - - Returns - ------- - out: any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > function reducerFn( acc, v ) { return acc + v; }; - > var v = arr.reduceRight( reducerFn, 0.0 ) - 6.0 - - -{{alias}}.prototype.reverse() - Reverses the array *in-place*. - - This method mutates the array on which the method is invoked. - - Returns - ------- - out: Float16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > arr.reverse(); - > var v = arr[ 0 ] - 3.0 - > v = arr[ 1 ] - 2.0 - > v = arr[ 2 ] - 1.0 - - -{{alias}}.prototype.set( arr[, offset] ) - Sets one or more array elements. - - If provided a single argument, the method sets array elements starting at - position (index) `i = 0`. To set elements starting elsewhere in the array, - provide an offset argument. - - Parameters - ---------- - arr: ArrayLike - Source array containing array values to set. - - offset: integer (optional) - Array index at which to start writing values. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > arr.set( [ 4.0, 5.0 ], 1 ); - > var v = arr[ 0 ] - 1.0 - > v = arr[ 1 ] - 4.0 - > v = arr[ 2 ] - 5.0 - - -{{alias}}.prototype.slice( [start[, end]] ) - Copies a portion of a typed array to a new typed array. - - Parameters - ---------- - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Float16Array - New typed array. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var out = arr.slice( 1 ) - - > var len = out.length - 2 - > var v = out[ 0 ] - 2.0 - > v = out[ 1 ] - 3.0 - - -{{alias}}.prototype.some( predicate[, thisArg] ) - Returns a boolean indicating whether at least one element passes a test. - - A predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether at least one element passes the test. - - Examples - -------- - > function predicate( v ) { return ( v > 2.0 ); }; - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var bool = arr.some( predicate ) - true - - -{{alias}}.prototype.sort( [compareFunction] ) - Sorts an array in-place. - - A comparison function determines the order of the array elements. The - function is provided two arguments: - - - a: first element for comparison. - - b: second element for comparison. - - The function should return a value less than zero if `a` comes before `b`, - a value greater than zero if `a` comes after `b`, and zero if `a` and `b` - are equivalent. - - Parameters - ---------- - compareFunction: Function (optional) - Comparison function. - - Returns - ------- - out: Float16Array - Modified array. - - Examples - -------- - > function compare( a, b ) { return a - b; }; - > var arr = new {{alias}}( [ 2.0, 3.0, 1.0 ] ) - - > arr.sort( compare ); - > var v = arr[ 0 ] - 1.0 - > v = arr[ 1 ] - 2.0 - > v = arr[ 2 ] - 3.0 - - -{{alias}}.prototype.subarray( [begin[, end]] ) - Creates a new typed array view over the same underlying `ArrayBuffer` and - with the same underlying data type as the host array. - - Parameters - ---------- - begin: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Float16Array - New typed array view. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ) - - > var out = arr.subarray( 1, 3 ) - - > var len = out.length - 2 - > var v = out[ 0 ] - 2.0 - > v = out[ 1 ] - 3.0 - - -{{alias}}.prototype.toLocaleString( [locales[, options]] ) - Serializes an array as a locale-specific string. - - Parameters - ---------- - locales: string|Array (optional) - Locale identifier(s). - - options: Object (optional) - An object containing serialization options. - - Returns - ------- - str: string - Local-specific string. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var str = arr.toLocaleString() - '1,2,3' - - -{{alias}}.prototype.toReversed() - Returns a new typed array containing the elements in reversed order. - - Returns - ------- - out: Float16Array - New typed array. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var out = arr.toReversed() - - > var v = out[ 0 ] - 3.0 - > v = out[ 1 ] - 2.0 - > v = out[ 2 ] - 1.0 - - -{{alias}}.prototype.toSorted( [compareFcn] ) - Returns a new typed array containing the elements in sorted order. - - A comparison function determines the order of the array elements. The - function is provided two arguments: - - - a: first element for comparison. - - b: second element for comparison. - - The function should return a value less than zero if `a` comes before `b`, - a value greater than zero if `a` comes after `b`, and zero if `a` and `b` - are equivalent. - - Parameters - ---------- - compareFcn: Function (optional) - Comparison function. - - Returns - ------- - out: Float16Array - New typed array. - - Examples - -------- - > function compare( a, b ) { return a - b; }; - > var arr = new {{alias}}( [ 2.0, 3.0, 1.0 ] ) - - > var out = arr.toSorted( compare ); - > var v = out[ 0 ] - 1.0 - > v = out[ 1 ] - 2.0 - > v = out[ 2 ] - 3.0 - - -{{alias}}.prototype.toString() - Serializes an array as a string. - - Returns - ------- - str: string - String serialization of the array. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var str = arr.toString() - '1,2,3' - - -{{alias}}.prototype.values() - Returns an iterator for iterating over each value in a typed array. - - Returns - ------- - iterator: Iterator - Iterator for iterating over array values. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0 ] ) - - > var it = arr.values(); - > var v = it.next().value - 1.0 - > v = it.next().value - 2.0 - > var bool = it.next().done - true - - -{{alias}}.prototype.with( index, value ) - Returns a new typed array with the element at a provided index replaced with - a provided value. - - Parameters - ---------- - index: integer - Element index. - - value: number - Element value. - - Returns - ------- - out: Float16Array - New typed array. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 2.0, 3.0 ] ) - - > var out = arr.with( 1, 4.0 ) - - > var v = out[ 1 ] - 4.0 - - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 033057e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,129 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2026 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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ArrayBuffer = require( '@stdlib/array-buffer' ); -import Float16Array = require( './index' ); - -/** -* Callback function. -* -* @param v - value -* @returns input value -*/ -function clbk( v: number ): number { - return v; -} - - -// TESTS // - -// The function returns a half-precision floating-point number array... -{ - new Float16Array(); // $ExpectType Float16Array - new Float16Array( 2 ); // $ExpectType Float16Array - new Float16Array( [ 1.0, -1.0 ] ); // $ExpectType Float16Array - - const buf = new ArrayBuffer( 16 ); - new Float16Array( buf ); // $ExpectType Float16Array - new Float16Array( buf, 8 ); // $ExpectType Float16Array - new Float16Array( buf, 8, 2 ); // $ExpectType Float16Array -} - -// The compiler throws an error if the function is provided a first argument that is not a number, typed array, array-like object, or array buffer... -{ - new Float16Array( true ); // $ExpectError - new Float16Array( false ); // $ExpectError - new Float16Array( null ); // $ExpectError - new Float16Array( 'abc' ); // $ExpectError - new Float16Array( {} ); // $ExpectError - new Float16Array( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument that is not a number... -{ - const buf = new ArrayBuffer( 16 ); - new Float16Array( buf, true ); // $ExpectError - new Float16Array( buf, false ); // $ExpectError - new Float16Array( buf, null ); // $ExpectError - new Float16Array( buf, 'abc' ); // $ExpectError - new Float16Array( buf, {} ); // $ExpectError - new Float16Array( buf, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument that is not a number... -{ - const buf = new ArrayBuffer( 16 ); - new Float16Array( buf, 8, true ); // $ExpectError - new Float16Array( buf, 8, false ); // $ExpectError - new Float16Array( buf, 8, null ); // $ExpectError - new Float16Array( buf, 8, 'abc' ); // $ExpectError - new Float16Array( buf, 8, {} ); // $ExpectError - new Float16Array( buf, 8, ( x: number ): number => x ); // $ExpectError -} - -// The `from` method returns a half-precision floating-point number array... -{ - Float16Array.from( [ 1.0, 1.0 ] ); // $ExpectType Float16Array - Float16Array.from( [ 1.0, 1.0 ], ( x: number ): number => x * x ); // $ExpectType Float16Array - Float16Array.from( [ 1.0 ], clbk, {} ); // $ExpectType Float16Array -} - -// The compiler throws an error if the `from` method is provided a first argument which is not array-like or iterable... -{ - Float16Array.from( true ); // $ExpectError - Float16Array.from( false ); // $ExpectError - Float16Array.from( 123 ); // $ExpectError - Float16Array.from( null ); // $ExpectError - Float16Array.from( {} ); // $ExpectError - - Float16Array.from( true, clbk ); // $ExpectError - Float16Array.from( false, clbk ); // $ExpectError - Float16Array.from( 123, clbk ); // $ExpectError - Float16Array.from( null, clbk ); // $ExpectError - Float16Array.from( {}, clbk ); // $ExpectError - - Float16Array.from( true, clbk, {} ); // $ExpectError - Float16Array.from( false, clbk, {} ); // $ExpectError - Float16Array.from( 123, clbk, {} ); // $ExpectError - Float16Array.from( null, clbk, {} ); // $ExpectError - Float16Array.from( {}, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the `from` method is provided a second argument which is not a function with a supported signature... -{ - Float16Array.from( [ 1.0, 1.0 ], true ); // $ExpectError - Float16Array.from( [ 1.0, 1.0 ], false ); // $ExpectError - Float16Array.from( [ 1.0, 1.0 ], 123 ); // $ExpectError - Float16Array.from( [ 1.0, 1.0 ], null ); // $ExpectError - Float16Array.from( [ 1.0, 1.0 ], {} ); // $ExpectError -} - -// The `of` method returns a half-precision floating-point number array... -{ - Float16Array.of( 1.0, 1.0, 1.0, 1.0 ); // $ExpectType Float16Array -} - -// The compiler throws an error if the `of` method is provided arguments that are not numbers... -{ - Float16Array.of( 'abc', 'def' ); // $ExpectError - Float16Array.of( true, false ); // $ExpectError - Float16Array.of( {}, [] ); // $ExpectError - Float16Array.of( null, null ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a5c84ca..0000000 --- a/examples/index.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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'; - -var Uint16Array = require( '@stdlib/array-uint16' ); -var logEach = require( '@stdlib/console-log-each' ); -var Float16Array = require( './../lib' ); - -// Create a half-precision floating-point number array by specifying a length: -var out = new Float16Array( 3 ); -logEach( '%s', out ); - -// Create a half-precision floating-point number array from an array of numbers: -var arr = [ 1.05, 2.05, 3.05 ]; -out = new Float16Array( arr ); -logEach( '%s', out ); - -// Create a half-precision floating-point number array from an array buffer: -arr = new Uint16Array( [ 1000, 2000, 3000, 4000 ] ); -out = new Float16Array( arr.buffer ); -logEach( '%s', out ); - -// Create a half-precision floating-point number array from an array buffer view: -arr = new Uint16Array( [ 1000, 2000, 3000, 4000 ] ); -out = new Float16Array( arr.buffer, 2, 2 ); -logEach( '%s', out ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 001159c..ed52b06 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { Iterator as Iter, IterableIterator, TypedIterator } from '@stdlib/types/iter'; import { ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..e1ce965 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-float16array-support@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-has-iterator-symbol-support@v0.2.3-esm/index.mjs";import{isPrimitive as n}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-nonnegative-integer@v0.2.3-esm/index.mjs";import{primitives as i}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string-array@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.3-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-arraybuffer@v0.2.3-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.3-esm/index.mjs";import{isPrimitive as f}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-integer@v0.2.3-esm/index.mjs";import{isPrimitive as h}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.3-esm/index.mjs";import{isPrimitive as l}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-string@v0.2.3-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-object@v0.2.3-esm/index.mjs";import u from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-assert-is-nan@v0.2.3-esm/index.mjs";import p from"https://cdn.jsdelivr.net/gh/stdlib-js/symbol-iterator@v0.2.3-esm/index.mjs";import w from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-accessor@v0.2.4-esm/index.mjs";import y from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.3-esm/index.mjs";import c from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.3-esm/index.mjs";import v from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@v0.2.4-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";import g from"https://cdn.jsdelivr.net/gh/stdlib-js/array-uint16@v0.2.3-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float64-base-to-float16@v0.1.2-esm/index.mjs";import b from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float16-base-to-word@v0.1.1-esm/index.mjs";import E from"https://cdn.jsdelivr.net/gh/stdlib-js/number-float16-base-from-word@v0.2.1-esm/index.mjs";import T from"https://cdn.jsdelivr.net/gh/stdlib-js/blas-base-gcopy@v0.2.3-esm/index.mjs";function _(t){var r,n;for(r=[];!(n=t.next()).done;)r.push(b(m(n.value)));return r}var j=g.BYTES_PER_ELEMENT,x=r();function L(t){return"object"==typeof t&&null!==t&&"Float16Array"===t.constructor.name&&t.BYTES_PER_ELEMENT===j}function R(t){return t===P}function O(t,r){return function(){return t._get(r)}}function A(t,r){return function(n){t.set([n],r)}}function P(){var t,r,i,h,l,u;if(r=arguments.length,!(this instanceof P))return 0===r?new P:1===r?new P(arguments[0]):2===r?new P(arguments[0],arguments[1]):new P(arguments[0],arguments[1],arguments[2]);if(0===r)i=new g(0);else if(1===r)if(n(l=arguments[0]))i=new g(l);else if(e(l))L(l)?(i=new g(l.length),T.ndarray(l.length,new g(l.buffer,l.byteOffset,l.length),1,0,i,1,0)):i=function(t,r){var n,i;for(n=r.length,i=0;ii.byteLength-t)throw new RangeError(d("null2G",h*j));i=new g(i,t,h)}}for(y(this,"_buffer",i),y(this,"_length",i.length),u=0;u1){if(!s(i=arguments[1]))throw new TypeError(d("null2H",i));n>2&&(r=arguments[2])}if(e(t)){if(i){for(f=(o=new this(l=t.length))._buffer,u=0;u=this._length))return E(this._buffer[t])})),w(P.prototype,"buffer",(function(){return this._buffer.buffer})),w(P.prototype,"byteLength",(function(){return this._buffer.byteLength})),w(P.prototype,"byteOffset",(function(){return this._buffer.byteOffset})),y(P.prototype,"BYTES_PER_ELEMENT",P.BYTES_PER_ELEMENT),y(P.prototype,"copyWithin",(function(t,r){if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");return 2===arguments.length?this._buffer.copyWithin(t,r):this._buffer.copyWithin(t,r,arguments[2]),this})),y(P.prototype,"entries",(function(){var t,r,n,i,e,o;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");return t=this,i=this._buffer,n=this._length,o=-1,y(r={},"next",(function(){if(o+=1,e||o>=n)return{done:!0};return{value:[o,E(i[o])],done:!1}})),y(r,"return",(function(t){if(e=!0,arguments.length)return{value:t,done:!0};return{done:!0}})),p&&y(r,p,(function(){return t.entries()})),r})),y(P.prototype,"every",(function(t,r){var n,i;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!s(t))throw new TypeError(d("null3c",t));for(n=this._buffer,i=0;i1){if(!f(r))throw new TypeError(d("null7f",r));if(r<0&&(r+=e)<0&&(r=0),arguments.length>2){if(!f(n))throw new TypeError(d("null2z",n));n<0&&(n+=e)<0&&(n=0),n>e&&(n=e)}else n=e}else r=0,n=e;for(s=b(t),o=r;o=0;e--)if(i=E(n[e]),t.call(r,i,e,this))return i})),y(P.prototype,"findLastIndex",(function(t,r){var n,i,e;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!s(t))throw new TypeError(d("null3c",t));for(n=this._buffer,e=this._length-1;e>=0;e--)if(i=E(n[e]),t.call(r,i,e,this))return e;return-1})),y(P.prototype,"forEach",(function(t,r){var n,i;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!s(t))throw new TypeError(d("null3c",t));for(n=this._buffer,i=0;i=this._length))return E(this._buffer[t])})),y(P.prototype,"includes",(function(t,r){var n,i,e;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!h(t))throw new TypeError(d("null49",t));if(arguments.length>1){if(!f(r))throw new TypeError(d("null7f",r));r<0&&(r+=this._length)<0&&(r=0)}else r=0;for(n=this._buffer,e=b(t),i=r;i1){if(!f(r))throw new TypeError(d("null7f",r));r<0&&(r+=this._length)<0&&(r=0)}else r=0;for(n=this._buffer,e=b(t),i=r;i0){if(!l(t))throw new TypeError(d("null3F",t))}else t=",";for(r=this._buffer,n=[],i=0;i=n)return{done:!0};return{value:e,done:!1}})),y(r,"return",(function(t){if(i=!0,arguments.length)return{value:t,done:!0};return{done:!0}})),p&&y(r,p,(function(){return t.keys()})),r})),y(P.prototype,"lastIndexOf",(function(t,r){var n,i,e;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!h(t))throw new TypeError(d("null49",t));if(arguments.length>1){if(!f(r))throw new TypeError(d("null7f",r));r>=this._length?r=this._length-1:r<0&&(r+=this._length)}else r=this._length-1;for(n=this._buffer,e=b(t),i=r;i>=0;i--)if(e===n[i])return i;return-1})),w(P.prototype,"length",(function(){return this._length})),y(P.prototype,"map",(function(t,r){var n,i,e,o;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!s(t))throw new TypeError(d("null3c"),t);for(e=this._buffer,n=(i=new this.constructor(this._length))._buffer,o=0;o1)e=r,o=0;else{if(0===i)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");e=E(n[0]),o=1}for(;o1)e=r,o=i-1;else{if(0===i)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");e=E(n[i-1]),o=i-2}for(;o>=0;o--)e=t(e,E(n[o]),o,this);return e})),y(P.prototype,"reverse",(function(){var t,r,n,i,e,o;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");for(t=this._buffer,n=this._length,i=v(n/2),e=0;e1){if(!n(i=arguments[1]))throw new TypeError(d("null2L",i))}else i=0;if(i+(h=t.length)>this._length)throw new RangeError(d("null03"));if(L(t)?(r=t._buffer,f=!0):(r=t,f=!1),a=o.byteOffset+i*j,r.buffer===o.buffer&&r.byteOffseta){for(s=new g(r.length),l=0;ls&&(r=s)}}for(n=ti)return 1;return 0})),this;if(!s(t))throw new TypeError(d("null3c",t));return r.sort((function(r,n){return t(E(r),E(n))})),this})),y(P.prototype,"subarray",(function(t,r){var n,i,e;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(i=this._buffer,e=this._length,0===arguments.length)t=0,r=e;else{if(!f(t))throw new TypeError(d("null7e",t));if(t<0&&(t+=e)<0&&(t=0),1===arguments.length)r=e;else{if(!f(r))throw new TypeError(d("null7f",r));r<0?(r+=e)<0&&(r=0):r>e&&(r=e)}}return t>=e?(e=0,n=i.byteLength):t>=r?(e=0,n=i.byteOffset+t*j):(e=r-t,n=i.byteOffset+t*j),new this.constructor(i.buffer,n,e<0?0:e)})),y(P.prototype,"toLocaleString",(function(t,r){var n,e,o,s,f;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(0===arguments.length)e=[];else{if(!l(t)&&!i(t))throw new TypeError(d("invalid argument. First argument must be a string or an array of strings. Value: `%s`.",t));e=t}if(arguments.length<2)n={};else{if(!a(r))throw new TypeError(d("null2V",r));n=r}for(s=this._buffer,o=[],f=0;f=n)return{done:!0};return{value:E(e[o]),done:!1}})),y(t,"return",(function(t){if(i=!0,arguments.length)return{value:t,done:!0};return{done:!0}})),p&&y(t,p,(function(){return r.values()})),t})),y(P.prototype,"with",(function(t,r){var n,i;if(!L(this))throw new TypeError("invalid invocation. `this` is not a floating-point number array.");if(!f(t))throw new TypeError(d("null7e",t));if(i=this._length,t<0&&(t+=i),t<0||t>=i)throw new RangeError(d("nullFP",t));if(!h(r))throw new TypeError(d("null4A",r));return(n=new this.constructor(this))[t]=r,n}));var S="function"==typeof Float16Array?Float16Array:void 0,F=t()?S:P;export{F as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..1b08c57 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/polyfill/from_iterator.js","../lib/polyfill/index.js","../lib/polyfill/from_array.js","../lib/polyfill/from_iterator_map.js","../lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport f16 from '@stdlib/number-float64-base-to-float16';\nimport toWord from '@stdlib/number-float16-base-to-word';\n\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @returns {Array} output array\n*/\nfunction fromIterator( it ) {\n\tvar out;\n\tvar v;\n\n\tout = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tout.push( toWord( f16( v.value ) ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIterator;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this, stdlib/jsdoc-typedef-typos, max-lines */\n\n'use strict';\n\n// MODULES //\n\nimport hasIteratorSymbolSupport from '@stdlib/assert-has-iterator-symbol-support';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport { primitives as isStringArray } from '@stdlib/assert-is-string-array';\nimport isCollection from '@stdlib/assert-is-collection';\nimport isArrayBuffer from '@stdlib/assert-is-arraybuffer';\nimport isFunction from '@stdlib/assert-is-function';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport { isPrimitive as isString } from '@stdlib/assert-is-string';\nimport isObject from '@stdlib/assert-is-object';\nimport isnan from '@stdlib/math-base-assert-is-nan';\nimport ITERATOR_SYMBOL from '@stdlib/symbol-iterator';\nimport setReadOnlyAccessor from '@stdlib/utils-define-nonenumerable-read-only-accessor';\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport setReadWriteAccessor from '@stdlib/utils-define-read-write-accessor';\nimport floor from '@stdlib/math-base-special-floor';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport Uint16Array from '@stdlib/array-uint16';\nimport f16 from '@stdlib/number-float64-base-to-float16';\nimport toWord from '@stdlib/number-float16-base-to-word';\nimport fromWord from '@stdlib/number-float16-base-from-word';\nimport gcopy from '@stdlib/blas-base-gcopy';\nimport fromArray from './from_array.js';\nimport fromIterator from './from_iterator.js';\nimport fromIteratorMap from './from_iterator_map.js';\n\n\n// VARIABLES //\n\nvar BYTES_PER_ELEMENT = Uint16Array.BYTES_PER_ELEMENT;\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\n\n\n// FUNCTIONS //\n\n/**\n* Returns a boolean indicating if a value is a `Float16Array`.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `Float16Array`\n*/\nfunction isFloat16Array( value ) {\n\treturn (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\tvalue.constructor.name === 'Float16Array' &&\n\t\tvalue.BYTES_PER_ELEMENT === BYTES_PER_ELEMENT\n\t);\n}\n\n/**\n* Returns a boolean indicating if a value is a floating-point typed array constructor.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a floating-point typed array constructor\n*/\nfunction isFloatingPointArrayConstructor( value ) { // eslint-disable-line id-length\n\treturn ( value === Float16Array );\n}\n\n/**\n* Returns a getter.\n*\n* @private\n* @param {Float16Array} ctx - typed array instance\n* @param {NonNegativeInteger} idx - element index\n* @returns {Function} getter\n*/\nfunction getter( ctx, idx ) {\n\treturn get;\n\n\t/**\n\t* Returns an array element.\n\t*\n\t* @private\n\t* @returns {(number|void)} array element\n\t*/\n\tfunction get() {\n\t\treturn ctx._get( idx ); // eslint-disable-line no-underscore-dangle\n\t}\n}\n\n/**\n* Returns a setter.\n*\n* @private\n* @param {Float16Array} ctx - typed array instance\n* @param {NonNegativeInteger} idx - element index\n* @returns {Function} setter\n*/\nfunction setter( ctx, idx ) {\n\treturn set;\n\n\t/**\n\t* Sets an array element.\n\t*\n\t* @private\n\t* @param {number} value - value to set\n\t*/\n\tfunction set( value ) {\n\t\tctx.set( [ value ], idx );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* 16-bit floating-point number array constructor.\n*\n* @constructor\n* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable\n* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n* @param {NonNegativeInteger} [length] - view length\n* @throws {RangeError} ArrayBuffer byte length must be a multiple of `2`\n* @throws {TypeError} if provided only a single argument, must provide a valid argument\n* @throws {TypeError} byte offset must be a nonnegative integer\n* @throws {RangeError} byte offset must be a multiple of `2`\n* @throws {TypeError} view length must be a positive multiple of `2`\n* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n* @returns {Float16Array} half-precision floating-point number array\n*\n* @example\n* var arr = new Float16Array();\n* // returns \n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var arr = new Float16Array( 5 );\n* // returns \n*\n* var len = arr.length;\n* // returns 5\n*\n* @example\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 5\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float16Array( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 8\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float16Array( buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 4\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Float16Array( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nfunction Float16Array() {\n\tvar byteOffset;\n\tvar nargs;\n\tvar buf;\n\tvar len;\n\tvar arg;\n\tvar i;\n\n\tnargs = arguments.length;\n\tif ( !(this instanceof Float16Array) ) {\n\t\tif ( nargs === 0 ) {\n\t\t\treturn new Float16Array();\n\t\t}\n\t\tif ( nargs === 1 ) {\n\t\t\treturn new Float16Array( arguments[0] );\n\t\t}\n\t\tif ( nargs === 2 ) {\n\t\t\treturn new Float16Array( arguments[0], arguments[1] );\n\t\t}\n\t\treturn new Float16Array( arguments[0], arguments[1], arguments[2] );\n\t}\n\t// Create the underlying data buffer...\n\tif ( nargs === 0 ) {\n\t\tbuf = new Uint16Array( 0 ); // backward-compatibility\n\t} else if ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\t\tif ( isNonNegativeInteger( arg ) ) {\n\t\t\tbuf = new Uint16Array( arg );\n\t\t} else if ( isCollection( arg ) ) {\n\t\t\tif ( isFloat16Array( arg ) ) {\n\t\t\t\tbuf = new Uint16Array( arg.length );\n\t\t\t\tgcopy.ndarray( arg.length, new Uint16Array( arg.buffer, arg.byteOffset, arg.length ), 1, 0, buf, 1, 0 ); // eslint-disable-line max-len\n\t\t\t} else {\n\t\t\t\tbuf = fromArray( new Uint16Array( arg.length ), arg );\n\t\t\t}\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tif ( !isInteger( arg.byteLength/BYTES_PER_ELEMENT ) ) {\n\t\t\t\tthrow new RangeError( format( 'nullE9', BYTES_PER_ELEMENT, arg.byteLength ) );\n\t\t\t}\n\t\t\tbuf = new Uint16Array( arg );\n\t\t} else if ( isObject( arg ) ) {\n\t\t\tif ( HAS_ITERATOR_SYMBOL === false ) {\n\t\t\t\tthrow new TypeError( format( 'null29', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2A', arg ) );\n\t\t\t}\n\t\t\tbuf = arg[ ITERATOR_SYMBOL ]();\n\t\t\tif ( !isFunction( buf.next ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2A', arg ) );\n\t\t\t}\n\t\t\tbuf = new Uint16Array( fromIterator( buf ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( 'null2A', arg ) );\n\t\t}\n\t} else {\n\t\tbuf = arguments[ 0 ];\n\t\tif ( !isArrayBuffer( buf ) ) {\n\t\t\tthrow new TypeError( format( 'null2B', buf ) );\n\t\t}\n\t\tbyteOffset = arguments[ 1 ];\n\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\tthrow new TypeError( format( 'null2C', byteOffset ) );\n\t\t}\n\t\tif ( !isInteger( byteOffset/BYTES_PER_ELEMENT ) ) {\n\t\t\tthrow new RangeError( format( 'nullEA', BYTES_PER_ELEMENT, byteOffset ) );\n\t\t}\n\t\tif ( nargs === 2 ) {\n\t\t\tlen = buf.byteLength - byteOffset;\n\t\t\tif ( !isInteger( len/BYTES_PER_ELEMENT ) ) {\n\t\t\t\tthrow new RangeError( format( 'null2E', BYTES_PER_ELEMENT, len ) );\n\t\t\t}\n\t\t\tbuf = new Uint16Array( buf, byteOffset );\n\t\t} else {\n\t\t\tlen = arguments[ 2 ];\n\t\t\tif ( !isNonNegativeInteger( len ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2F', len ) );\n\t\t\t}\n\t\t\tif ( (len*BYTES_PER_ELEMENT) > (buf.byteLength-byteOffset) ) {\n\t\t\t\tthrow new RangeError( format( 'null2G', len*BYTES_PER_ELEMENT ) );\n\t\t\t}\n\t\t\tbuf = new Uint16Array( buf, byteOffset, len );\n\t\t}\n\t}\n\tsetReadOnly( this, '_buffer', buf );\n\tsetReadOnly( this, '_length', buf.length );\n\tfor ( i = 0; i < buf.length; i++ ) {\n\t\tsetReadWriteAccessor( this, i, getter( this, i ), setter( this, i ) );\n\t}\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each array element.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Float16Array\n* @readonly\n* @type {PositiveInteger}\n* @default 2\n*\n* @example\n* var nbytes = Float16Array.BYTES_PER_ELEMENT;\n* // returns 2\n*/\nsetReadOnly( Float16Array, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT );\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof Float16Array\n* @readonly\n* @type {string}\n* @default 'Float16Array'\n*\n* @example\n* var str = Float16Array.name;\n* // returns 'Float16Array'\n*/\nsetReadOnly( Float16Array, 'name', 'Float16Array' );\n\n/**\n* Creates a new 16-bit floating-point number array from an array-like object or an iterable.\n*\n* @name from\n* @memberof Float16Array\n* @type {Function}\n* @param {(Collection|Iterable)} src - array-like object or iterable\n* @param {Function} [clbk] - callback to invoke for each source element\n* @param {*} [thisArg] - context\n* @throws {TypeError} `this` context must be a constructor\n* @throws {TypeError} `this` must be a floating-point array\n* @throws {TypeError} first argument must be an array-like object or an iterable\n* @throws {TypeError} second argument must be a function\n* @returns {Float16Array} half-precision floating-point number array\n*\n* @example\n* var arr = Float16Array.from( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* function clbk( v ) {\n* return v * 2.0;\n* }\n*\n* var arr = Float16Array.from( [ 1.0, 2.0 ], clbk );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nsetReadOnly( Float16Array, 'from', function from( src ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar clbk;\n\tvar out;\n\tvar buf;\n\tvar tmp;\n\tvar len;\n\tvar i;\n\tif ( !isFunction( this ) ) {\n\t\tthrow new TypeError( format('null01') );\n\t}\n\tif ( !isFloatingPointArrayConstructor( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs > 1 ) {\n\t\tclbk = arguments[ 1 ];\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'null2H', clbk ) );\n\t\t}\n\t\tif ( nargs > 2 ) {\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( isCollection( src ) ) {\n\t\tif ( clbk ) {\n\t\t\tlen = src.length;\n\t\t\tout = new this( len );\n\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tbuf[ i ] = toWord( f16( clbk.call( thisArg, src[ i ], i ) ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\treturn new this( src );\n\t}\n\tif ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) { // eslint-disable-line max-len\n\t\tbuf = src[ ITERATOR_SYMBOL ]();\n\t\tif ( !isFunction( buf.next ) ) {\n\t\t\tthrow new TypeError( format( 'null2J', src ) );\n\t\t}\n\t\tif ( clbk ) {\n\t\t\ttmp = fromIteratorMap( buf, clbk, thisArg );\n\t\t} else {\n\t\t\ttmp = fromIterator( buf );\n\t\t}\n\t\tif ( tmp instanceof Error ) {\n\t\t\tthrow tmp;\n\t\t}\n\t\tlen = tmp.length;\n\t\tout = new this( len );\n\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tbuf[ i ] = tmp[ i ];\n\t\t}\n\t\treturn out;\n\t}\n\tthrow new TypeError( format( 'null2J', src ) );\n});\n\n/**\n* Creates a new 16-bit floating-point number array from a variable number of arguments.\n*\n* @name of\n* @memberof Float16Array\n* @type {Function}\n* @param {...*} element - array elements\n* @throws {TypeError} `this` context must be a constructor\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Float16Array} half-precision floating-point number array\n*\n* @example\n* var arr = Float16Array.of( 1.0, 1.0, 1.0, 1.0 );\n* // returns \n*\n* var x = arr[ 0 ];\n* // returns 1.0\n*\n* var len = arr.length;\n* // returns 4\n*/\nsetReadOnly( Float16Array, 'of', function of() {\n\tvar args;\n\tvar i;\n\tif ( !isFunction( this ) ) {\n\t\tthrow new TypeError( format('null01') );\n\t}\n\tif ( !isFloatingPointArrayConstructor( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\targs = [];\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\targs.push( arguments[ i ] );\n\t}\n\treturn new this( args );\n});\n\n/**\n* Returns an array element with support for both nonnegative and negative integer indices.\n*\n* @name at\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} must provide an integer\n* @returns {(number|void)} array element\n*\n* @example\n* var arr = new Float16Array( [ 10.0, 20.0, 30.0 ] );\n*\n* var v = arr.at( 0 );\n* // returns 10.0\n*\n* v = arr.at( -1 );\n* // returns 30.0\n*\n* v = arr.at( 100 );\n* // returns undefined\n*/\nsetReadOnly( Float16Array.prototype, 'at', function at( idx ) {\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'null8A', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += this._length;\n\t}\n\tif ( idx < 0 || idx >= this._length ) {\n\t\treturn;\n\t}\n\treturn fromWord( this._buffer[ idx ] );\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name buffer\n* @memberof Float16Array.prototype\n* @readonly\n* @type {ArrayBuffer}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var buf = arr.buffer;\n* // returns \n*/\nsetReadOnlyAccessor( Float16Array.prototype, 'buffer', function get() {\n\treturn this._buffer.buffer;\n});\n\n/**\n* Size (in bytes) of the array.\n*\n* @name byteLength\n* @memberof Float16Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var byteLength = arr.byteLength;\n* // returns 20\n*/\nsetReadOnlyAccessor( Float16Array.prototype, 'byteLength', function get() {\n\treturn this._buffer.byteLength;\n});\n\n/**\n* Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`.\n*\n* @name byteOffset\n* @memberof Float16Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var byteOffset = arr.byteOffset;\n* // returns 0\n*/\nsetReadOnlyAccessor( Float16Array.prototype, 'byteOffset', function get() {\n\treturn this._buffer.byteOffset;\n});\n\n/**\n* Size (in bytes) of each array element.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Float16Array.prototype\n* @readonly\n* @type {PositiveInteger}\n* @default 2\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var nbytes = arr.BYTES_PER_ELEMENT;\n* // returns 2\n*/\nsetReadOnly( Float16Array.prototype, 'BYTES_PER_ELEMENT', Float16Array.BYTES_PER_ELEMENT );\n\n/**\n* Copies a sequence of elements within the array to the position starting at `target`.\n*\n* @name copyWithin\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} target - index at which to start copying elements\n* @param {integer} start - source index at which to copy elements from\n* @param {integer} [end] - source index at which to stop copying elements from\n* @throws {TypeError} `this` must be a floating-point array\n* @returns {Float16Array} modified array\n*\n* @example\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0 ] );\n*\n* // Copy the first two elements to the last two elements:\n* arr.copyWithin( 2, 0, 2 );\n*\n* var v = arr[ 2 ];\n* // returns 1.0\n*\n* v = arr[ 3 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'copyWithin', function copyWithin( target, start ) {\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\t// FIXME: prefer a functional `copyWithin` implementation which addresses lack of universal browser support (e.g., IE11 and Safari) or ensure that typed arrays are polyfilled\n\tif ( arguments.length === 2 ) {\n\t\tthis._buffer.copyWithin( target, start );\n\t} else {\n\t\tthis._buffer.copyWithin( target, start, arguments[2] );\n\t}\n\treturn this;\n});\n\n/**\n* Returns an iterator for iterating over array key-value pairs.\n*\n* @name entries\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] );\n*\n* var it = arr.entries();\n*\n* var v = it.next().value;\n* // returns [ 0, 1.0 ]\n*\n* v = it.next().value;\n* // returns [ 1, 2.0 ]\n*\n* v = it.next().value;\n* // returns [ 2, 3.0 ]\n*\n* var bool = it.next().done;\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'entries', function entries() {\n\tvar self;\n\tvar iter;\n\tvar len;\n\tvar buf;\n\tvar FLG;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tself = this;\n\tbuf = this._buffer;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': [ i, fromWord( buf[ i ] ) ],\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.entries();\n\t}\n});\n\n/**\n* Tests whether all elements in an array pass a test implemented by a predicate function.\n*\n* @name every\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {boolean} boolean indicating whether all elements pass a test\n*\n* @example\n* function predicate( v ) {\n* return v === 0.0;\n* }\n*\n* var arr = new Float16Array( 3 );\n*\n* var bool = arr.every( predicate );\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'every', function every( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( !predicate.call( thisArg, fromWord( buf[ i ] ), i, this ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n});\n\n/**\n* Returns a modified typed array filled with a fill value.\n*\n* @name fill\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {number} value - fill value\n* @param {integer} [start=0] - starting index (inclusive)\n* @param {integer} [end] - ending index (exclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a floating-point number\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be an integer\n* @returns {Float16Array} modified array\n*\n* @example\n* var arr = new Float16Array( 3 );\n*\n* arr.fill( 1.0, 1 );\n*\n* var v = arr[ 0 ];\n* // returns 0.0\n*\n* v = arr[ 1 ];\n* // returns 1.0\n*\n* v = arr[ 2 ];\n* // returns 1.0\n*/\nsetReadOnly( Float16Array.prototype, 'fill', function fill( value, start, end ) {\n\tvar buf;\n\tvar len;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNumber( value ) ) {\n\t\tthrow new TypeError( format( 'null49', value ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( start ) ) {\n\t\t\tthrow new TypeError( format( 'null7f', start ) );\n\t\t}\n\t\tif ( start < 0 ) {\n\t\t\tstart += len;\n\t\t\tif ( start < 0 ) {\n\t\t\t\tstart = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length > 2 ) {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'null2z', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t} else {\n\t\t\tend = len;\n\t\t}\n\t} else {\n\t\tstart = 0;\n\t\tend = len;\n\t}\n\tv = toWord( value );\n\tfor ( i = start; i < end; i++ ) {\n\t\tbuf[ i ] = v;\n\t}\n\treturn this;\n});\n\n/**\n* Returns a new array containing the elements of an array which pass a test implemented by a predicate function.\n*\n* @name filter\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {Float16Array} floating-point number array\n*\n* @example\n* function predicate( v ) {\n* return ( v === 0.0 );\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] );\n*\n* var out = arr.filter( predicate );\n* // returns \n*\n* var len = out.length;\n* // returns 2\n*\n* var v = out[ 0 ];\n* // returns 0.0\n*\n* v = out[ 1 ];\n* // returns 0.0\n*/\nsetReadOnly( Float16Array.prototype, 'filter', function filter( predicate, thisArg ) {\n\tvar buf;\n\tvar out;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\tout.push( v );\n\t\t}\n\t}\n\treturn new this.constructor( out );\n});\n\n/**\n* Returns the first element in an array for which a predicate function returns a truthy value.\n*\n* @name find\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {(boolean|void)} array element or undefined\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] );\n*\n* var v = arr.find( predicate );\n* // returns 1.0\n*/\nsetReadOnly( Float16Array.prototype, 'find', function find( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn v;\n\t\t}\n\t}\n});\n\n/**\n* Returns the index of the first element in an array for which a predicate function returns a truthy value.\n*\n* @name findIndex\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {integer} index or -1\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var v = arr.findIndex( predicate );\n* // returns 1\n*/\nsetReadOnly( Float16Array.prototype, 'findIndex', function findIndex( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Returns the last element in an array for which a predicate function returns a truthy value.\n*\n* @name findLast\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {(boolean|void)} array element or undefined\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] );\n*\n* var v = arr.findLast( predicate );\n* // returns 1.0\n*/\nsetReadOnly( Float16Array.prototype, 'findLast', function findLast( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = this._length-1; i >= 0; i-- ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn v;\n\t\t}\n\t}\n});\n\n/**\n* Returns the index of the last element in an array for which a predicate function returns a truthy value.\n*\n* @name findLastIndex\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {integer} index or -1\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] );\n*\n* var v = arr.findLastIndex( predicate );\n* // returns 1\n*/\nsetReadOnly( Float16Array.prototype, 'findLastIndex', function findLastIndex( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = this._length-1; i >= 0; i-- ) {\n\t\tv = fromWord( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Invokes a function once for each array element.\n*\n* @name forEach\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} fcn - function to invoke\n* @param {*} [thisArg] - function invocation context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n*\n* @example\n* function log( v, i ) {\n* console.log( '%s: %s', i, v.toString() );\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* arr.forEach( log );\n*/\nsetReadOnly( Float16Array.prototype, 'forEach', function forEach( fcn, thisArg ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( fcn ) ) {\n\t\tthrow new TypeError( format( 'null3c', fcn ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tfcn.call( thisArg, fromWord( buf[ i ] ), i, this );\n\t}\n});\n\n/**\n* Returns an array element.\n*\n* @private\n* @name _get\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {NonNegativeInteger} idx - element index\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} must provide a nonnegative integer\n* @returns {(number|void)} array element\n*/\nsetReadOnly( Float16Array.prototype, '_get', function get( idx ) {\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNonNegativeInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'null2K', idx ) );\n\t}\n\tif ( idx >= this._length ) {\n\t\treturn;\n\t}\n\treturn fromWord( this._buffer[ idx ] );\n});\n\n/**\n* Returns a boolean indicating whether an array includes a provided value.\n*\n* @name includes\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {number} searchElement - search element\n* @param {integer} [fromIndex=0] - starting index (inclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a floating-point number\n* @throws {TypeError} second argument must be an integer\n* @returns {boolean} boolean indicating whether an array includes a value\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] );\n*\n* var bool = arr.includes( 1.0 );\n* // returns true\n*\n* bool = arr.includes( 1.0, 2 );\n* // returns false\n*\n* bool = arr.includes( 5.0 );\n* // returns false\n*/\nsetReadOnly( Float16Array.prototype, 'includes', function includes( searchElement, fromIndex ) {\n\tvar buf;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNumber( searchElement ) ) {\n\t\tthrow new TypeError( format( 'null49', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'null7f', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\tfromIndex = 0;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfromIndex = 0;\n\t}\n\tbuf = this._buffer;\n\tv = toWord( searchElement );\n\tfor ( i = fromIndex; i < this._length; i++ ) {\n\t\tif ( v === buf[ i ] ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n});\n\n/**\n* Returns the first index at which a given element can be found.\n*\n* @name indexOf\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {float16} searchElement - element to find\n* @param {integer} [fromIndex=0] - starting index (inclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a floating-point number\n* @throws {TypeError} second argument must be an integer\n* @returns {integer} index or -1\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] );\n*\n* var idx = arr.indexOf( 2.0 );\n* // returns 2\n*\n* idx = arr.indexOf( 2.0, 3 );\n* // returns -1\n*\n* idx = arr.indexOf( 3.0, 3 );\n* // returns 3\n*/\nsetReadOnly( Float16Array.prototype, 'indexOf', function indexOf( searchElement, fromIndex ) {\n\tvar buf;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNumber( searchElement ) ) {\n\t\tthrow new TypeError( format( 'null49', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'null7f', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\tfromIndex = 0;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfromIndex = 0;\n\t}\n\tbuf = this._buffer;\n\tv = toWord( searchElement );\n\tfor ( i = fromIndex; i < this._length; i++ ) {\n\t\tif ( v === buf[ i ] ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Returns a new string by concatenating all array elements.\n*\n* @name join\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {string} [separator=','] - element separator\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a string\n* @returns {string} string representation\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var str = arr.join();\n* // returns '0,1,2'\n*\n* str = arr.join( '|' );\n* // returns '0|1|2'\n*/\nsetReadOnly( Float16Array.prototype, 'join', function join( separator ) {\n\tvar buf;\n\tvar out;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( arguments.length > 0 ) {\n\t\tif ( !isString( separator ) ) {\n\t\t\tthrow new TypeError( format( 'null3F', separator ) );\n\t\t}\n\t} else {\n\t\tseparator = ',';\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( fromWord( buf[ i ] ) );\n\t}\n\treturn out.join( separator );\n});\n\n/**\n* Returns an iterator for iterating over each index key in a typed array.\n*\n* @name keys\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new Float16Array( [ 1.0, 2.0 ] );\n*\n* var iter = arr.keys();\n*\n* var v = iter.next().value;\n* // returns 0\n*\n* v = iter.next().value;\n* // returns 1\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'keys', function keys() {\n\tvar self;\n\tvar iter;\n\tvar len;\n\tvar FLG;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tself = this;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': i,\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.keys();\n\t}\n});\n\n/**\n* Returns the last index at which a given element can be found.\n*\n* @name lastIndexOf\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {number} searchElement - element to find\n* @param {integer} [fromIndex] - starting index (inclusive)\n* @throws {TypeError} `this` must be a floating-point number\n* @throws {TypeError} first argument must be a numeric value\n* @throws {TypeError} second argument must be an integer\n* @returns {integer} index or -1\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 2.0 ] );\n*\n* var idx = arr.lastIndexOf( 2.0 );\n* // returns 4\n*\n* idx = arr.lastIndexOf( 2.0, 3 );\n* // returns 2\n*\n* idx = arr.lastIndexOf( 4.0, 3 );\n* // returns -1\n*\n* idx = arr.lastIndexOf( 1.0, -3 );\n* // returns 1\n*/\nsetReadOnly( Float16Array.prototype, 'lastIndexOf', function lastIndexOf( searchElement, fromIndex ) {\n\tvar buf;\n\tvar i;\n\tvar v;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isNumber( searchElement ) ) {\n\t\tthrow new TypeError( format( 'null49', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'null7f', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex >= this._length ) {\n\t\t\tfromIndex = this._length - 1;\n\t\t} else if ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t}\n\t} else {\n\t\tfromIndex = this._length - 1;\n\t}\n\tbuf = this._buffer;\n\tv = toWord( searchElement );\n\tfor ( i = fromIndex; i >= 0; i-- ) {\n\t\tif ( v === buf[ i ] ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Number of array elements.\n*\n* @name length\n* @memberof Float16Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var len = arr.length;\n* // returns 10\n*/\nsetReadOnlyAccessor( Float16Array.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Returns a new array with each element being the result of a provided callback function.\n*\n* @name map\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} fcn - callback function\n* @param {*} [thisArg] - callback function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {Float16Array} new floating-point number array\n*\n* @example\n* function scale( v ) {\n* return v * 2.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var out = arr.map( scale );\n* // returns \n*\n* var z = out[ 0 ];\n* // returns 0.0\n*\n* z = out[ 1 ];\n* // returns 2.0\n*\n* z = out[ 2 ];\n* // returns 4.0\n*/\nsetReadOnly( Float16Array.prototype, 'map', function map( fcn, thisArg ) {\n\tvar outbuf;\n\tvar out;\n\tvar buf;\n\tvar i;\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( fcn ) ) {\n\t\tthrow new TypeError( format('null3c'), fcn );\n\t}\n\tbuf = this._buffer;\n\tout = new this.constructor( this._length );\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\toutbuf[ i ] = toWord( fcn.call( thisArg, fromWord( buf[ i ] ), i, this ) ); // eslint-disable-line max-len\n\t}\n\treturn out;\n});\n\n/**\n* Applies a provided callback function to each element of the array, in order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion.\n*\n* @name reduce\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} reducer - callback function\n* @param {*} [initialValue] - initial value\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {Error} if not provided an initial value, the array must have at least one element\n* @returns {*} accumulated result\n*\n* @example\n* function add( acc, v ) {\n* return acc + v;\n* }\n*\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] );\n*\n* var out = arr.reduce( add, 0 );\n* // returns 6.0\n*/\nsetReadOnly( Float16Array.prototype, 'reduce', function reduce( reducer, initialValue ) {\n\tvar buf;\n\tvar len;\n\tvar acc;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( reducer ) ) {\n\t\tthrow new TypeError( format( 'null3c', reducer ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tacc = initialValue;\n\t\ti = 0;\n\t} else {\n\t\tif ( len === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' );\n\t\t}\n\t\tacc = fromWord( buf[ 0 ] );\n\t\ti = 1;\n\t}\n\tfor ( ; i < len; i++ ) {\n\t\tacc = reducer( acc, fromWord( buf[ i ] ), i, this );\n\t}\n\treturn acc;\n});\n\n/**\n* Applies a provided callback function to each element of the array, in reverse order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion.\n*\n* @name reduceRight\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} reducer - callback function\n* @param {*} [initialValue] - initial value\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {Error} if not provided an initial value, the array must have at least one element\n* @returns {*} accumulated result\n*\n* @example\n* function add( acc, v ) {\n* return acc + v;\n* }\n*\n* var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] );\n*\n* var out = arr.reduceRight( add, 0 );\n* // returns 6.0\n*/\nsetReadOnly( Float16Array.prototype, 'reduceRight', function reduceRight( reducer, initialValue ) {\n\tvar buf;\n\tvar len;\n\tvar acc;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( reducer ) ) {\n\t\tthrow new TypeError( format( 'null3c', reducer ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tacc = initialValue;\n\t\ti = len - 1;\n\t} else {\n\t\tif ( len === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' );\n\t\t}\n\t\tacc = fromWord( buf[ len-1 ] );\n\t\ti = len - 2;\n\t}\n\tfor ( ; i >= 0; i-- ) {\n\t\tacc = reducer( acc, fromWord( buf[ i ] ), i, this );\n\t}\n\treturn acc;\n});\n\n/**\n* Reverses an array in-place.\n*\n* @name reverse\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Float16Array} reversed array\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var out = arr.reverse();\n* // returns \n*\n* var v = out[ 0 ];\n* // returns 2.0\n*\n* v = out[ 1 ];\n* // returns 1.0\n*\n* v = out[ 2 ];\n* // returns 0.0\n*/\nsetReadOnly( Float16Array.prototype, 'reverse', function reverse() {\n\tvar buf;\n\tvar tmp;\n\tvar len;\n\tvar N;\n\tvar i;\n\tvar j;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tN = floor( len / 2 );\n\tfor ( i = 0; i < N; i++ ) {\n\t\tj = len - i - 1;\n\t\ttmp = buf[ i ];\n\t\tbuf[ i ] = buf[ j ];\n\t\tbuf[ j ] = tmp;\n\t}\n\treturn this;\n});\n\n/**\n* Sets one or more array elements.\n*\n* ## Notes\n*\n* - When provided a typed array, we must check whether the source array shares the same buffer as the target array and whether the underlying memory overlaps. In particular, we are concerned with the following scenario:\n*\n* ```text\n* buf: ---------------------\n* src: ---------------------\n* ```\n*\n* In the above, as we copy values from `src`, we will overwrite values in the `src` view, resulting in duplicated values copied into the end of `buf`, which is not intended. Hence, to avoid overwriting source values, we must **copy** source values to a temporary array.\n*\n* In the other overlapping scenario,\n*\n* ```text\n* buf: ---------------------\n* src: ---------------------\n* ```\n*\n* by the time we begin copying into the overlapping region, we are copying from the end of `src`, a non-overlapping region, which means we don't run the risk of copying copied values, rather than the original `src` values, as intended.\n*\n* @name set\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {(Collection|Float16Array)} value - value(s)\n* @param {NonNegativeInteger} [i=0] - element index at which to start writing values\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a collection\n* @throws {TypeError} index argument must be a nonnegative integer\n* @throws {RangeError} index argument is out-of-bounds\n* @throws {RangeError} target array lacks sufficient storage to accommodate source values\n* @returns {void}\n*\n* @example\n* var arr = new Float16Array( 10 );\n*\n* var v = arr[ 0 ];\n* // returns 0.0\n*\n* arr.set( [ 1.0, 2.0 ], 0 );\n*\n* v = arr[ 0 ];\n* // returns 1.0\n*/\nsetReadOnly( Float16Array.prototype, 'set', function set( value ) {\n\tvar sbuf;\n\tvar idx;\n\tvar buf;\n\tvar tmp;\n\tvar flg;\n\tvar N;\n\tvar i;\n\tvar j;\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isCollection( value ) ) {\n\t\tthrow new TypeError( format( 'null2O', value ) );\n\t}\n\tbuf = this._buffer;\n\tif ( arguments.length > 1 ) {\n\t\tidx = arguments[ 1 ];\n\t\tif ( !isNonNegativeInteger( idx ) ) {\n\t\t\tthrow new TypeError( format( 'null2L', idx ) );\n\t\t}\n\t} else {\n\t\tidx = 0;\n\t}\n\tN = value.length;\n\tif ( idx+N > this._length ) {\n\t\tthrow new RangeError( format('null03') );\n\t}\n\tif ( isFloat16Array( value ) ) {\n\t\tsbuf = value._buffer; // eslint-disable-line no-underscore-dangle\n\t\tflg = true;\n\t} else {\n\t\tsbuf = value;\n\t\tflg = false;\n\t}\n\t// Check for overlapping memory...\n\tj = buf.byteOffset + (idx*BYTES_PER_ELEMENT);\n\tif (\n\t\tsbuf.buffer === buf.buffer &&\n\t\t(\n\t\t\tsbuf.byteOffset < j &&\n\t\t\tsbuf.byteOffset+sbuf.byteLength > j\n\t\t)\n\t) {\n\t\t// We need to copy source values...\n\t\ttmp = new Uint16Array( sbuf.length );\n\t\tfor ( i = 0; i < sbuf.length; i++ ) {\n\t\t\ttmp[ i ] = sbuf[ i ];\n\t\t}\n\t\tsbuf = tmp;\n\t}\n\tif ( flg ) {\n\t\tfor ( i = 0; i < N; idx++, i++ ) {\n\t\t\tbuf[ idx ] = sbuf[ i ];\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < N; idx++, i++ ) {\n\t\t\tbuf[ idx ] = toWord( sbuf[ i ] );\n\t\t}\n\t}\n});\n\n/**\n* Copies a portion of a typed array to a new typed array.\n*\n* @name slice\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} [begin] - start index (inclusive)\n* @param {integer} [end] - end index (exclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be integer\n* @throws {TypeError} second argument must be integer\n* @returns {Float16Array} floating-point number array\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] );\n*\n* var out = arr.slice();\n* // returns \n*\n* var len = out.length;\n* // returns 5\n*\n* var v = out[ 0 ];\n* // returns 0.0\n*\n* v = out[ len-1 ];\n* // returns 4.0\n*\n* out = arr.slice( 1, -2 );\n* // returns \n*\n* len = out.length;\n* // returns 2\n*\n* v = out[ 0 ];\n* // returns 1.0\n*\n* v = out[ len-1 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'slice', function slice( begin, end ) {\n\tvar outlen;\n\tvar outbuf;\n\tvar out;\n\tvar buf;\n\tvar len;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length === 0 ) {\n\t\tbegin = 0;\n\t\tend = len;\n\t} else {\n\t\tif ( !isInteger( begin ) ) {\n\t\t\tthrow new TypeError( format( 'null7e', begin ) );\n\t\t}\n\t\tif ( begin < 0 ) {\n\t\t\tbegin += len;\n\t\t\tif ( begin < 0 ) {\n\t\t\t\tbegin = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\tend = len;\n\t\t} else {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'null7f', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t} else if ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t}\n\t}\n\tif ( begin < end ) {\n\t\toutlen = end - begin;\n\t} else {\n\t\toutlen = 0;\n\t}\n\tout = new this.constructor( outlen );\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < outlen; i++ ) {\n\t\toutbuf[ i ] = buf[ i+begin ];\n\t}\n\treturn out;\n});\n\n/**\n* Tests whether at least one element in an array passes a test implemented by a predicate function.\n*\n* @name some\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {boolean} boolean indicating whether at least one element passes a test\n*\n* @example\n* function predicate( v ) {\n* return v > 0.0;\n* }\n*\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var bool = arr.some( predicate );\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'some', function some( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'null3c', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( predicate.call( thisArg, fromWord( buf[ i ] ), i, this ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n});\n\n/**\n* Sorts an array in-place.\n*\n* @name sort\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} [compareFcn] - comparison function\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {Float16Array} sorted array\n*\n* @example\n* function compare( a, b ) {\n* if ( a < b ) {\n* return -1;\n* }\n* if ( a > b ) {\n* return 1;\n* }\n* return 0;\n* }\n*\n* var arr = new Float16Array( [ 1.0, 0.0, 2.0 ] );\n*\n* arr.sort( compare );\n*\n* var v = arr[ 0 ];\n* // returns 0.0\n*\n* v = arr[ 1 ];\n* // returns 1.0\n*\n* v = arr[ 2 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'sort', function sort( compareFcn ) {\n\tvar buf;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tif ( arguments.length === 0 ) {\n\t\tbuf.sort( defaultCompare );\n\t\treturn this;\n\t}\n\tif ( !isFunction( compareFcn ) ) {\n\t\tthrow new TypeError( format( 'null3c', compareFcn ) );\n\t}\n\tbuf.sort( compare );\n\treturn this;\n\n\t/**\n\t* Default comparison function for float16 values.\n\t*\n\t* @private\n\t* @param {unsigned16} a - unsigned 16-bit integer for comparison\n\t* @param {unsigned16} b - unsigned 16-bit integer for comparison\n\t* @returns {number} comparison result\n\t*/\n\tfunction defaultCompare( a, b ) { // eslint-disable-line stdlib/no-unnecessary-nested-functions\n\t\tvar x = fromWord( a );\n\t\tvar y = fromWord( b );\n\n\t\t// Handle NaN...\n\t\tif ( isnan( x ) && isnan( y ) ) {\n\t\t\treturn 0;\n\t\t}\n\t\tif ( isnan( x ) ) {\n\t\t\treturn 1;\n\t\t}\n\t\tif ( isnan( y ) ) {\n\t\t\treturn -1;\n\t\t}\n\t\t// Normal comparison\n\t\tif ( x < y ) {\n\t\t\treturn -1;\n\t\t}\n\t\tif ( x > y ) {\n\t\t\treturn 1;\n\t\t}\n\t\treturn 0;\n\t}\n\n\t/**\n\t* Comparison function wrapper.\n\t*\n\t* @private\n\t* @param {unsigned16} a - unsigned 16-bit integer for comparison\n\t* @param {unsigned16} b - unsigned 16-bit integer for comparison\n\t* @returns {number} comparison result\n\t*/\n\tfunction compare( a, b ) {\n\t\treturn compareFcn( fromWord( a ), fromWord( b ) );\n\t}\n});\n\n/**\n* Creates a new typed array view over the same underlying `ArrayBuffer` and with the same underlying data type as the host array.\n*\n* @name subarray\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} [begin] - start index (inclusive)\n* @param {integer} [end] - end index (exclusive)\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be an integer\n* @throws {TypeError} second argument must be an integer\n* @returns {Float16Array} subarray\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] );\n*\n* var subarr = arr.subarray();\n* // returns \n*\n* var len = subarr.length;\n* // returns 5\n*\n* var bool = subarr[ 0 ];\n* // returns 0.0\n*\n* bool = subarr[ len-1 ];\n* // returns 4.0\n*\n* subarr = arr.subarray( 1, -2 );\n* // returns \n*\n* len = subarr.length;\n* // returns 2\n*\n* bool = subarr[ 0 ];\n* // returns 1.0\n*\n* bool = subarr[ len-1 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'subarray', function subarray( begin, end ) {\n\tvar offset;\n\tvar buf;\n\tvar len;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length === 0 ) {\n\t\tbegin = 0;\n\t\tend = len;\n\t} else {\n\t\tif ( !isInteger( begin ) ) {\n\t\t\tthrow new TypeError( format( 'null7e', begin ) );\n\t\t}\n\t\tif ( begin < 0 ) {\n\t\t\tbegin += len;\n\t\t\tif ( begin < 0 ) {\n\t\t\t\tbegin = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\tend = len;\n\t\t} else {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'null7f', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t} else if ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t}\n\t}\n\tif ( begin >= len ) {\n\t\tlen = 0;\n\t\toffset = buf.byteLength;\n\t} else if ( begin >= end ) {\n\t\tlen = 0;\n\t\toffset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT );\n\t} else {\n\t\tlen = end - begin;\n\t\toffset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT );\n\t}\n\treturn new this.constructor( buf.buffer, offset, ( len < 0 ) ? 0 : len );\n});\n\n/**\n* Serializes an array as a locale-specific string.\n*\n* @name toLocaleString\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {(string|Array)} [locales] - locale identifier(s)\n* @param {Object} [options] - configuration options\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a string or an array of strings\n* @throws {TypeError} options argument must be an object\n* @returns {string} string representation\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var str = arr.toLocaleString();\n* // returns '0,1,2'\n*/\nsetReadOnly( Float16Array.prototype, 'toLocaleString', function toLocaleString( locales, options ) {\n\tvar opts;\n\tvar loc;\n\tvar out;\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( arguments.length === 0 ) {\n\t\tloc = [];\n\t} else if ( isString( locales ) || isStringArray( locales ) ) {\n\t\tloc = locales;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a string or an array of strings. Value: `%s`.', locales ) );\n\t}\n\tif ( arguments.length < 2 ) {\n\t\topts = {};\n\t} else if ( isObject( options ) ) {\n\t\topts = options;\n\t} else {\n\t\tthrow new TypeError( format( 'null2V', options ) );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( fromWord( buf[ i ] ) );\n\t}\n\treturn out.toLocaleString( loc, opts );\n});\n\n/**\n* Returns a new typed array containing the elements in reversed order.\n*\n* @name toReversed\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Float16Array} reversed array\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var out = arr.toReversed();\n* // returns \n*\n* var v = out[ 0 ];\n* // returns 2.0\n*\n* v = out[ 1 ];\n* // returns 1.0\n*\n* v = out[ 2 ];\n* // returns 0.0\n*/\nsetReadOnly( Float16Array.prototype, 'toReversed', function toReversed() {\n\tvar outbuf;\n\tvar out;\n\tvar len;\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tlen = this._length;\n\tout = new this.constructor( len );\n\tbuf = this._buffer;\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < len; i++ ) {\n\t\toutbuf[ i ] = buf[ len - i - 1 ];\n\t}\n\treturn out;\n});\n\n/**\n* Returns a new typed array containing the elements in sorted order.\n*\n* @name toSorted\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {Function} [compareFcn] - comparison function\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be a function\n* @returns {Float16Array} sorted array\n*\n* @example\n* function compare( a, b ) {\n* if ( a > b ) {\n* return 1;\n* }\n* if ( a < b ) {\n* return -1;\n* }\n* return 0;\n* }\n*\n* var arr = new Float16Array( [ 2.0, 0.0, 1.0 ] );\n*\n* var out = arr.toSorted( compare );\n* // returns \n*\n* var v = out[ 0 ];\n* // returns 0.0\n*\n* v = out[ 1 ];\n* // returns 1.0\n*\n* v = out[ 2 ];\n* // returns 2.0\n*/\nsetReadOnly( Float16Array.prototype, 'toSorted', function toSorted( compareFcn ) {\n\tvar out;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tout = new this.constructor( this );\n\tif ( arguments.length === 0 ) {\n\t\treturn out.sort();\n\t}\n\treturn out.sort( compareFcn );\n});\n\n/**\n* Serializes an array as a string.\n*\n* @name toString\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {string} string representation\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var str = arr.toString();\n* // returns '0,1,2'\n*/\nsetReadOnly( Float16Array.prototype, 'toString', function toString() {\n\tvar out;\n\tvar buf;\n\tvar i;\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( fromWord( buf[ i ] ) );\n\t}\n\treturn out.join( ',' );\n});\n\n/**\n* Returns an iterator for iterating over each value in a typed array.\n*\n* @name values\n* @memberof Float16Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a floating-point number array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0 ] );\n*\n* var iter = arr.values();\n*\n* var v = iter.next().value;\n* // returns 0.0\n*\n* v = iter.next().value;\n* // returns 1.0\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nsetReadOnly( Float16Array.prototype, 'values', function values() {\n\tvar iter;\n\tvar self;\n\tvar len;\n\tvar FLG;\n\tvar buf;\n\tvar i;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tself = this;\n\tbuf = this._buffer;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': fromWord( buf[ i ] ),\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.values();\n\t}\n});\n\n/**\n* Returns a new typed array with the element at a provided index replaced with a provided value.\n*\n* @name with\n* @memberof Float16Array.prototype\n* @type {Function}\n* @param {integer} index - element index\n* @param {number} value - new value\n* @throws {TypeError} `this` must be a floating-point number array\n* @throws {TypeError} first argument must be an integer\n* @throws {RangeError} index argument is out-of-bounds\n* @throws {TypeError} second argument must be a floating-point number\n* @returns {Float16Array} new typed array\n*\n* @example\n* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] );\n*\n* var out = arr.with( 0, 3.0 );\n* // returns \n*\n* var v = out[ 0 ];\n* // returns 3.0\n*/\nsetReadOnly( Float16Array.prototype, 'with', function copyWith( index, value ) {\n\tvar out;\n\tvar len;\n\n\tif ( !isFloat16Array( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a floating-point number array.' );\n\t}\n\tif ( !isInteger( index ) ) {\n\t\tthrow new TypeError( format( 'null7e', index ) );\n\t}\n\tlen = this._length;\n\tif ( index < 0 ) {\n\t\tindex += len;\n\t}\n\tif ( index < 0 || index >= len ) {\n\t\tthrow new RangeError( format( 'nullFP', index ) );\n\t}\n\tif ( !isNumber( value ) ) {\n\t\tthrow new TypeError( format( 'null4A', value ) );\n\t}\n\tout = new this.constructor( this );\n\tout[ index ] = value;\n\treturn out;\n});\n\n\n// EXPORTS //\n\nexport default Float16Array;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport f16 from '@stdlib/number-float64-base-to-float16';\nimport toWord from '@stdlib/number-float16-base-to-word';\n\n\n// MAIN //\n\n/**\n* Fills an output array with unsigned 16-bit integers corresponding to the IEEE 754 binary representation of respective half-precision floating-point numbers.\n*\n* @private\n* @param {Uint16Array} buf - output array\n* @param {Array} arr - input array\n* @returns {Uint16Array} output array\n*/\nfunction fromArray( buf, arr ) {\n\tvar len;\n\tvar i;\n\n\tlen = arr.length;\n\tfor ( i = 0; i < len; i++ ) {\n\t\tbuf[ i ] = toWord( f16( arr[ i ] ) );\n\t}\n\treturn buf;\n}\n\n\n// EXPORTS //\n\nexport default fromArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport f16 from '@stdlib/number-float64-base-to-float16';\nimport toWord from '@stdlib/number-float16-base-to-word';\n\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @param {Function} clbk - callback to invoke for each iterated value\n* @param {*} thisArg - invocation context\n* @returns {Array} output array\n*/\nfunction fromIteratorMap( it, clbk, thisArg ) {\n\tvar out;\n\tvar v;\n\tvar i;\n\n\tout = [];\n\ti = -1;\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\ti += 1;\n\t\tout.push( toWord( f16( clbk.call( thisArg, v.value, i ) ) ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIteratorMap;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Float16Array === 'function' ) ? Float16Array : void 0; // eslint-disable-line no-undef, stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2026 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* 16-bit floating-point number array constructor.\n*\n* @module @stdlib/array-float16\n*\n* @example\n* import Float16Array from '@stdlib/array-float16';\n*\n* var arr = new Float16Array();\n* // returns \n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* import Float16Array from '@stdlib/array-float16';\n*\n* var arr = new Float16Array( 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import Float16Array from '@stdlib/array-float16';\n*\n* var arr = new Float16Array( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n* import Float16Array from '@stdlib/array-float16';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float16Array( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 8\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n* import Float16Array from '@stdlib/array-float16';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float16Array( buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 4\n*\n* @example\n* import ArrayBuffer from '@stdlib/array-buffer';\n* import Float16Array from '@stdlib/array-float16';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Float16Array( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\n\n// MODULES //\n\nimport hasFloat16ArraySupport from '@stdlib/assert-has-float16array-support';\nimport polyfill from './polyfill';\nimport builtin from './main.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasFloat16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n"],"names":["fromIterator","it","out","v","next","done","push","toWord","f16","value","BYTES_PER_ELEMENT","Uint16Array","HAS_ITERATOR_SYMBOL","hasIteratorSymbolSupport","isFloat16Array","constructor","name","isFloatingPointArrayConstructor","Float16Array","getter","ctx","idx","_get","setter","set","byteOffset","nargs","buf","len","arg","i","arguments","length","this","isNonNegativeInteger","isCollection","gcopy","ndarray","buffer","arr","fromArray","isArrayBuffer","isInteger","byteLength","RangeError","format","isObject","TypeError","isFunction","ITERATOR_SYMBOL","setReadOnly","setReadWriteAccessor","src","thisArg","clbk","tmp","_buffer","call","fromIteratorMap","Error","args","prototype","_length","fromWord","setReadOnlyAccessor","target","start","copyWithin","self","iter","FLG","entries","predicate","end","isNumber","fcn","searchElement","fromIndex","separator","isString","join","keys","outbuf","reducer","initialValue","acc","N","j","floor","sbuf","flg","begin","outlen","compareFcn","sort","a","b","x","y","isnan","offset","locales","options","opts","loc","isStringArray","toLocaleString","values","index","ctor","ctor$1","hasFloat16ArraySupport","builtin","polyfill"],"mappings":"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"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 662979c..0000000 --- a/lib/index.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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'; - -/** -* 16-bit floating-point number array constructor. -* -* @module @stdlib/array-float16 -* -* @example -* var Float16Array = require( '@stdlib/array-float16' ); -* -* var arr = new Float16Array(); -* // returns -* -* var len = arr.length; -* // returns 0 -* -* @example -* var Float16Array = require( '@stdlib/array-float16' ); -* -* var arr = new Float16Array( 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var Float16Array = require( '@stdlib/array-float16' ); -* -* var arr = new Float16Array( [ 1.0, 2.0 ] ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var Float16Array = require( '@stdlib/array-float16' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float16Array( buf ); -* // returns -* -* var len = arr.length; -* // returns 8 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var Float16Array = require( '@stdlib/array-float16' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float16Array( buf, 8 ); -* // returns -* -* var len = arr.length; -* // returns 4 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* var Float16Array = require( '@stdlib/array-float16' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = new Float16Array( buf, 8, 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -*/ - -// MODULES // - -var hasFloat16ArraySupport = require( '@stdlib/assert-has-float16array-support' ); -var polyfill = require( './polyfill' ); -var builtin = require( './main.js' ); - - -// MAIN // - -var ctor; -if ( hasFloat16ArraySupport() ) { - ctor = builtin; -} else { - ctor = polyfill; -} - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 90c9924..0000000 --- a/lib/main.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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'; - -// MAIN // - -var ctor = ( typeof Float16Array === 'function' ) ? Float16Array : void 0; // eslint-disable-line no-undef, stdlib/require-globals - - -// EXPORTS // - -module.exports = ctor; diff --git a/lib/polyfill/from_array.js b/lib/polyfill/from_array.js deleted file mode 100644 index b5894dc..0000000 --- a/lib/polyfill/from_array.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 f16 = require( '@stdlib/number-float64-base-to-float16' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); - - -// MAIN // - -/** -* Fills an output array with unsigned 16-bit integers corresponding to the IEEE 754 binary representation of respective half-precision floating-point numbers. -* -* @private -* @param {Uint16Array} buf - output array -* @param {Array} arr - input array -* @returns {Uint16Array} output array -*/ -function fromArray( buf, arr ) { - var len; - var i; - - len = arr.length; - for ( i = 0; i < len; i++ ) { - buf[ i ] = toWord( f16( arr[ i ] ) ); - } - return buf; -} - - -// EXPORTS // - -module.exports = fromArray; diff --git a/lib/polyfill/from_iterator.js b/lib/polyfill/from_iterator.js deleted file mode 100644 index 37a2c7c..0000000 --- a/lib/polyfill/from_iterator.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 f16 = require( '@stdlib/number-float64-base-to-float16' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); - - -// MAIN // - -/** -* Returns an array of iterated values. -* -* @private -* @param {Object} it - iterator -* @returns {Array} output array -*/ -function fromIterator( it ) { - var out; - var v; - - out = []; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - out.push( toWord( f16( v.value ) ) ); - } - return out; -} - - -// EXPORTS // - -module.exports = fromIterator; diff --git a/lib/polyfill/from_iterator_map.js b/lib/polyfill/from_iterator_map.js deleted file mode 100644 index 265e59d..0000000 --- a/lib/polyfill/from_iterator_map.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 f16 = require( '@stdlib/number-float64-base-to-float16' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); - - -// MAIN // - -/** -* Returns an array of iterated values. -* -* @private -* @param {Object} it - iterator -* @param {Function} clbk - callback to invoke for each iterated value -* @param {*} thisArg - invocation context -* @returns {Array} output array -*/ -function fromIteratorMap( it, clbk, thisArg ) { - var out; - var v; - var i; - - out = []; - i = -1; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - i += 1; - out.push( toWord( f16( clbk.call( thisArg, v.value, i ) ) ) ); - } - return out; -} - - -// EXPORTS // - -module.exports = fromIteratorMap; diff --git a/lib/polyfill/index.js b/lib/polyfill/index.js deleted file mode 100644 index f4a1a8f..0000000 --- a/lib/polyfill/index.js +++ /dev/null @@ -1,2410 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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. -*/ - -/* eslint-disable no-restricted-syntax, no-invalid-this, stdlib/jsdoc-typedef-typos, max-lines */ - -'use strict'; - -// MODULES // - -var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var isStringArray = require( '@stdlib/assert-is-string-array' ).primitives; -var isCollection = require( '@stdlib/assert-is-collection' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isInteger = require( '@stdlib/assert-is-integer' ).isPrimitive; -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var isObject = require( '@stdlib/assert-is-object' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var setReadOnlyAccessor = require( '@stdlib/utils-define-nonenumerable-read-only-accessor' ); -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var f16 = require( '@stdlib/number-float64-base-to-float16' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var fromWord = require( '@stdlib/number-float16-base-from-word' ); -var gcopy = require( '@stdlib/blas-base-gcopy' ); -var fromArray = require( './from_array.js' ); -var fromIterator = require( './from_iterator.js' ); -var fromIteratorMap = require( './from_iterator_map.js' ); - - -// VARIABLES // - -var BYTES_PER_ELEMENT = Uint16Array.BYTES_PER_ELEMENT; -var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport(); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating if a value is a `Float16Array`. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating if a value is a `Float16Array` -*/ -function isFloat16Array( value ) { - return ( - typeof value === 'object' && - value !== null && - value.constructor.name === 'Float16Array' && - value.BYTES_PER_ELEMENT === BYTES_PER_ELEMENT - ); -} - -/** -* Returns a boolean indicating if a value is a floating-point typed array constructor. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating if a value is a floating-point typed array constructor -*/ -function isFloatingPointArrayConstructor( value ) { // eslint-disable-line id-length - return ( value === Float16Array ); -} - -/** -* Returns a getter. -* -* @private -* @param {Float16Array} ctx - typed array instance -* @param {NonNegativeInteger} idx - element index -* @returns {Function} getter -*/ -function getter( ctx, idx ) { - return get; - - /** - * Returns an array element. - * - * @private - * @returns {(number|void)} array element - */ - function get() { - return ctx._get( idx ); // eslint-disable-line no-underscore-dangle - } -} - -/** -* Returns a setter. -* -* @private -* @param {Float16Array} ctx - typed array instance -* @param {NonNegativeInteger} idx - element index -* @returns {Function} setter -*/ -function setter( ctx, idx ) { - return set; - - /** - * Sets an array element. - * - * @private - * @param {number} value - value to set - */ - function set( value ) { - ctx.set( [ value ], idx ); - } -} - - -// MAIN // - -/** -* 16-bit floating-point number array constructor. -* -* @constructor -* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable -* @param {NonNegativeInteger} [byteOffset=0] - byte offset -* @param {NonNegativeInteger} [length] - view length -* @throws {RangeError} ArrayBuffer byte length must be a multiple of `2` -* @throws {TypeError} if provided only a single argument, must provide a valid argument -* @throws {TypeError} byte offset must be a nonnegative integer -* @throws {RangeError} byte offset must be a multiple of `2` -* @throws {TypeError} view length must be a positive multiple of `2` -* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements -* @returns {Float16Array} half-precision floating-point number array -* -* @example -* var arr = new Float16Array(); -* // returns -* -* var len = arr.length; -* // returns 0 -* -* @example -* var arr = new Float16Array( 5 ); -* // returns -* -* var len = arr.length; -* // returns 5 -* -* @example -* var arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -* // returns -* -* var len = arr.length; -* // returns 5 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float16Array( buf ); -* // returns -* -* var len = arr.length; -* // returns 8 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float16Array( buf, 8 ); -* // returns -* -* var len = arr.length; -* // returns 4 -* -* @example -* var ArrayBuffer = require( '@stdlib/array-buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = new Float16Array( buf, 8, 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -*/ -function Float16Array() { - var byteOffset; - var nargs; - var buf; - var len; - var arg; - var i; - - nargs = arguments.length; - if ( !(this instanceof Float16Array) ) { - if ( nargs === 0 ) { - return new Float16Array(); - } - if ( nargs === 1 ) { - return new Float16Array( arguments[0] ); - } - if ( nargs === 2 ) { - return new Float16Array( arguments[0], arguments[1] ); - } - return new Float16Array( arguments[0], arguments[1], arguments[2] ); - } - // Create the underlying data buffer... - if ( nargs === 0 ) { - buf = new Uint16Array( 0 ); // backward-compatibility - } else if ( nargs === 1 ) { - arg = arguments[ 0 ]; - if ( isNonNegativeInteger( arg ) ) { - buf = new Uint16Array( arg ); - } else if ( isCollection( arg ) ) { - if ( isFloat16Array( arg ) ) { - buf = new Uint16Array( arg.length ); - gcopy.ndarray( arg.length, new Uint16Array( arg.buffer, arg.byteOffset, arg.length ), 1, 0, buf, 1, 0 ); // eslint-disable-line max-len - } else { - buf = fromArray( new Uint16Array( arg.length ), arg ); - } - } else if ( isArrayBuffer( arg ) ) { - if ( !isInteger( arg.byteLength/BYTES_PER_ELEMENT ) ) { - throw new RangeError( format( 'nullE9', BYTES_PER_ELEMENT, arg.byteLength ) ); - } - buf = new Uint16Array( arg ); - } else if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'null29', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'null2A', arg ) ); - } - buf = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( buf.next ) ) { - throw new TypeError( format( 'null2A', arg ) ); - } - buf = new Uint16Array( fromIterator( buf ) ); - } else { - throw new TypeError( format( 'null2A', arg ) ); - } - } else { - buf = arguments[ 0 ]; - if ( !isArrayBuffer( buf ) ) { - throw new TypeError( format( 'null2B', buf ) ); - } - byteOffset = arguments[ 1 ]; - if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'null2C', byteOffset ) ); - } - if ( !isInteger( byteOffset/BYTES_PER_ELEMENT ) ) { - throw new RangeError( format( 'nullEA', BYTES_PER_ELEMENT, byteOffset ) ); - } - if ( nargs === 2 ) { - len = buf.byteLength - byteOffset; - if ( !isInteger( len/BYTES_PER_ELEMENT ) ) { - throw new RangeError( format( 'null2E', BYTES_PER_ELEMENT, len ) ); - } - buf = new Uint16Array( buf, byteOffset ); - } else { - len = arguments[ 2 ]; - if ( !isNonNegativeInteger( len ) ) { - throw new TypeError( format( 'null2F', len ) ); - } - if ( (len*BYTES_PER_ELEMENT) > (buf.byteLength-byteOffset) ) { - throw new RangeError( format( 'null2G', len*BYTES_PER_ELEMENT ) ); - } - buf = new Uint16Array( buf, byteOffset, len ); - } - } - setReadOnly( this, '_buffer', buf ); - setReadOnly( this, '_length', buf.length ); - for ( i = 0; i < buf.length; i++ ) { - setReadWriteAccessor( this, i, getter( this, i ), setter( this, i ) ); - } - return this; -} - -/** -* Size (in bytes) of each array element. -* -* @name BYTES_PER_ELEMENT -* @memberof Float16Array -* @readonly -* @type {PositiveInteger} -* @default 2 -* -* @example -* var nbytes = Float16Array.BYTES_PER_ELEMENT; -* // returns 2 -*/ -setReadOnly( Float16Array, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT ); - -/** -* Constructor name. -* -* @name name -* @memberof Float16Array -* @readonly -* @type {string} -* @default 'Float16Array' -* -* @example -* var str = Float16Array.name; -* // returns 'Float16Array' -*/ -setReadOnly( Float16Array, 'name', 'Float16Array' ); - -/** -* Creates a new 16-bit floating-point number array from an array-like object or an iterable. -* -* @name from -* @memberof Float16Array -* @type {Function} -* @param {(Collection|Iterable)} src - array-like object or iterable -* @param {Function} [clbk] - callback to invoke for each source element -* @param {*} [thisArg] - context -* @throws {TypeError} `this` context must be a constructor -* @throws {TypeError} `this` must be a floating-point array -* @throws {TypeError} first argument must be an array-like object or an iterable -* @throws {TypeError} second argument must be a function -* @returns {Float16Array} half-precision floating-point number array -* -* @example -* var arr = Float16Array.from( [ 1.0, 2.0 ] ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* function clbk( v ) { -* return v * 2.0; -* } -* -* var arr = Float16Array.from( [ 1.0, 2.0 ], clbk ); -* // returns -* -* var len = arr.length; -* // returns 2 -*/ -setReadOnly( Float16Array, 'from', function from( src ) { - var thisArg; - var nargs; - var clbk; - var out; - var buf; - var tmp; - var len; - var i; - if ( !isFunction( this ) ) { - throw new TypeError( format('null01') ); - } - if ( !isFloatingPointArrayConstructor( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - nargs = arguments.length; - if ( nargs > 1 ) { - clbk = arguments[ 1 ]; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'null2H', clbk ) ); - } - if ( nargs > 2 ) { - thisArg = arguments[ 2 ]; - } - } - if ( isCollection( src ) ) { - if ( clbk ) { - len = src.length; - out = new this( len ); - buf = out._buffer; // eslint-disable-line no-underscore-dangle - for ( i = 0; i < len; i++ ) { - buf[ i ] = toWord( f16( clbk.call( thisArg, src[ i ], i ) ) ); - } - return out; - } - return new this( src ); - } - if ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) { // eslint-disable-line max-len - buf = src[ ITERATOR_SYMBOL ](); - if ( !isFunction( buf.next ) ) { - throw new TypeError( format( 'null2J', src ) ); - } - if ( clbk ) { - tmp = fromIteratorMap( buf, clbk, thisArg ); - } else { - tmp = fromIterator( buf ); - } - if ( tmp instanceof Error ) { - throw tmp; - } - len = tmp.length; - out = new this( len ); - buf = out._buffer; // eslint-disable-line no-underscore-dangle - for ( i = 0; i < len; i++ ) { - buf[ i ] = tmp[ i ]; - } - return out; - } - throw new TypeError( format( 'null2J', src ) ); -}); - -/** -* Creates a new 16-bit floating-point number array from a variable number of arguments. -* -* @name of -* @memberof Float16Array -* @type {Function} -* @param {...*} element - array elements -* @throws {TypeError} `this` context must be a constructor -* @throws {TypeError} `this` must be a floating-point number array -* @returns {Float16Array} half-precision floating-point number array -* -* @example -* var arr = Float16Array.of( 1.0, 1.0, 1.0, 1.0 ); -* // returns -* -* var x = arr[ 0 ]; -* // returns 1.0 -* -* var len = arr.length; -* // returns 4 -*/ -setReadOnly( Float16Array, 'of', function of() { - var args; - var i; - if ( !isFunction( this ) ) { - throw new TypeError( format('null01') ); - } - if ( !isFloatingPointArrayConstructor( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - args = []; - for ( i = 0; i < arguments.length; i++ ) { - args.push( arguments[ i ] ); - } - return new this( args ); -}); - -/** -* Returns an array element with support for both nonnegative and negative integer indices. -* -* @name at -* @memberof Float16Array.prototype -* @type {Function} -* @param {integer} idx - element index -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} must provide an integer -* @returns {(number|void)} array element -* -* @example -* var arr = new Float16Array( [ 10.0, 20.0, 30.0 ] ); -* -* var v = arr.at( 0 ); -* // returns 10.0 -* -* v = arr.at( -1 ); -* // returns 30.0 -* -* v = arr.at( 100 ); -* // returns undefined -*/ -setReadOnly( Float16Array.prototype, 'at', function at( idx ) { - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isInteger( idx ) ) { - throw new TypeError( format( 'null8A', idx ) ); - } - if ( idx < 0 ) { - idx += this._length; - } - if ( idx < 0 || idx >= this._length ) { - return; - } - return fromWord( this._buffer[ idx ] ); -}); - -/** -* Pointer to the underlying data buffer. -* -* @name buffer -* @memberof Float16Array.prototype -* @readonly -* @type {ArrayBuffer} -* -* @example -* var arr = new Float16Array( 10 ); -* -* var buf = arr.buffer; -* // returns -*/ -setReadOnlyAccessor( Float16Array.prototype, 'buffer', function get() { - return this._buffer.buffer; -}); - -/** -* Size (in bytes) of the array. -* -* @name byteLength -* @memberof Float16Array.prototype -* @readonly -* @type {NonNegativeInteger} -* -* @example -* var arr = new Float16Array( 10 ); -* -* var byteLength = arr.byteLength; -* // returns 20 -*/ -setReadOnlyAccessor( Float16Array.prototype, 'byteLength', function get() { - return this._buffer.byteLength; -}); - -/** -* Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`. -* -* @name byteOffset -* @memberof Float16Array.prototype -* @readonly -* @type {NonNegativeInteger} -* -* @example -* var arr = new Float16Array( 10 ); -* -* var byteOffset = arr.byteOffset; -* // returns 0 -*/ -setReadOnlyAccessor( Float16Array.prototype, 'byteOffset', function get() { - return this._buffer.byteOffset; -}); - -/** -* Size (in bytes) of each array element. -* -* @name BYTES_PER_ELEMENT -* @memberof Float16Array.prototype -* @readonly -* @type {PositiveInteger} -* @default 2 -* -* @example -* var arr = new Float16Array( 10 ); -* -* var nbytes = arr.BYTES_PER_ELEMENT; -* // returns 2 -*/ -setReadOnly( Float16Array.prototype, 'BYTES_PER_ELEMENT', Float16Array.BYTES_PER_ELEMENT ); - -/** -* Copies a sequence of elements within the array to the position starting at `target`. -* -* @name copyWithin -* @memberof Float16Array.prototype -* @type {Function} -* @param {integer} target - index at which to start copying elements -* @param {integer} start - source index at which to copy elements from -* @param {integer} [end] - source index at which to stop copying elements from -* @throws {TypeError} `this` must be a floating-point array -* @returns {Float16Array} modified array -* -* @example -* var arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0 ] ); -* -* // Copy the first two elements to the last two elements: -* arr.copyWithin( 2, 0, 2 ); -* -* var v = arr[ 2 ]; -* // returns 1.0 -* -* v = arr[ 3 ]; -* // returns 2.0 -*/ -setReadOnly( Float16Array.prototype, 'copyWithin', function copyWithin( target, start ) { - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - // FIXME: prefer a functional `copyWithin` implementation which addresses lack of universal browser support (e.g., IE11 and Safari) or ensure that typed arrays are polyfilled - if ( arguments.length === 2 ) { - this._buffer.copyWithin( target, start ); - } else { - this._buffer.copyWithin( target, start, arguments[2] ); - } - return this; -}); - -/** -* Returns an iterator for iterating over array key-value pairs. -* -* @name entries -* @memberof Float16Array.prototype -* @type {Function} -* @throws {TypeError} `this` must be a floating-point number array -* @returns {Iterator} iterator -* -* @example -* var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); -* -* var it = arr.entries(); -* -* var v = it.next().value; -* // returns [ 0, 1.0 ] -* -* v = it.next().value; -* // returns [ 1, 2.0 ] -* -* v = it.next().value; -* // returns [ 2, 3.0 ] -* -* var bool = it.next().done; -* // returns true -*/ -setReadOnly( Float16Array.prototype, 'entries', function entries() { - var self; - var iter; - var len; - var buf; - var FLG; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - self = this; - buf = this._buffer; - len = this._length; - - // Initialize an iteration index: - i = -1; - - // Create an iterator protocol-compliant object: - iter = {}; - setReadOnly( iter, 'next', next ); - setReadOnly( iter, 'return', end ); - - if ( ITERATOR_SYMBOL ) { - setReadOnly( iter, ITERATOR_SYMBOL, factory ); - } - return iter; - - /** - * Returns an iterator protocol-compliant object containing the next iterated value. - * - * @private - * @returns {Object} iterator protocol-compliant object - */ - function next() { - i += 1; - if ( FLG || i >= len ) { - return { - 'done': true - }; - } - return { - 'value': [ i, fromWord( buf[ i ] ) ], - 'done': false - }; - } - - /** - * Finishes an iterator. - * - * @private - * @param {*} [value] - value to return - * @returns {Object} iterator protocol-compliant object - */ - function end( value ) { - FLG = true; - if ( arguments.length ) { - return { - 'value': value, - 'done': true - }; - } - return { - 'done': true - }; - } - - /** - * Returns a new iterator. - * - * @private - * @returns {Iterator} iterator - */ - function factory() { - return self.entries(); - } -}); - -/** -* Tests whether all elements in an array pass a test implemented by a predicate function. -* -* @name every -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - predicate function execution context -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a function -* @returns {boolean} boolean indicating whether all elements pass a test -* -* @example -* function predicate( v ) { -* return v === 0.0; -* } -* -* var arr = new Float16Array( 3 ); -* -* var bool = arr.every( predicate ); -* // returns true -*/ -setReadOnly( Float16Array.prototype, 'every', function every( predicate, thisArg ) { - var buf; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'null3c', predicate ) ); - } - buf = this._buffer; - for ( i = 0; i < this._length; i++ ) { - if ( !predicate.call( thisArg, fromWord( buf[ i ] ), i, this ) ) { - return false; - } - } - return true; -}); - -/** -* Returns a modified typed array filled with a fill value. -* -* @name fill -* @memberof Float16Array.prototype -* @type {Function} -* @param {number} value - fill value -* @param {integer} [start=0] - starting index (inclusive) -* @param {integer} [end] - ending index (exclusive) -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a floating-point number -* @throws {TypeError} second argument must be an integer -* @throws {TypeError} third argument must be an integer -* @returns {Float16Array} modified array -* -* @example -* var arr = new Float16Array( 3 ); -* -* arr.fill( 1.0, 1 ); -* -* var v = arr[ 0 ]; -* // returns 0.0 -* -* v = arr[ 1 ]; -* // returns 1.0 -* -* v = arr[ 2 ]; -* // returns 1.0 -*/ -setReadOnly( Float16Array.prototype, 'fill', function fill( value, start, end ) { - var buf; - var len; - var i; - var v; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isNumber( value ) ) { - throw new TypeError( format( 'null49', value ) ); - } - buf = this._buffer; - len = this._length; - if ( arguments.length > 1 ) { - if ( !isInteger( start ) ) { - throw new TypeError( format( 'null7f', start ) ); - } - if ( start < 0 ) { - start += len; - if ( start < 0 ) { - start = 0; - } - } - if ( arguments.length > 2 ) { - if ( !isInteger( end ) ) { - throw new TypeError( format( 'null2z', end ) ); - } - if ( end < 0 ) { - end += len; - if ( end < 0 ) { - end = 0; - } - } - if ( end > len ) { - end = len; - } - } else { - end = len; - } - } else { - start = 0; - end = len; - } - v = toWord( value ); - for ( i = start; i < end; i++ ) { - buf[ i ] = v; - } - return this; -}); - -/** -* Returns a new array containing the elements of an array which pass a test implemented by a predicate function. -* -* @name filter -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} predicate - test function -* @param {*} [thisArg] - predicate function execution context -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a function -* @returns {Float16Array} floating-point number array -* -* @example -* function predicate( v ) { -* return ( v === 0.0 ); -* } -* -* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] ); -* -* var out = arr.filter( predicate ); -* // returns -* -* var len = out.length; -* // returns 2 -* -* var v = out[ 0 ]; -* // returns 0.0 -* -* v = out[ 1 ]; -* // returns 0.0 -*/ -setReadOnly( Float16Array.prototype, 'filter', function filter( predicate, thisArg ) { - var buf; - var out; - var i; - var v; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'null3c', predicate ) ); - } - buf = this._buffer; - out = []; - for ( i = 0; i < this._length; i++ ) { - v = fromWord( buf[ i ] ); - if ( predicate.call( thisArg, v, i, this ) ) { - out.push( v ); - } - } - return new this.constructor( out ); -}); - -/** -* Returns the first element in an array for which a predicate function returns a truthy value. -* -* @name find -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - predicate function execution context -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a function -* @returns {(boolean|void)} array element or undefined -* -* @example -* function predicate( v ) { -* return v > 0.0; -* } -* -* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] ); -* -* var v = arr.find( predicate ); -* // returns 1.0 -*/ -setReadOnly( Float16Array.prototype, 'find', function find( predicate, thisArg ) { - var buf; - var v; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'null3c', predicate ) ); - } - buf = this._buffer; - for ( i = 0; i < this._length; i++ ) { - v = fromWord( buf[ i ] ); - if ( predicate.call( thisArg, v, i, this ) ) { - return v; - } - } -}); - -/** -* Returns the index of the first element in an array for which a predicate function returns a truthy value. -* -* @name findIndex -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - predicate function execution context -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a function -* @returns {integer} index or -1 -* -* @example -* function predicate( v ) { -* return v > 0.0; -* } -* -* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] ); -* -* var v = arr.findIndex( predicate ); -* // returns 1 -*/ -setReadOnly( Float16Array.prototype, 'findIndex', function findIndex( predicate, thisArg ) { - var buf; - var v; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'null3c', predicate ) ); - } - buf = this._buffer; - for ( i = 0; i < this._length; i++ ) { - v = fromWord( buf[ i ] ); - if ( predicate.call( thisArg, v, i, this ) ) { - return i; - } - } - return -1; -}); - -/** -* Returns the last element in an array for which a predicate function returns a truthy value. -* -* @name findLast -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - predicate function execution context -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a function -* @returns {(boolean|void)} array element or undefined -* -* @example -* function predicate( v ) { -* return v > 0.0; -* } -* -* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] ); -* -* var v = arr.findLast( predicate ); -* // returns 1.0 -*/ -setReadOnly( Float16Array.prototype, 'findLast', function findLast( predicate, thisArg ) { - var buf; - var v; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'null3c', predicate ) ); - } - buf = this._buffer; - for ( i = this._length-1; i >= 0; i-- ) { - v = fromWord( buf[ i ] ); - if ( predicate.call( thisArg, v, i, this ) ) { - return v; - } - } -}); - -/** -* Returns the index of the last element in an array for which a predicate function returns a truthy value. -* -* @name findLastIndex -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - predicate function execution context -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a function -* @returns {integer} index or -1 -* -* @example -* function predicate( v ) { -* return v > 0.0; -* } -* -* var arr = new Float16Array( [ 0.0, 1.0, 0.0 ] ); -* -* var v = arr.findLastIndex( predicate ); -* // returns 1 -*/ -setReadOnly( Float16Array.prototype, 'findLastIndex', function findLastIndex( predicate, thisArg ) { - var buf; - var v; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'null3c', predicate ) ); - } - buf = this._buffer; - for ( i = this._length-1; i >= 0; i-- ) { - v = fromWord( buf[ i ] ); - if ( predicate.call( thisArg, v, i, this ) ) { - return i; - } - } - return -1; -}); - -/** -* Invokes a function once for each array element. -* -* @name forEach -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} fcn - function to invoke -* @param {*} [thisArg] - function invocation context -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a function -* -* @example -* function log( v, i ) { -* console.log( '%s: %s', i, v.toString() ); -* } -* -* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] ); -* -* arr.forEach( log ); -*/ -setReadOnly( Float16Array.prototype, 'forEach', function forEach( fcn, thisArg ) { - var buf; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'null3c', fcn ) ); - } - buf = this._buffer; - for ( i = 0; i < this._length; i++ ) { - fcn.call( thisArg, fromWord( buf[ i ] ), i, this ); - } -}); - -/** -* Returns an array element. -* -* @private -* @name _get -* @memberof Float16Array.prototype -* @type {Function} -* @param {NonNegativeInteger} idx - element index -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} must provide a nonnegative integer -* @returns {(number|void)} array element -*/ -setReadOnly( Float16Array.prototype, '_get', function get( idx ) { - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isNonNegativeInteger( idx ) ) { - throw new TypeError( format( 'null2K', idx ) ); - } - if ( idx >= this._length ) { - return; - } - return fromWord( this._buffer[ idx ] ); -}); - -/** -* Returns a boolean indicating whether an array includes a provided value. -* -* @name includes -* @memberof Float16Array.prototype -* @type {Function} -* @param {number} searchElement - search element -* @param {integer} [fromIndex=0] - starting index (inclusive) -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a floating-point number -* @throws {TypeError} second argument must be an integer -* @returns {boolean} boolean indicating whether an array includes a value -* -* @example -* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] ); -* -* var bool = arr.includes( 1.0 ); -* // returns true -* -* bool = arr.includes( 1.0, 2 ); -* // returns false -* -* bool = arr.includes( 5.0 ); -* // returns false -*/ -setReadOnly( Float16Array.prototype, 'includes', function includes( searchElement, fromIndex ) { - var buf; - var i; - var v; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isNumber( searchElement ) ) { - throw new TypeError( format( 'null49', searchElement ) ); - } - if ( arguments.length > 1 ) { - if ( !isInteger( fromIndex ) ) { - throw new TypeError( format( 'null7f', fromIndex ) ); - } - if ( fromIndex < 0 ) { - fromIndex += this._length; - if ( fromIndex < 0 ) { - fromIndex = 0; - } - } - } else { - fromIndex = 0; - } - buf = this._buffer; - v = toWord( searchElement ); - for ( i = fromIndex; i < this._length; i++ ) { - if ( v === buf[ i ] ) { - return true; - } - } - return false; -}); - -/** -* Returns the first index at which a given element can be found. -* -* @name indexOf -* @memberof Float16Array.prototype -* @type {Function} -* @param {float16} searchElement - element to find -* @param {integer} [fromIndex=0] - starting index (inclusive) -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a floating-point number -* @throws {TypeError} second argument must be an integer -* @returns {integer} index or -1 -* -* @example -* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] ); -* -* var idx = arr.indexOf( 2.0 ); -* // returns 2 -* -* idx = arr.indexOf( 2.0, 3 ); -* // returns -1 -* -* idx = arr.indexOf( 3.0, 3 ); -* // returns 3 -*/ -setReadOnly( Float16Array.prototype, 'indexOf', function indexOf( searchElement, fromIndex ) { - var buf; - var i; - var v; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isNumber( searchElement ) ) { - throw new TypeError( format( 'null49', searchElement ) ); - } - if ( arguments.length > 1 ) { - if ( !isInteger( fromIndex ) ) { - throw new TypeError( format( 'null7f', fromIndex ) ); - } - if ( fromIndex < 0 ) { - fromIndex += this._length; - if ( fromIndex < 0 ) { - fromIndex = 0; - } - } - } else { - fromIndex = 0; - } - buf = this._buffer; - v = toWord( searchElement ); - for ( i = fromIndex; i < this._length; i++ ) { - if ( v === buf[ i ] ) { - return i; - } - } - return -1; -}); - -/** -* Returns a new string by concatenating all array elements. -* -* @name join -* @memberof Float16Array.prototype -* @type {Function} -* @param {string} [separator=','] - element separator -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a string -* @returns {string} string representation -* -* @example -* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] ); -* -* var str = arr.join(); -* // returns '0,1,2' -* -* str = arr.join( '|' ); -* // returns '0|1|2' -*/ -setReadOnly( Float16Array.prototype, 'join', function join( separator ) { - var buf; - var out; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( arguments.length > 0 ) { - if ( !isString( separator ) ) { - throw new TypeError( format( 'null3F', separator ) ); - } - } else { - separator = ','; - } - buf = this._buffer; - out = []; - for ( i = 0; i < this._length; i++ ) { - out.push( fromWord( buf[ i ] ) ); - } - return out.join( separator ); -}); - -/** -* Returns an iterator for iterating over each index key in a typed array. -* -* @name keys -* @memberof Float16Array.prototype -* @type {Function} -* @throws {TypeError} `this` must be a floating-point number array -* @returns {Iterator} iterator -* -* @example -* var arr = new Float16Array( [ 1.0, 2.0 ] ); -* -* var iter = arr.keys(); -* -* var v = iter.next().value; -* // returns 0 -* -* v = iter.next().value; -* // returns 1 -* -* var bool = iter.next().done; -* // returns true -*/ -setReadOnly( Float16Array.prototype, 'keys', function keys() { - var self; - var iter; - var len; - var FLG; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - self = this; - len = this._length; - - // Initialize an iteration index: - i = -1; - - // Create an iterator protocol-compliant object: - iter = {}; - setReadOnly( iter, 'next', next ); - setReadOnly( iter, 'return', end ); - - if ( ITERATOR_SYMBOL ) { - setReadOnly( iter, ITERATOR_SYMBOL, factory ); - } - return iter; - - /** - * Returns an iterator protocol-compliant object containing the next iterated value. - * - * @private - * @returns {Object} iterator protocol-compliant object - */ - function next() { - i += 1; - if ( FLG || i >= len ) { - return { - 'done': true - }; - } - return { - 'value': i, - 'done': false - }; - } - - /** - * Finishes an iterator. - * - * @private - * @param {*} [value] - value to return - * @returns {Object} iterator protocol-compliant object - */ - function end( value ) { - FLG = true; - if ( arguments.length ) { - return { - 'value': value, - 'done': true - }; - } - return { - 'done': true - }; - } - - /** - * Returns a new iterator. - * - * @private - * @returns {Iterator} iterator - */ - function factory() { - return self.keys(); - } -}); - -/** -* Returns the last index at which a given element can be found. -* -* @name lastIndexOf -* @memberof Float16Array.prototype -* @type {Function} -* @param {number} searchElement - element to find -* @param {integer} [fromIndex] - starting index (inclusive) -* @throws {TypeError} `this` must be a floating-point number -* @throws {TypeError} first argument must be a numeric value -* @throws {TypeError} second argument must be an integer -* @returns {integer} index or -1 -* -* @example -* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 2.0 ] ); -* -* var idx = arr.lastIndexOf( 2.0 ); -* // returns 4 -* -* idx = arr.lastIndexOf( 2.0, 3 ); -* // returns 2 -* -* idx = arr.lastIndexOf( 4.0, 3 ); -* // returns -1 -* -* idx = arr.lastIndexOf( 1.0, -3 ); -* // returns 1 -*/ -setReadOnly( Float16Array.prototype, 'lastIndexOf', function lastIndexOf( searchElement, fromIndex ) { - var buf; - var i; - var v; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isNumber( searchElement ) ) { - throw new TypeError( format( 'null49', searchElement ) ); - } - if ( arguments.length > 1 ) { - if ( !isInteger( fromIndex ) ) { - throw new TypeError( format( 'null7f', fromIndex ) ); - } - if ( fromIndex >= this._length ) { - fromIndex = this._length - 1; - } else if ( fromIndex < 0 ) { - fromIndex += this._length; - } - } else { - fromIndex = this._length - 1; - } - buf = this._buffer; - v = toWord( searchElement ); - for ( i = fromIndex; i >= 0; i-- ) { - if ( v === buf[ i ] ) { - return i; - } - } - return -1; -}); - -/** -* Number of array elements. -* -* @name length -* @memberof Float16Array.prototype -* @readonly -* @type {NonNegativeInteger} -* -* @example -* var arr = new Float16Array( 10 ); -* -* var len = arr.length; -* // returns 10 -*/ -setReadOnlyAccessor( Float16Array.prototype, 'length', function get() { - return this._length; -}); - -/** -* Returns a new array with each element being the result of a provided callback function. -* -* @name map -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} fcn - callback function -* @param {*} [thisArg] - callback function execution context -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a function -* @returns {Float16Array} new floating-point number array -* -* @example -* function scale( v ) { -* return v * 2.0; -* } -* -* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] ); -* -* var out = arr.map( scale ); -* // returns -* -* var z = out[ 0 ]; -* // returns 0.0 -* -* z = out[ 1 ]; -* // returns 2.0 -* -* z = out[ 2 ]; -* // returns 4.0 -*/ -setReadOnly( Float16Array.prototype, 'map', function map( fcn, thisArg ) { - var outbuf; - var out; - var buf; - var i; - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( format('null3c'), fcn ); - } - buf = this._buffer; - out = new this.constructor( this._length ); - outbuf = out._buffer; // eslint-disable-line no-underscore-dangle - for ( i = 0; i < this._length; i++ ) { - outbuf[ i ] = toWord( fcn.call( thisArg, fromWord( buf[ i ] ), i, this ) ); // eslint-disable-line max-len - } - return out; -}); - -/** -* Applies a provided callback function to each element of the array, in order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion. -* -* @name reduce -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} reducer - callback function -* @param {*} [initialValue] - initial value -* @throws {TypeError} `this` must be a floating-point number array -* @throws {Error} if not provided an initial value, the array must have at least one element -* @returns {*} accumulated result -* -* @example -* function add( acc, v ) { -* return acc + v; -* } -* -* var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); -* -* var out = arr.reduce( add, 0 ); -* // returns 6.0 -*/ -setReadOnly( Float16Array.prototype, 'reduce', function reduce( reducer, initialValue ) { - var buf; - var len; - var acc; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isFunction( reducer ) ) { - throw new TypeError( format( 'null3c', reducer ) ); - } - buf = this._buffer; - len = this._length; - if ( arguments.length > 1 ) { - acc = initialValue; - i = 0; - } else { - if ( len === 0 ) { - throw new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' ); - } - acc = fromWord( buf[ 0 ] ); - i = 1; - } - for ( ; i < len; i++ ) { - acc = reducer( acc, fromWord( buf[ i ] ), i, this ); - } - return acc; -}); - -/** -* Applies a provided callback function to each element of the array, in reverse order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion. -* -* @name reduceRight -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} reducer - callback function -* @param {*} [initialValue] - initial value -* @throws {TypeError} `this` must be a floating-point number array -* @throws {Error} if not provided an initial value, the array must have at least one element -* @returns {*} accumulated result -* -* @example -* function add( acc, v ) { -* return acc + v; -* } -* -* var arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); -* -* var out = arr.reduceRight( add, 0 ); -* // returns 6.0 -*/ -setReadOnly( Float16Array.prototype, 'reduceRight', function reduceRight( reducer, initialValue ) { - var buf; - var len; - var acc; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isFunction( reducer ) ) { - throw new TypeError( format( 'null3c', reducer ) ); - } - buf = this._buffer; - len = this._length; - if ( arguments.length > 1 ) { - acc = initialValue; - i = len - 1; - } else { - if ( len === 0 ) { - throw new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' ); - } - acc = fromWord( buf[ len-1 ] ); - i = len - 2; - } - for ( ; i >= 0; i-- ) { - acc = reducer( acc, fromWord( buf[ i ] ), i, this ); - } - return acc; -}); - -/** -* Reverses an array in-place. -* -* @name reverse -* @memberof Float16Array.prototype -* @type {Function} -* @throws {TypeError} `this` must be a floating-point number array -* @returns {Float16Array} reversed array -* -* @example -* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] ); -* -* var out = arr.reverse(); -* // returns -* -* var v = out[ 0 ]; -* // returns 2.0 -* -* v = out[ 1 ]; -* // returns 1.0 -* -* v = out[ 2 ]; -* // returns 0.0 -*/ -setReadOnly( Float16Array.prototype, 'reverse', function reverse() { - var buf; - var tmp; - var len; - var N; - var i; - var j; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number 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 one or more array elements. -* -* ## Notes -* -* - When provided a typed array, we must check whether the source array shares the same buffer as the target array and whether the underlying memory overlaps. In particular, we are concerned with the following scenario: -* -* ```text -* buf: --------------------- -* src: --------------------- -* ``` -* -* In the above, as we copy values from `src`, we will overwrite values in the `src` view, resulting in duplicated values copied into the end of `buf`, which is not intended. Hence, to avoid overwriting source values, we must **copy** source values to a temporary array. -* -* In the other overlapping scenario, -* -* ```text -* buf: --------------------- -* src: --------------------- -* ``` -* -* by the time we begin copying into the overlapping region, we are copying from the end of `src`, a non-overlapping region, which means we don't run the risk of copying copied values, rather than the original `src` values, as intended. -* -* @name set -* @memberof Float16Array.prototype -* @type {Function} -* @param {(Collection|Float16Array)} value - value(s) -* @param {NonNegativeInteger} [i=0] - element index at which to start writing values -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a collection -* @throws {TypeError} index argument must be a nonnegative integer -* @throws {RangeError} index argument is out-of-bounds -* @throws {RangeError} target array lacks sufficient storage to accommodate source values -* @returns {void} -* -* @example -* var arr = new Float16Array( 10 ); -* -* var v = arr[ 0 ]; -* // returns 0.0 -* -* arr.set( [ 1.0, 2.0 ], 0 ); -* -* v = arr[ 0 ]; -* // returns 1.0 -*/ -setReadOnly( Float16Array.prototype, 'set', function set( value ) { - var sbuf; - var idx; - var buf; - var tmp; - var flg; - var N; - var i; - var j; - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isCollection( value ) ) { - throw new TypeError( format( 'null2O', value ) ); - } - buf = this._buffer; - if ( arguments.length > 1 ) { - idx = arguments[ 1 ]; - if ( !isNonNegativeInteger( idx ) ) { - throw new TypeError( format( 'null2L', idx ) ); - } - } else { - idx = 0; - } - N = value.length; - if ( idx+N > this._length ) { - throw new RangeError( format('null03') ); - } - if ( isFloat16Array( value ) ) { - sbuf = value._buffer; // eslint-disable-line no-underscore-dangle - flg = true; - } else { - sbuf = value; - flg = false; - } - // Check for overlapping memory... - j = buf.byteOffset + (idx*BYTES_PER_ELEMENT); - if ( - sbuf.buffer === buf.buffer && - ( - sbuf.byteOffset < j && - sbuf.byteOffset+sbuf.byteLength > j - ) - ) { - // We need to copy source values... - tmp = new Uint16Array( sbuf.length ); - for ( i = 0; i < sbuf.length; i++ ) { - tmp[ i ] = sbuf[ i ]; - } - sbuf = tmp; - } - if ( flg ) { - for ( i = 0; i < N; idx++, i++ ) { - buf[ idx ] = sbuf[ i ]; - } - } else { - for ( i = 0; i < N; idx++, i++ ) { - buf[ idx ] = toWord( sbuf[ i ] ); - } - } -}); - -/** -* Copies a portion of a typed array to a new typed array. -* -* @name slice -* @memberof Float16Array.prototype -* @type {Function} -* @param {integer} [begin] - start index (inclusive) -* @param {integer} [end] - end index (exclusive) -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be integer -* @throws {TypeError} second argument must be integer -* @returns {Float16Array} floating-point number array -* -* @example -* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] ); -* -* var out = arr.slice(); -* // returns -* -* var len = out.length; -* // returns 5 -* -* var v = out[ 0 ]; -* // returns 0.0 -* -* v = out[ len-1 ]; -* // returns 4.0 -* -* out = arr.slice( 1, -2 ); -* // returns -* -* len = out.length; -* // returns 2 -* -* v = out[ 0 ]; -* // returns 1.0 -* -* v = out[ len-1 ]; -* // returns 2.0 -*/ -setReadOnly( Float16Array.prototype, 'slice', function slice( begin, end ) { - var outlen; - var outbuf; - var out; - var buf; - var len; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - buf = this._buffer; - len = this._length; - if ( arguments.length === 0 ) { - begin = 0; - end = len; - } else { - if ( !isInteger( begin ) ) { - throw new TypeError( format( 'null7e', begin ) ); - } - if ( begin < 0 ) { - begin += len; - if ( begin < 0 ) { - begin = 0; - } - } - if ( arguments.length === 1 ) { - end = len; - } else { - if ( !isInteger( end ) ) { - throw new TypeError( format( 'null7f', end ) ); - } - if ( end < 0 ) { - end += len; - if ( end < 0 ) { - end = 0; - } - } else if ( end > len ) { - end = len; - } - } - } - if ( begin < end ) { - outlen = end - begin; - } else { - outlen = 0; - } - out = new this.constructor( outlen ); - outbuf = out._buffer; // eslint-disable-line no-underscore-dangle - for ( i = 0; i < outlen; i++ ) { - outbuf[ i ] = buf[ i+begin ]; - } - return out; -}); - -/** -* Tests whether at least one element in an array passes a test implemented by a predicate function. -* -* @name some -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - predicate function execution context -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a function -* @returns {boolean} boolean indicating whether at least one element passes a test -* -* @example -* function predicate( v ) { -* return v > 0.0; -* } -* -* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] ); -* -* var bool = arr.some( predicate ); -* // returns true -*/ -setReadOnly( Float16Array.prototype, 'some', function some( predicate, thisArg ) { - var buf; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'null3c', predicate ) ); - } - buf = this._buffer; - for ( i = 0; i < this._length; i++ ) { - if ( predicate.call( thisArg, fromWord( buf[ i ] ), i, this ) ) { - return true; - } - } - return false; -}); - -/** -* Sorts an array in-place. -* -* @name sort -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} [compareFcn] - comparison function -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a function -* @returns {Float16Array} sorted array -* -* @example -* function compare( a, b ) { -* if ( a < b ) { -* return -1; -* } -* if ( a > b ) { -* return 1; -* } -* return 0; -* } -* -* var arr = new Float16Array( [ 1.0, 0.0, 2.0 ] ); -* -* arr.sort( compare ); -* -* var v = arr[ 0 ]; -* // returns 0.0 -* -* v = arr[ 1 ]; -* // returns 1.0 -* -* v = arr[ 2 ]; -* // returns 2.0 -*/ -setReadOnly( Float16Array.prototype, 'sort', function sort( compareFcn ) { - var buf; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - buf = this._buffer; - if ( arguments.length === 0 ) { - buf.sort( defaultCompare ); - return this; - } - if ( !isFunction( compareFcn ) ) { - throw new TypeError( format( 'null3c', compareFcn ) ); - } - buf.sort( compare ); - return this; - - /** - * Default comparison function for float16 values. - * - * @private - * @param {unsigned16} a - unsigned 16-bit integer for comparison - * @param {unsigned16} b - unsigned 16-bit integer for comparison - * @returns {number} comparison result - */ - function defaultCompare( a, b ) { // eslint-disable-line stdlib/no-unnecessary-nested-functions - var x = fromWord( a ); - var y = fromWord( b ); - - // Handle NaN... - if ( isnan( x ) && isnan( y ) ) { - return 0; - } - if ( isnan( x ) ) { - return 1; - } - if ( isnan( y ) ) { - return -1; - } - // Normal comparison - if ( x < y ) { - return -1; - } - if ( x > y ) { - return 1; - } - return 0; - } - - /** - * Comparison function wrapper. - * - * @private - * @param {unsigned16} a - unsigned 16-bit integer for comparison - * @param {unsigned16} b - unsigned 16-bit integer for comparison - * @returns {number} comparison result - */ - function compare( a, b ) { - return compareFcn( fromWord( a ), fromWord( b ) ); - } -}); - -/** -* Creates a new typed array view over the same underlying `ArrayBuffer` and with the same underlying data type as the host array. -* -* @name subarray -* @memberof Float16Array.prototype -* @type {Function} -* @param {integer} [begin] - start index (inclusive) -* @param {integer} [end] - end index (exclusive) -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be an integer -* @throws {TypeError} second argument must be an integer -* @returns {Float16Array} subarray -* -* @example -* var arr = new Float16Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] ); -* -* var subarr = arr.subarray(); -* // returns -* -* var len = subarr.length; -* // returns 5 -* -* var bool = subarr[ 0 ]; -* // returns 0.0 -* -* bool = subarr[ len-1 ]; -* // returns 4.0 -* -* subarr = arr.subarray( 1, -2 ); -* // returns -* -* len = subarr.length; -* // returns 2 -* -* bool = subarr[ 0 ]; -* // returns 1.0 -* -* bool = subarr[ len-1 ]; -* // returns 2.0 -*/ -setReadOnly( Float16Array.prototype, 'subarray', function subarray( begin, end ) { - var offset; - var buf; - var len; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - buf = this._buffer; - len = this._length; - if ( arguments.length === 0 ) { - begin = 0; - end = len; - } else { - if ( !isInteger( begin ) ) { - throw new TypeError( format( 'null7e', begin ) ); - } - if ( begin < 0 ) { - begin += len; - if ( begin < 0 ) { - begin = 0; - } - } - if ( arguments.length === 1 ) { - end = len; - } else { - if ( !isInteger( end ) ) { - throw new TypeError( format( 'null7f', end ) ); - } - if ( end < 0 ) { - end += len; - if ( end < 0 ) { - end = 0; - } - } else if ( end > len ) { - end = len; - } - } - } - if ( begin >= len ) { - len = 0; - offset = buf.byteLength; - } else if ( begin >= end ) { - len = 0; - offset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT ); - } else { - len = end - begin; - offset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT ); - } - return new this.constructor( buf.buffer, offset, ( len < 0 ) ? 0 : len ); -}); - -/** -* Serializes an array as a locale-specific string. -* -* @name toLocaleString -* @memberof Float16Array.prototype -* @type {Function} -* @param {(string|Array)} [locales] - locale identifier(s) -* @param {Object} [options] - configuration options -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a string or an array of strings -* @throws {TypeError} options argument must be an object -* @returns {string} string representation -* -* @example -* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] ); -* -* var str = arr.toLocaleString(); -* // returns '0,1,2' -*/ -setReadOnly( Float16Array.prototype, 'toLocaleString', function toLocaleString( locales, options ) { - var opts; - var loc; - var out; - var buf; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( arguments.length === 0 ) { - loc = []; - } else if ( isString( locales ) || isStringArray( locales ) ) { - loc = locales; - } else { - throw new TypeError( format( 'invalid argument. First argument must be a string or an array of strings. Value: `%s`.', locales ) ); - } - if ( arguments.length < 2 ) { - opts = {}; - } else if ( isObject( options ) ) { - opts = options; - } else { - throw new TypeError( format( 'null2V', options ) ); - } - buf = this._buffer; - out = []; - for ( i = 0; i < this._length; i++ ) { - out.push( fromWord( buf[ i ] ) ); - } - return out.toLocaleString( loc, opts ); -}); - -/** -* Returns a new typed array containing the elements in reversed order. -* -* @name toReversed -* @memberof Float16Array.prototype -* @type {Function} -* @throws {TypeError} `this` must be a floating-point number array -* @returns {Float16Array} reversed array -* -* @example -* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] ); -* -* var out = arr.toReversed(); -* // returns -* -* var v = out[ 0 ]; -* // returns 2.0 -* -* v = out[ 1 ]; -* // returns 1.0 -* -* v = out[ 2 ]; -* // returns 0.0 -*/ -setReadOnly( Float16Array.prototype, 'toReversed', function toReversed() { - var outbuf; - var out; - var len; - var buf; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number 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; -}); - -/** -* Returns a new typed array containing the elements in sorted order. -* -* @name toSorted -* @memberof Float16Array.prototype -* @type {Function} -* @param {Function} [compareFcn] - comparison function -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be a function -* @returns {Float16Array} sorted array -* -* @example -* function compare( a, b ) { -* if ( a > b ) { -* return 1; -* } -* if ( a < b ) { -* return -1; -* } -* return 0; -* } -* -* var arr = new Float16Array( [ 2.0, 0.0, 1.0 ] ); -* -* var out = arr.toSorted( compare ); -* // returns -* -* var v = out[ 0 ]; -* // returns 0.0 -* -* v = out[ 1 ]; -* // returns 1.0 -* -* v = out[ 2 ]; -* // returns 2.0 -*/ -setReadOnly( Float16Array.prototype, 'toSorted', function toSorted( compareFcn ) { - var out; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - out = new this.constructor( this ); - if ( arguments.length === 0 ) { - return out.sort(); - } - return out.sort( compareFcn ); -}); - -/** -* Serializes an array as a string. -* -* @name toString -* @memberof Float16Array.prototype -* @type {Function} -* @throws {TypeError} `this` must be a floating-point number array -* @returns {string} string representation -* -* @example -* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] ); -* -* var str = arr.toString(); -* // returns '0,1,2' -*/ -setReadOnly( Float16Array.prototype, 'toString', function toString() { - var out; - var buf; - var i; - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - buf = this._buffer; - out = []; - for ( i = 0; i < this._length; i++ ) { - out.push( fromWord( buf[ i ] ) ); - } - return out.join( ',' ); -}); - -/** -* Returns an iterator for iterating over each value in a typed array. -* -* @name values -* @memberof Float16Array.prototype -* @type {Function} -* @throws {TypeError} `this` must be a floating-point number array -* @returns {Iterator} iterator -* -* @example -* var arr = new Float16Array( [ 0.0, 1.0 ] ); -* -* var iter = arr.values(); -* -* var v = iter.next().value; -* // returns 0.0 -* -* v = iter.next().value; -* // returns 1.0 -* -* var bool = iter.next().done; -* // returns true -*/ -setReadOnly( Float16Array.prototype, 'values', function values() { - var iter; - var self; - var len; - var FLG; - var buf; - var i; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - self = this; - buf = this._buffer; - len = this._length; - - // Initialize an iteration index: - i = -1; - - // Create an iterator protocol-compliant object: - iter = {}; - setReadOnly( iter, 'next', next ); - setReadOnly( iter, 'return', end ); - - if ( ITERATOR_SYMBOL ) { - setReadOnly( iter, ITERATOR_SYMBOL, factory ); - } - return iter; - - /** - * Returns an iterator protocol-compliant object containing the next iterated value. - * - * @private - * @returns {Object} iterator protocol-compliant object - */ - function next() { - i += 1; - if ( FLG || i >= len ) { - return { - 'done': true - }; - } - return { - 'value': fromWord( buf[ i ] ), - 'done': false - }; - } - - /** - * Finishes an iterator. - * - * @private - * @param {*} [value] - value to return - * @returns {Object} iterator protocol-compliant object - */ - function end( value ) { - FLG = true; - if ( arguments.length ) { - return { - 'value': value, - 'done': true - }; - } - return { - 'done': true - }; - } - - /** - * Returns a new iterator. - * - * @private - * @returns {Iterator} iterator - */ - function factory() { - return self.values(); - } -}); - -/** -* Returns a new typed array with the element at a provided index replaced with a provided value. -* -* @name with -* @memberof Float16Array.prototype -* @type {Function} -* @param {integer} index - element index -* @param {number} value - new value -* @throws {TypeError} `this` must be a floating-point number array -* @throws {TypeError} first argument must be an integer -* @throws {RangeError} index argument is out-of-bounds -* @throws {TypeError} second argument must be a floating-point number -* @returns {Float16Array} new typed array -* -* @example -* var arr = new Float16Array( [ 0.0, 1.0, 2.0 ] ); -* -* var out = arr.with( 0, 3.0 ); -* // returns -* -* var v = out[ 0 ]; -* // returns 3.0 -*/ -setReadOnly( Float16Array.prototype, 'with', function copyWith( index, value ) { - var out; - var len; - - if ( !isFloat16Array( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a floating-point number array.' ); - } - if ( !isInteger( index ) ) { - throw new TypeError( format( 'null7e', index ) ); - } - len = this._length; - if ( index < 0 ) { - index += len; - } - if ( index < 0 || index >= len ) { - throw new RangeError( format( 'nullFP', index ) ); - } - if ( !isNumber( value ) ) { - throw new TypeError( format( 'null4A', value ) ); - } - out = new this.constructor( this ); - out[ index ] = value; - return out; -}); - - -// EXPORTS // - -module.exports = Float16Array; diff --git a/package.json b/package.json index 0ed7acd..953c789 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.0", "description": "Float16Array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,65 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-uint16": "^0.2.3", - "@stdlib/assert-has-float16array-support": "^0.1.1", - "@stdlib/assert-has-iterator-symbol-support": "^0.2.3", - "@stdlib/assert-is-arraybuffer": "^0.2.3", - "@stdlib/assert-is-collection": "^0.2.3", - "@stdlib/assert-is-function": "^0.2.3", - "@stdlib/assert-is-integer": "^0.2.3", - "@stdlib/assert-is-nonnegative-integer": "^0.2.3", - "@stdlib/assert-is-number": "^0.2.3", - "@stdlib/assert-is-object": "^0.2.3", - "@stdlib/assert-is-string": "^0.2.3", - "@stdlib/assert-is-string-array": "^0.2.3", - "@stdlib/blas-base-gcopy": "^0.2.3", - "@stdlib/math-base-assert-is-nan": "^0.2.3", - "@stdlib/math-base-special-floor": "^0.2.4", - "@stdlib/number-float16-base-from-word": "^0.2.1", - "@stdlib/number-float16-base-to-word": "^0.1.1", - "@stdlib/number-float64-base-to-float16": "^0.1.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/symbol-iterator": "^0.2.3", - "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.2.4", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", - "@stdlib/utils-define-read-write-accessor": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-buffer": "^0.2.3", - "@stdlib/assert-has-own-property": "^0.2.3", - "@stdlib/assert-instance-of": "^0.3.1", - "@stdlib/assert-is-array": "^0.2.3", - "@stdlib/assert-is-boolean": "^0.2.3", - "@stdlib/assert-is-iterator-like": "^0.2.3", - "@stdlib/console-log-each": "^0.2.4", - "@stdlib/math-base-special-pow": "^0.3.1", - "@stdlib/random-array-uniform": "^0.2.2", - "@stdlib/utils-identity-function": "^0.2.3", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..c9f26e2 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 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 main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/polyfill/test.at.js b/test/polyfill/test.at.js deleted file mode 100644 index 2cd65c2..0000000 --- a/test/polyfill/test.at.js +++ /dev/null @@ -1,144 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `at` method for returning an array element', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'at' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.at ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.at.call( value, 0 ); - }; - } -}); - -tape( 'the method throws an error if provided an index argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - 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.at( value ); - }; - } -}); - -tape( 'the method returns `undefined` if provided an index which exceeds array dimensions', function test( t ) { - var arr; - var v; - var i; - - arr = new Float16Array( 10 ); - for ( i = -arr.length; i < arr.length; i++ ) { - if ( i < 0 ) { - v = arr.at( i-arr.length ); - t.strictEqual( v, void 0, 'returns expected value for index '+(i-arr.length) ); - } else { - v = arr.at( arr.length+i ); - t.strictEqual( v, void 0, 'returns expected value for index '+(arr.length+i) ); - } - } - t.end(); -}); - -tape( 'the method returns an array element', function test( t ) { - var arr; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( i+0.05 ); - } - - arr = new Float16Array( arr ); - - for ( i = -arr.length; i < arr.length; i++ ) { - v = arr.at( i ); - if ( i < 0 ) { - t.strictEqual( v, float64ToFloat16( arr.length + i + 0.05 ), 'returns expected value for index '+i ); - } else { - t.strictEqual( v, float64ToFloat16( i + 0.05 ), 'returns expected value for index '+i ); - } - } - t.end(); -}); diff --git a/test/polyfill/test.copy_within.js b/test/polyfill/test.copy_within.js deleted file mode 100644 index 0a8eb57..0000000 --- a/test/polyfill/test.copy_within.js +++ /dev/null @@ -1,281 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 Uint16Array = require( '@stdlib/array-uint16' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `copyWithin` method for copying a sequence of array elements within a floating-point number array', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'copyWithin' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within an array', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( 0, 3 ); - buf = new Uint16Array( arr.buffer ); - - // Overwritten: - t.strictEqual( buf[ 0 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 4.05 ), 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 2 ], toWord( 2.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (negative target)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( -arr.length, 3 ); - buf = new Uint16Array( arr.buffer ); - - // Overwritten: - t.strictEqual( buf[ 0 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 4.05 ), 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 2 ], toWord( 2.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (negative start)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( 0, -2 ); - buf = new Uint16Array( arr.buffer ); - - // Overwritten: - t.strictEqual( buf[ 0 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 4.05 ), 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 2 ], toWord( 2.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (end=length)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( 0, 3, arr.length ); - buf = new Uint16Array( arr.buffer ); - - // Overwritten: - t.strictEqual( buf[ 0 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 4.05 ), 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 2 ], toWord( 2.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (non-inclusive end)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( 2, 0, 2 ); - buf = new Uint16Array( arr.buffer ); - - // Remain the same: - t.strictEqual( buf[ 0 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - - // Overwritten: - t.strictEqual( buf[ 2 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 1.05 ), 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (negative end)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( 2, 0, -3 ); - buf = new Uint16Array( arr.buffer ); - - // Remain the same: - t.strictEqual( buf[ 0 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - - // Overwritten: - t.strictEqual( buf[ 2 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 1.05 ), 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (target >= length)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( arr.length, 3 ); - buf = new Uint16Array( arr.buffer ); - - // Remain the same: - t.strictEqual( buf[ 0 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 2 ], toWord( 2.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (target > start)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( 2, 0 ); - buf = new Uint16Array( arr.buffer ); - - // Remain the same: - t.strictEqual( buf[ 0 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - - // Overwritten: - t.strictEqual( buf[ 2 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 4 ], toWord( 2.05 ), 'returns expected value' ); - - t.end(); -}); diff --git a/test/polyfill/test.entries.js b/test/polyfill/test.entries.js deleted file mode 100644 index 4cea4d1..0000000 --- a/test/polyfill/test.entries.js +++ /dev/null @@ -1,238 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 proxyquire = require( 'proxyquire' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isNumber = require( '@stdlib/assert-is-number' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `entries` method for returning an iterator for iterating over array key-value pairs', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'entries' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.entries ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.entries.call( value ); - }; - } -}); - -tape( 'the method returns an iterator protocol-compliant object', function test( t ) { - var buf; - var arr; - var it; - var v; - var i; - - buf = [ 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( buf ); - - it = arr.entries(); - t.strictEqual( it.next.length, 0, 'has zero arity' ); - - for ( i = 0; i < arr.length; i++ ) { - v = it.next(); - t.strictEqual( isArray( v.value ), true, 'returns expected value' ); - t.strictEqual( v.value[ 0 ], i, 'returns expected value' ); - t.strictEqual( isNumber( v.value[ 1 ] ), true, 'returns expected value' ); - t.strictEqual( v.value[ 1 ], float64ToFloat16( buf[ i ] ), 'returns expected value' ); - t.strictEqual( typeof v.done, 'boolean', 'returns expected value' ); - } - t.end(); -}); - -tape( 'the method returns an iterator which has a `return` method for closing an iterator (no argument)', function test( t ) { - var buf; - var arr; - var it; - var v; - - buf = [ 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( buf ); - - it = arr.entries(); - - v = it.next(); - t.strictEqual( v.value[ 1 ], float64ToFloat16( buf[ 0 ] ), 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value[ 1 ], float64ToFloat16( buf[ 1 ] ), 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.return(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method returns an iterator which has a `return` method for closing an iterator (argument)', function test( t ) { - var buf; - var arr; - var it; - var v; - - buf = [ 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( buf ); - - it = arr.entries(); - - v = it.next(); - t.strictEqual( v.value[ 1 ], float64ToFloat16( buf[ 0 ] ), 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value[ 1 ], float64ToFloat16( buf[ 1 ] ), 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.return( 'finished' ); - t.strictEqual( v.value, 'finished', 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'if an environment supports `Symbol.iterator`, the method returns an iterable', function test( t ) { - var Float16Array; - var arr; - var buf; - var it1; - var it2; - var v1; - var v2; - var i; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - buf = [ 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( buf ); - - it1 = arr.entries(); - t.strictEqual( typeof it1[ '__ITERATOR_SYMBOL__' ], 'function', 'has method' ); - t.strictEqual( it1[ '__ITERATOR_SYMBOL__' ].length, 0, 'has zero arity' ); - - it2 = it1[ '__ITERATOR_SYMBOL__' ](); - t.strictEqual( typeof it2, 'object', 'returns expected value' ); - t.strictEqual( typeof it2.next, 'function', 'has `next` method' ); - t.strictEqual( typeof it2.return, 'function', 'has `return` method' ); - - for ( i = 0; i < arr.length; i++ ) { - v1 = it1.next().value; - v2 = it2.next().value; - t.strictEqual( v1[ 0 ], v2[ 0 ], 'returns expected value' ); - t.strictEqual( v1[ 1 ], v2[ 1 ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'if an environment does not support `Symbol.iterator`, the method does not return an "iterable"', function test( t ) { - var Float16Array; - var arr; - var buf; - var it; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/symbol-iterator': false - }); - - buf = [ 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( buf ); - - it = arr.entries(); - t.strictEqual( it[ ITERATOR_SYMBOL ], void 0, 'does not have property' ); - - t.end(); -}); diff --git a/test/polyfill/test.every.js b/test/polyfill/test.every.js deleted file mode 100644 index 384adc4..0000000 --- a/test/polyfill/test.every.js +++ /dev/null @@ -1,174 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `every` method for returning boolean indicating whether all elements pass a test', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'every' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.every ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.every.call( value, predicate ); - }; - } - - function predicate( v ) { - return v === 0.0; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.every( value ); - }; - } -}); - -tape( 'the method returns `true` if operating on an empty floating-point number array', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( 0 ); - bool = arr.every( predicate ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns `true` if all elements pass a test', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 1.05, 1.05, 1.05 ] ); - bool = arr.every( predicate ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v === float64ToFloat16( 1.05 ); - } -}); - -tape( 'the method returns `false` if one or more elements fail a test', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 1.05, 0.05, 1.05 ] ); - bool = arr.every( predicate ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v === float64ToFloat16( 1.05 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var bool; - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ 1.05, 1.05, 1.05, 1.05 ] ); - bool = arr.every( predicate, ctx ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v === float64ToFloat16( 1.05 ); - } -}); diff --git a/test/polyfill/test.fill.js b/test/polyfill/test.fill.js deleted file mode 100644 index 197e33f..0000000 --- a/test/polyfill/test.fill.js +++ /dev/null @@ -1,305 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 Uint16Array = require( '@stdlib/array-uint16' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `fill` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'fill' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.fill ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.fill.call( value, 1.0 ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a floating-point number', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 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.fill( value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - 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.fill( 1.0, value ); - }; - } -}); - -tape( 'the method throws an error if provided a third argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - 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.fill( 1.0, 0, value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.fill( 1.05 ); - - t.strictEqual( out instanceof Float16Array, true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 10 ); - out = arr.fill( 1.05 ); - - t.strictEqual( out, arr, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'if called with one argument, the method sets each array element to the provided value', function test( t ) { - var arr; - var buf; - var i; - - arr = new Float16Array( 3 ); - arr.fill( 1.05 ); - - buf = new Uint16Array( arr.buffer ); - - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( buf[ i ], toWord( 1.05 ), 'returns expected value' ); - } - - t.end(); -}); - -tape( 'if called with two arguments, the method sets each array element to the provided value starting from a start index (inclusive)', function test( t ) { - var arr; - var buf; - - arr = new Float16Array( 3 ); - buf = new Uint16Array( arr.buffer ); - - arr.fill( 1.05, 1 ); - - t.strictEqual( buf[ 0 ], toWord( 0.0 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 2 ], toWord( 1.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'if called with three arguments, the method sets each array element to the provided value starting from a start index (inclusive) until a specified end index (exclusive)', function test( t ) { - var arr; - var buf; - - arr = new Float16Array( 3 ); - buf = new Uint16Array( arr.buffer ); - - arr.fill( 1.05, 0, 2 ); - - t.strictEqual( buf[ 0 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 2 ], toWord( 0.0 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method supports negative indices', function test( t ) { - var arr; - var buf; - - arr = new Float16Array( 3 ); - buf = new Uint16Array( arr.buffer ); - - arr.fill( 1.05, -3, -1 ); - - t.strictEqual( buf[ 0 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 2 ], toWord( 0.0 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'if a provided start index resolves to a negative index, the method fills an array starting from the first element', function test( t ) { - var arr; - var buf; - var i; - - arr = new Float16Array( 3 ); - buf = new Uint16Array( arr.buffer ); - - arr.fill( 1.05, -10 ); - - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( buf[ i ], toWord( 1.05 ), 'returns expected value' ); - } - - t.end(); -}); - -tape( 'if a provided end index resolves to an index exceeding the last array element index, the method fills an array until the last element (inclusive)', function test( t ) { - var arr; - var buf; - var i; - - arr = new Float16Array( 3 ); - buf = new Uint16Array( arr.buffer ); - - arr.fill( 1.05, 1, 10 ); - - t.strictEqual( buf[ 0 ], toWord( 0.0 ), 'returns expected value' ); - for ( i = 1; i < arr.length; i++ ) { - t.strictEqual( buf[ i ], toWord( 1.05 ), 'returns expected value' ); - } - - t.end(); -}); - -tape( 'if a provided start index resolves to an index which is greater than or equal to a resolved end index, the method does not fill an array', function test( t ) { - var arr; - var buf; - - arr = new Float16Array( 3 ); - buf = new Uint16Array( arr.buffer ); - - arr.fill( 1.0, 2, 1 ); - - t.strictEqual( buf[ 0 ], toWord( 0.0 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 0.0 ), 'returns expected value' ); - t.strictEqual( buf[ 2 ], toWord( 0.0 ), 'returns expected value' ); - - t.end(); -}); diff --git a/test/polyfill/test.filter.js b/test/polyfill/test.filter.js deleted file mode 100644 index c5be66b..0000000 --- a/test/polyfill/test.filter.js +++ /dev/null @@ -1,226 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 instanceOf = require( '@stdlib/assert-instance-of' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `filter` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'filter' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.filter ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.filter.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( v === 1.0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.filter( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.filter( predicate ); - - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v === 1.0 ); - } -}); - -tape( 'the method returns a new floating-point number array containing only those elements which satisfy a test condition', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 1.05, 2.05 ] ); - expected = new Uint16Array( [ toWord( 1.05 ), toWord( 1.05 ) ] ); - actual = arr.filter( predicate ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v === float64ToFloat16( 1.05 ) ); - } -}); - -tape( 'the method copies all elements to a new array if all elements satisfy a test condition', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ) - ]); - actual = arr.filter( predicate ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.notEqual( actual, arr, 'returns a new instance' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v > 1.0 ); - } -}); - -tape( 'the method returns an empty array if no elements satisfy a test condition', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array( [] ); - actual = arr.filter( predicate ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.notEqual( actual, arr, 'returns a new instance' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 1.0 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var expected; - var actual; - var arr; - var buf; - var ctx; - - arr = new Float16Array( [ 1.05, 2.05, 1.05, 1.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 1.05 ), - toWord( 1.05 ) - ]); - ctx = { - 'count': 0 - }; - actual = arr.filter( predicate, ctx ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v === float64ToFloat16( 1.05 ) ); - } -}); diff --git a/test/polyfill/test.find.js b/test/polyfill/test.find.js deleted file mode 100644 index 64dffd0..0000000 --- a/test/polyfill/test.find.js +++ /dev/null @@ -1,174 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `find` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'find' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.find ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.find.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( v === 1.0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.find( value ); - }; - } -}); - -tape( 'the method returns `undefined` if operating on an empty floating-point number array', function test( t ) { - var arr; - var v; - - arr = new Float16Array( 0 ); - v = arr.find( predicate ); - - t.strictEqual( v, void 0, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns the first element which passes a test', function test( t ) { - var arr; - var v; - - arr = new Float16Array( [ 1.05, -2.05, 3.05, -4.05 ] ); - v = arr.find( predicate ); - - t.strictEqual( v, float64ToFloat16( -2.05 ), 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method returns `undefined` if all elements fail a test', function test( t ) { - var arr; - var v; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - v = arr.find( predicate ); - - t.strictEqual( v, void 0, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - var v; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ -1.05, -2.05, 3.05, 4.05, 5.05 ] ); - v = arr.find( predicate, ctx ); - - t.strictEqual( v, float64ToFloat16( 3.05 ), 'returns expected value' ); - t.strictEqual( ctx.count, 3, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v > 0.0 ); - } -}); diff --git a/test/polyfill/test.find_index.js b/test/polyfill/test.find_index.js deleted file mode 100644 index e1516da..0000000 --- a/test/polyfill/test.find_index.js +++ /dev/null @@ -1,173 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `findIndex` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'findIndex' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.findIndex ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.findIndex.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( v === 1.0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.findIndex( value ); - }; - } -}); - -tape( 'the method returns `-1` if operating on an empty floating-point number array', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( 0 ); - idx = arr.findIndex( predicate ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns the index of the first element which passes a test', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( [ 1.05, -2.05, 3.05, -4.05 ] ); - idx = arr.findIndex( predicate ); - - t.strictEqual( idx, 1, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0); - } -}); - -tape( 'the method returns `-1` if all elements fail a test', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - idx = arr.findIndex( predicate ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - var idx; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ -1.05, -2.05, 3.05, 4.05, 5.05 ] ); - idx = arr.findIndex( predicate, ctx ); - - t.strictEqual( idx, 2, 'returns expected value' ); - t.strictEqual( ctx.count, 3, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v > 0.0 ); - } -}); diff --git a/test/polyfill/test.find_last.js b/test/polyfill/test.find_last.js deleted file mode 100644 index 091e5a7..0000000 --- a/test/polyfill/test.find_last.js +++ /dev/null @@ -1,174 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `findLast` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'findLast' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.findLast ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.findLast.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( v === 0.0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.findLast( value ); - }; - } -}); - -tape( 'the method returns `undefined` if operating on an empty floating-point number array', function test( t ) { - var arr; - var v; - - arr = new Float16Array( 0 ); - v = arr.findLast( predicate ); - - t.strictEqual( v, void 0, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns the last element which passes a test', function test( t ) { - var arr; - var v; - - arr = new Float16Array( [ 1.05, -2.05, 3.05, -4.05 ] ); - v = arr.findLast( predicate ); - - t.strictEqual( v, float64ToFloat16( -4.05 ), 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method returns `undefined` if all elements fail a test', function test( t ) { - var arr; - var v; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - v = arr.findLast( predicate ); - - t.strictEqual( v, void 0, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - var v; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ -1.05, -2.05, 3.05, 4.05, 5.05 ] ); - v = arr.findLast( predicate, ctx ); - - t.strictEqual( v, float64ToFloat16( 5.05 ), 'returns expected value' ); - t.strictEqual( ctx.count, 1, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v > 0.0 ); - } -}); diff --git a/test/polyfill/test.find_last_index.js b/test/polyfill/test.find_last_index.js deleted file mode 100644 index 1b7b8df..0000000 --- a/test/polyfill/test.find_last_index.js +++ /dev/null @@ -1,173 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `findLastIndex` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'findLastIndex' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.findLastIndex ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.findLastIndex.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( v === 1.0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.findLastIndex( value ); - }; - } -}); - -tape( 'the method returns `-1` if operating on an empty floating-point number array', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( 0 ); - idx = arr.findLastIndex( predicate ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns the index of the last element which passes a test', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( [ 1.05, -2.05, 3.05, -4.05 ] ); - idx = arr.findLastIndex( predicate ); - - t.strictEqual( idx, 3, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method returns `-1` if all elements fail a test', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - idx = arr.findLastIndex( predicate ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - var idx; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ -1.05, -2.05, 3.05, 4.05, 5.05 ] ); - idx = arr.findLastIndex( predicate, ctx ); - - t.strictEqual( idx, 4, 'returns expected value' ); - t.strictEqual( ctx.count, 1, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v > 0.0 ); - } -}); diff --git a/test/polyfill/test.for_each.js b/test/polyfill/test.for_each.js deleted file mode 100644 index 98e75c2..0000000 --- a/test/polyfill/test.for_each.js +++ /dev/null @@ -1,196 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `forEach` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'forEach' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.forEach ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.forEach.call( value, fcn ); - }; - } - - function fcn( v ) { - if ( !isNumber( v ) ) { - t.fail( 'should be a number' ); - } - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.forEach( value ); - }; - } -}); - -tape( 'the method should not invoke a provided callback function if operating on an empty floating-point array', function test( t ) { - var arr; - - arr = new Float16Array( 0 ); - arr.forEach( fcn ); - - t.end(); - - function fcn() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns `undefined`', function test( t ) { - var arr; - var out; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - out = arr.forEach( fcn ); - - t.strictEqual( out, void 0, 'returns expected value' ); - t.end(); - - function fcn( v ) { - if ( !isNumber( v ) ) { - t.fail( 'should be a number' ); - } - } -}); - -tape( 'the method invokes a provided function for each element in an array', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var arr; - - indices = []; - values = []; - arrays = []; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - arr.forEach( fcn ); - - expected = [ - float64ToFloat16( 1.05 ), - float64ToFloat16( 2.05 ), - float64ToFloat16( 3.05 ), - float64ToFloat16( 4.05 ) - ]; - - t.deepEqual( values, expected, 'returns expected value' ); - t.deepEqual( indices, [ 0, 1, 2, 3 ], 'returns expected value' ); - t.strictEqual( arrays[ 0 ], arr, 'returns expected value' ); - t.strictEqual( arrays[ 1 ], arr, 'returns expected value' ); - t.strictEqual( arrays[ 2 ], arr, 'returns expected value' ); - t.strictEqual( arrays[ 3 ], arr, 'returns expected value' ); - - t.end(); - - function fcn( v, i, arr ) { - values.push( v ); - indices.push( i ); - arrays.push( arr ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - arr.forEach( fcn, ctx ); - - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function fcn() { - this.count += 1; // eslint-disable-line no-invalid-this - } -}); diff --git a/test/polyfill/test.from.js b/test/polyfill/test.from.js deleted file mode 100644 index d9cfc1a..0000000 --- a/test/polyfill/test.from.js +++ /dev/null @@ -1,654 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 proxyquire = require( 'proxyquire' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is a `from` method for creating a 16-bit floating-point number array from an array-like object or an iterable', function test( t ) { - var arr; - - t.strictEqual( hasOwnProp( Float16Array, 'from' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.from ), true, 'has method' ); - - arr = Float16Array.from( [] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a constructor', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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 Float16Array.from.call( value, [] ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array constructor', function test( t ) { - var values; - var i; - - values = [ - {}, - null, - 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 Float16Array.from.call( value, [] ); - }; - } -}); - -tape( 'the method throws an error if not provided an iterable or array-like object', function test( t ) { - var values; - var i; - - 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 Float16Array.from( value ); - }; - } -}); - -tape( 'the method throws an error if not provided an iterable or array-like object (callback)', function test( t ) { - var values; - var i; - - 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 Float16Array.from( value, clbk ); - }; - } - - function clbk() { - return 1.0; - } -}); - -tape( 'the method throws an error if not provided an iterable or array-like object (callback, thisArg)', function test( t ) { - var values; - var i; - - 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 Float16Array.from( value, clbk, {} ); - }; - } - - function clbk() { - return 1.0; - } -}); - -tape( 'the method throws an error if provided a second argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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 Float16Array.from( [], value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not a function (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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 Float16Array.from( [], value, {} ); - }; - } -}); - -tape( 'the method returns a floating-point number array', function test( t ) { - var arr; - var v; - - // Generic array: - arr = Float16Array.from( [] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Float16Array.from( [ 1.0, 2.0, 3.0, 4.0 ] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - // Generic array containing non-numeric values: - arr = Float16Array.from( [ 'beep' ] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - arr = Float16Array.from( [ null, 4 ] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - arr = Float16Array.from( [ true, {}, '' ] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 3, 'returns expected value' ); - - // Typed array: - arr = Float16Array.from( new Uint16Array( 0 ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Float16Array.from( new Uint16Array( [ 1, 1 ] ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // Floating-point number typed array: - arr = Float16Array.from( new Float16Array( 0 ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Float16Array.from( new Float16Array( [ 1.0, 2.0 ] ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method returns a floating-point number array (iterable)', function test( t ) { - var Float16Array; - var iter; - var arr; - var v; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - iter = { - 'next': next, - 'i': 0, - 'N': 4 - }; - arr = Float16Array.from( createIterable( iter ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, iter.N, 'returns expected value' ); - - t.end(); - - function hasSupport() { - return true; - } - - function createIterable( iterator ) { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return iterator; - } - } - - function next() { - iter.i += 1; - if ( iter.i <= iter.N ) { - return { - 'value': 1.0 - }; - } - return { - 'done': true - }; - } -}); - -tape( 'the method supports providing a "map" function which is invoked for each source element', function test( t ) { - var arr; - var v; - - // Generic array: - arr = Float16Array.from( [], clbk1 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Float16Array.from( [ 1.0, 2.0, 3.0, 4.0 ], clbk1 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - // Generic array containing non-numeric values: - arr = Float16Array.from( [ 'beep' ], clbk2 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - arr = Float16Array.from( [ null ], clbk2 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - arr = Float16Array.from( [ [], {} ], clbk1 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - arr = Float16Array.from( [ 4, 5 ], clbk1 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // Typed array: - arr = Float16Array.from( new Uint16Array( 0 ), clbk1 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Float16Array.from( new Uint16Array( [ 1, 1 ] ), clbk1 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // Floating-point number typed array: - arr = Float16Array.from( new Float16Array( 0 ), clbk2 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Float16Array.from( new Float16Array( [ true, true ] ), clbk2 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - t.end(); - - function clbk1( v ) { - return v; - } - - function clbk2() { - return true; - } -}); - -tape( 'the method supports providing a "map" function which is invoked for each iterated value', function test( t ) { - var Float16Array; - var iter; - var arr; - var v; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - iter = { - 'next': next, - 'i': 0, - 'N': 4 - }; - arr = Float16Array.from( createIterable( iter ), clbk ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, iter.N, 'returns expected value' ); - - t.end(); - - function hasSupport() { - return true; - } - - function createIterable( iterator ) { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return iterator; - } - } - - function next() { - iter.i += 1; - if ( iter.i <= iter.N ) { - return { - 'value': 1.0 - }; - } - return { - 'done': true - }; - } - - function clbk( v ) { - return !v; - } -}); - -tape( 'the method supports providing a `this` context for a provided map function', function test( t ) { - var arr; - var ctx; - - ctx = { - 'count': 0 - }; - arr = Float16Array.from( [ 1.0, 2.0, 3.0, 4.0 ], clbk1, ctx ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function clbk1( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v; - } -}); - -tape( 'the method supports providing a `this` context for a provided map function (iterable)', function test( t ) { - var Float16Array; - var iter; - var ctx; - var arr; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - iter = { - 'next': next, - 'i': 0, - 'N': 4 - }; - ctx = { - 'count': 0 - }; - - arr = Float16Array.from( createIterable( iter ), clbk, ctx ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function hasSupport() { - return true; - } - - function createIterable( iterator ) { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return iterator; - } - } - - function next() { - iter.i += 1; - if ( iter.i <= iter.N ) { - return { - 'value': 1.0 - }; - } - return { - 'done': true - }; - } - - function clbk( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v; - } -}); - -tape( 'the method throws an error if provided a non-iterable object (non-ES2015+)', function test( t ) { - var Float16Array; - var values; - var i; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - {}, - { - '0': 1, - '1': 2, - '2': 3 - } - ]; - 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 Float16Array.from( value ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the method throws an error if provided a non-iterable object (ES2015+)', function test( t ) { - var Float16Array; - var values; - var i; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - values = [ - {}, - { - '0': 1, - '1': 2, - '2': 3 - }, - { - '__SYMBOL_ITERATOR__': null - }, - { - '__SYMBOL_ITERATOR__': 'beep' - }, - { - '__SYMBOL_ITERATOR__': nonIterable1 - }, - { - '__SYMBOL_ITERATOR__': nonIterable2 - } - ]; - 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 Float16Array.from( value ); - }; - } - - function hasSupport() { - return true; - } - - function nonIterable1() { - return null; - } - - function nonIterable2() { - return {}; - } -}); diff --git a/test/polyfill/test.includes.js b/test/polyfill/test.includes.js deleted file mode 100644 index 8bb9850..0000000 --- a/test/polyfill/test.includes.js +++ /dev/null @@ -1,222 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `includes` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'includes' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.includes ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.includes.call( value, true ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a numeric value', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 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.includes( value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - 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.includes( true, value ); - }; - } -}); - -tape( 'the method returns `false` if operating on an empty floating-point number array', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( 0 ); - bool = arr.includes( 1.0 ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `false` if a floating-point number is not found', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( 10 ); - bool = arr.includes( 1.0 ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `true` if an array contains a specified floating-point number', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05] ); - bool = arr.includes( float64ToFloat16( 1.05 ) ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `false` if provided a second argument which exceeds the input array length', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( 10 ); - bool = arr.includes( 0.0, 20 ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 1.05, 1.05, 1.05 ] ); - - bool = arr.includes( float64ToFloat16( 1.05 ), 0 ); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = arr.includes( float64ToFloat16( 2.05 ), 1 ); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = arr.includes( float64ToFloat16( 2.05 ), 3 ); - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index (negative)', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 1.05, 1.05, 1.05 ] ); - - bool = arr.includes( float64ToFloat16( 1.05 ), -5 ); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = arr.includes( float64ToFloat16( 2.05 ), -2 ); - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'when provided a starting index which resolves to an index which is less than zero, the method searches from the first array element', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 1.05, 1.05, 1.05 ] ); - - bool = arr.includes( float64ToFloat16( 1.05 ), -10 ); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = arr.includes( float64ToFloat16( 2.05 ), -10 ); - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); -}); diff --git a/test/polyfill/test.index_of.js b/test/polyfill/test.index_of.js deleted file mode 100644 index b432c6d..0000000 --- a/test/polyfill/test.index_of.js +++ /dev/null @@ -1,222 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `indexOf` method for returning the index of an array element', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'indexOf' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.indexOf ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.indexOf.call( value, 1.0 ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a numeric value', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 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.indexOf( value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - 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.indexOf( 1.0, value ); - }; - } -}); - -tape( 'the method returns `-1` if operating on an empty floating-point number array', function test( t ) { - var arr; - var idx; - - arr = new Float16Array(); - idx = arr.indexOf( 1.0 ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `-1` if a numeric value is not found', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( 10 ); - idx = arr.indexOf( 1.0 ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns the index of the first match if a numeric value is found', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - idx = arr.indexOf( float64ToFloat16( 2.05 ) ); - - t.strictEqual( idx, 1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `-1` if provided a second argument which exceeds the input array length', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( 10 ); - idx = arr.indexOf( 1.0, 20 ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 2.05, 5.05 ] ); - - idx = arr.indexOf( float64ToFloat16( 2.05 ), 0 ); - t.strictEqual( idx, 1, 'returns expected value' ); - - idx = arr.indexOf( float64ToFloat16( 2.05 ), 2 ); - t.strictEqual( idx, 3, 'returns expected value' ); - - idx = arr.indexOf( float64ToFloat16( 2.05 ), 4 ); - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index (negative)', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 2.05, 5.05 ] ); - - idx = arr.indexOf( float64ToFloat16( 2.05 ), -5 ); - t.strictEqual( idx, 1, 'returns expected value' ); - - idx = arr.indexOf( float64ToFloat16( 2.05 ), -1 ); - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'when provided a starting index which resolves to an index which is less than zero, the method searches from the first array element', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 2.05, 5.05 ] ); - - idx = arr.indexOf( float64ToFloat16( 2.05 ), -10 ); - t.strictEqual( idx, 1, 'returns expected value' ); - - idx = arr.indexOf( float64ToFloat16( 1.05 ), -10 ); - t.strictEqual( idx, 0, 'returns expected value' ); - t.end(); -}); diff --git a/test/polyfill/test.join.js b/test/polyfill/test.join.js deleted file mode 100644 index 007f1cb..0000000 --- a/test/polyfill/test.join.js +++ /dev/null @@ -1,173 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `join` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'join' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.join ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.join.call( value ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `separator` argument which is not a string', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - 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.join( value ); - }; - } -}); - -tape( 'the method returns an empty string if invoked on an empty array', function test( t ) { - var str; - var arr; - - arr = new Float16Array( 0 ); - str = arr.join(); - - t.strictEqual( str, '', 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a string representation of a floating-point number array with elements separated by a separator', function test( t ) { - var expected; - var str; - var arr; - var i; - - arr = new Float16Array( [ 0.05, 1.05, 2.05, 3.05, 4.05 ] ); - - expected = float64ToFloat16( 0.05 ); - for ( i = 1; i < arr.length; i++ ) { - expected += '@' + float64ToFloat16( i + 0.05 ); - } - - str = arr.join( '@' ); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a string representation of a floating-point number array with elements separated by a separator (single element)', function test( t ) { - var expected; - var str; - var arr; - - arr = new Float16Array( [ 1.05 ] ); - expected = '' + float64ToFloat16( 1.05 ); - - str = arr.join(); - - t.strictEqual( str, expected, 'returns expected value' ); - - arr = new Float16Array( [ 1.05 ] ); - expected = '' + float64ToFloat16( 1.05 ); - - str = arr.join( '@' ); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if the method is invoked without a separator argument, the method returns a string representation of a floating-point number array with elements separated by a comma', function test( t ) { - var expected; - var str; - var arr; - var i; - - arr = new Float16Array( [ 0.05, 1.05, 2.05, 3.05, 4.05 ] ); - - expected = float64ToFloat16( 0.05 ); - for ( i = 1; i < arr.length; i++ ) { - expected += ',' + float64ToFloat16( i + 0.05 ); - } - - str = arr.join(); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); diff --git a/test/polyfill/test.js b/test/polyfill/test.js deleted file mode 100644 index 6e254ad..0000000 --- a/test/polyfill/test.js +++ /dev/null @@ -1,740 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 proxyquire = require( 'proxyquire' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var arr = new Float16Array( 0 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var ctor; - var arr; - - ctor = Float16Array; - - arr = ctor( 0 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (no argument)', function test( t ) { - var arr = new Float16Array(); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (no argument, no new)', function test( t ) { - var ctor; - var arr; - - ctor = Float16Array; - - arr = ctor(); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (length)', function test( t ) { - var arr = new Float16Array( 10 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (length, no new)', function test( t ) { - var ctor; - var arr; - - ctor = Float16Array; - - arr = ctor( 10 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (array)', function test( t ) { - var arr = new Float16Array( [] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (array, no new)', function test( t ) { - var ctor; - var arr; - - ctor = Float16Array; - - arr = ctor( [] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (typed array)', function test( t ) { - var arr = new Float16Array( new Uint16Array( 0 ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (typed array, no new)', function test( t ) { - var ctor; - var arr; - - ctor = Float16Array; - - arr = ctor( new Uint16Array( 0 ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (iterable)', function test( t ) { - var Float16Array; - var arr; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - arr = new Float16Array( createIterable() ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); - - function hasSupport() { - return true; - } - - function createIterable() { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return { - 'next': next - }; - } - - function next() { - return { - 'done': true - }; - } - } -}); - -tape( 'the constructor returns a 16-bit floating-point number array (iterable, no new)', function test( t ) { - var ctor; - var arr; - - ctor = proxyquire( './../../lib/polyfill', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - arr = ctor( createIterable() ); - t.strictEqual( arr instanceof ctor, true, 'returns expected value' ); - - t.end(); - - function hasSupport() { - return true; - } - - function createIterable() { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return { - 'next': next - }; - } - - function next() { - return { - 'done': true - }; - } - } -}); - -tape( 'the constructor returns a 16-bit floating-point number array (ArrayBuffer)', function test( t ) { - var arr = new Float16Array( new ArrayBuffer( 0 ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (ArrayBuffer, no new)', function test( t ) { - var ctor; - var arr; - - ctor = Float16Array; - - arr = ctor( new ArrayBuffer( 0 ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (ArrayBuffer, byte offset)', function test( t ) { - var arr = new Float16Array( new ArrayBuffer( 8 ), 8 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (ArrayBuffer, byte offset, no new)', function test( t ) { - var ctor; - var arr; - - ctor = Float16Array; - - arr = ctor( new ArrayBuffer( 8 ), 8 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (ArrayBuffer, byte offset, length)', function test( t ) { - var arr = new Float16Array( new ArrayBuffer( 8 ), 8, 0 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (ArrayBuffer, byte offset, length, no new)', function test( t ) { - var ctor; - var arr; - - ctor = Float16Array; - - arr = ctor( new ArrayBuffer( 8 ), 8, 0 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'attached to the constructor is a property returning the number of bytes per array element', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Float16Array.BYTES_PER_ELEMENT, 2, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the constructor is a property returning the constructor name', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array, 'name' ), true, 'has property' ); - t.strictEqual( Float16Array.name, 'Float16Array', 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance having a `BYTES_PER_ELEMENT` property returning the number of bytes per array element', function test( t ) { - var arr; - - t.strictEqual( hasOwnProp( Float16Array.prototype, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Float16Array.prototype.BYTES_PER_ELEMENT, 2, 'returns expected value' ); - - arr = new Float16Array( 0 ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance having a `buffer` property for returning the underlying memory (i.e., ArrayBuffer)', function test( t ) { - var arr; - var buf; - - arr = new Float16Array( 0 ); - buf = arr.buffer; - t.strictEqual( isArrayBuffer( buf ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance having a `byteLength` property for returning the number of bytes belonging to the array view', function test( t ) { - var arr; - var v; - - arr = new Float16Array( 0 ); - v = arr.byteLength; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( new ArrayBuffer( 64 ), 8 ); - v = arr.byteLength; - t.strictEqual( v, 56, 'returns expected value' ); - - arr = new Float16Array( new ArrayBuffer( 64 ), 64 ); - v = arr.byteLength; - t.strictEqual( v, 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance having a `byteOffset` property for returning the byte offset pointing to the first array element in the underlying memory', function test( t ) { - var arr; - var v; - - arr = new Float16Array( 0 ); - v = arr.byteOffset; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( new ArrayBuffer( 64 ), 32 ); - v = arr.byteOffset; - t.strictEqual( v, 32, 'returns expected value' ); - - arr = new Float16Array( new ArrayBuffer( 64 ), 64 ); - v = arr.byteOffset; - t.strictEqual( v, 64, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance having a `length` property for returning the number of array elements', function test( t ) { - var arr; - var v; - - // No arguments: - arr = new Float16Array(); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - // Explicit array length: - arr = new Float16Array( 0 ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( 10 ); - v = arr.length; - t.strictEqual( v, 10, 'returns expected value' ); - - // Generic array: - arr = new Float16Array( [] ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - // Typed array: - arr = new Float16Array( new Uint16Array( 0 ) ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( new Uint16Array( [ 1.0, 1.0 ] ) ); - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // Float16 typed array: - arr = new Float16Array( new Float16Array( 0 ) ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( new Float16Array( [ 1.0, 2.0 ] ) ); - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // ArrayBuffer: - arr = new Float16Array( new ArrayBuffer( 64 ), 32 ); - v = arr.length; - t.strictEqual( v, 16, 'returns expected value' ); - - arr = new Float16Array( new ArrayBuffer( 64 ), 64 ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( new ArrayBuffer( 64 ), 32, 2 ); - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance having a `length` property for returning the number of array elements (iterable)', function test( t ) { - var Float16Array; - var iter; - var arr; - var v; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - iter = { - 'next': next, - 'i': 0, - 'N': 4 - }; - arr = new Float16Array( createIterable( iter ) ); - v = arr.length; - t.strictEqual( v, iter.N, 'returns expected value' ); - - t.end(); - - function hasSupport() { - return true; - } - - function createIterable( iterator ) { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return iterator; - } - } - - function next() { - iter.i += 1; - if ( iter.i <= iter.N ) { - return { - 'value': 1.0 - }; - } - return { - 'done': true - }; - } -}); - -tape( 'the constructor throws an error if provided an ArrayBuffer which is not a multiple of 2', function test( t ) { - var values; - var i; - - values = [ - 1, - 3, - 5, - 7, - 9, - 11, - 101, - 1001 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided an ArrayBuffer having a byte length equal to '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Float16Array( new ArrayBuffer( value ) ); - }; - } -}); - -tape( 'the constructor throws an error if provided a non-iterable object (non-ES2015+)', function test( t ) { - var Float16Array; - var values; - var i; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport - }); - - values = [ - {}, - { - '0': 1, - '1': 2, - '2': 3 - } - ]; - 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 new Float16Array( value ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the constructor throws an error if provided a non-iterable object (ES2015+)', function test( t ) { - var Float16Array; - var values; - var i; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/assert-has-iterator-symbol-support': hasSupport, - '@stdlib/symbol-iterator': '__SYMBOL_ITERATOR__' - }); - - values = [ - {}, - { - '0': 1, - '1': 2, - '2': 3 - }, - { - '__SYMBOL_ITERATOR__': null - }, - { - '__SYMBOL_ITERATOR__': 'beep' - }, - { - '__SYMBOL_ITERATOR__': nonIterable1 - }, - { - '__SYMBOL_ITERATOR__': nonIterable2 - } - ]; - 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 new Float16Array( value ); - }; - } - - function hasSupport() { - return true; - } - - function nonIterable1() { - return null; - } - - function nonIterable2() { - return {}; - } -}); - -tape( 'the constructor throws an error if not provided a length, iterable, array-like object, or ArrayBuffer', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - 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 new Float16Array( value ); - }; - } -}); - -tape( 'the constructor throws an error if provided more than one argument and the first argument is not an ArrayBuffer', function test( t ) { - var values; - var i; - - 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 new Float16Array( value, 0 ); - }; - } -}); - -tape( 'the constructor throws an error if provided a byte offset argument which is not a nonnegative integer', function test( t ) { - var values; - var i; - - values = [ - '5', - -1, - 3.14, - 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 new Float16Array( new ArrayBuffer( 64 ), value ); - }; - } -}); - -tape( 'the constructor throws an error if provided a byte offset argument which is not a multiple of 2', function test( t ) { - var values; - var i; - - values = [ - 1, - 3, - 5, - 7, - 9, - 11, - 101, - 1001 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Float16Array( new ArrayBuffer( 1e3 ), value ); - }; - } -}); - -tape( 'the constructor throws an error if provided a byte offset argument such that the view byte length is not a multiple of 8', function test( t ) { - var values; - var i; - - values = [ - 2, - 4, - 6, - 8, - 10, - 12, - 14, - 16, - 18, - 20 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Float16Array( new ArrayBuffer( 101 ), value ); - }; - } -}); - -tape( 'the constructor throws an error if provided a length argument which is not a nonnegative integer (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - -1, - 3.14, - 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 new Float16Array( new ArrayBuffer( 64 ), 0, value ); - }; - } -}); - -tape( 'the constructor throws an error if provided insufficient memory to accommodate byte offset and length arguments', function test( t ) { - var values; - var i; - - values = [ - 8, - 16, - 24, - 32 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Float16Array( new ArrayBuffer( 100 ), value, 1e3 ); - }; - } -}); diff --git a/test/polyfill/test.keys.js b/test/polyfill/test.keys.js deleted file mode 100644 index 59c6210..0000000 --- a/test/polyfill/test.keys.js +++ /dev/null @@ -1,261 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 proxyquire = require( 'proxyquire' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `keys` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'keys' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.keys ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.keys.call( value ); - }; - } -}); - -tape( 'the method returns an iterator protocol-compliant object', function test( t ) { - var expected; - var arr; - var it; - var i; - var r; - var e; - - arr = new Float16Array( [ 1.05, 2.05 ] ); - expected = [ - { - 'value': 0, - 'done': false - }, - { - 'value': 1, - 'done': false - }, - { - 'done': true - } - ]; - it = arr.keys(); - - t.strictEqual( typeof it, 'object', 'returns expected value' ); - t.strictEqual( typeof it.next, 'function', 'has next method' ); - - for ( i = 0; i < expected.length; i++ ) { - r = it.next(); - e = expected[ i ]; - if ( e.value === void 0 ) { - t.deepEqual( r, e, 'returns expected value' ); - } else { - t.strictEqual( r.value, e.value, 'returns expected value' ); - t.strictEqual( r.done, e.done, 'returns expected value' ); - } - } - - t.end(); -}); - -tape( 'the method returns an iterator which does not iterate over empty arrays', function test( t ) { - var expected; - var arr; - var it; - var i; - var v; - - arr = new Float16Array( [] ); - expected = [ - { - 'done': true - }, - { - 'done': true - }, - { - 'done': true - } - ]; - it = arr.keys(); - - t.strictEqual( typeof it, 'object', 'returns expected value' ); - t.strictEqual( typeof it.next, 'function', 'has next method' ); - - for ( i = 0; i < expected.length; i++ ) { - v = it.next(); - t.deepEqual( v, expected[ i ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (no argument)', function test( t ) { - var arr; - var it; - var v; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - it = arr.keys(); - - v = it.next(); - t.strictEqual( v.value, 0, 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, 1, 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.return(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (argument)', function test( t ) { - var arr; - var it; - var v; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - it = arr.keys(); - - v = it.next(); - t.strictEqual( v.value, 0, 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, 1, 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.return( 'beep' ); - t.strictEqual( v.value, 'beep', 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'if an environment supports `Symbol.iterator`, the method returns an iterable', function test( t ) { - var Float16Array; - var arr; - var buf; - var it1; - var it2; - var v1; - var v2; - var i; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - buf = [ 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( buf ); - - it1 = arr.keys(); - t.strictEqual( typeof it1[ '__ITERATOR_SYMBOL__' ], 'function', 'has method' ); - t.strictEqual( it1[ '__ITERATOR_SYMBOL__' ].length, 0, 'has zero arity' ); - - it2 = it1[ '__ITERATOR_SYMBOL__' ](); - t.strictEqual( typeof it2, 'object', 'returns expected value' ); - t.strictEqual( typeof it2.next, 'function', 'has `next` method' ); - t.strictEqual( typeof it2.return, 'function', 'has `return` method' ); - - for ( i = 0; i < arr.length; i++ ) { - v1 = it1.next().value; - v2 = it2.next().value; - t.strictEqual( v1, v2, 'returns expected value' ); - } - t.end(); -}); - -tape( 'if an environment does not support `Symbol.iterator`, the method does not return an "iterable"', function test( t ) { - var Float16Array; - var arr; - var buf; - var it; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/symbol-iterator': false - }); - - buf = [ 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( buf ); - - it = arr.keys(); - t.strictEqual( it[ ITERATOR_SYMBOL ], void 0, 'does not have property' ); - - t.end(); -}); diff --git a/test/polyfill/test.last_index_of.js b/test/polyfill/test.last_index_of.js deleted file mode 100644 index 6a2fe99..0000000 --- a/test/polyfill/test.last_index_of.js +++ /dev/null @@ -1,211 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `lastIndexOf` method for returning the index of an array element', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'lastIndexOf' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.lastIndexOf ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.lastIndexOf.call( value, true ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a numeric value', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 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.lastIndexOf( value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - 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.lastIndexOf( true, value ); - }; - } -}); - -tape( 'the method returns `-1` if operating on an empty floating-point number array', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( 0 ); - idx = arr.lastIndexOf( 0.0 ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `-1` if a numeric value is not found', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( 10 ); - idx = arr.lastIndexOf( 1.0 ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns the index of the first match when searching from the end of the array if a search element is found', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 1.05, 2.05 ] ); - idx = arr.lastIndexOf( float64ToFloat16( 1.05 ) ); - - t.strictEqual( idx, 2, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 2.05, 1.05, 1.05 ] ); - - idx = arr.lastIndexOf( float64ToFloat16( 1.05 ), 4 ); - t.strictEqual( idx, 4, 'returns expected value' ); - - idx = arr.lastIndexOf( float64ToFloat16( 2.05 ), 2 ); - t.strictEqual( idx, 2, 'returns expected value' ); - - idx = arr.lastIndexOf( float64ToFloat16( 2.05 ), 0 ); - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index (negative)', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 2.05, 1.05, 1.05 ] ); - - idx = arr.lastIndexOf( float64ToFloat16( 1.05 ), -3 ); - t.strictEqual( idx, 0, 'returns expected value' ); - - idx = arr.lastIndexOf( float64ToFloat16( 2.05 ), -1 ); - t.strictEqual( idx, 2, 'returns expected value' ); - t.end(); -}); - -tape( 'when the method is provided a starting index which resolves to an index which exceeds the maximum array index, the method searches from the last array element', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 2.05, 1.05, 1.05 ] ); - - idx = arr.lastIndexOf( float64ToFloat16( 1.05 ), 10 ); - t.strictEqual( idx, 4, 'returns expected value' ); - - idx = arr.lastIndexOf( float64ToFloat16( 2.05 ), 10 ); - t.strictEqual( idx, 2, 'returns expected value' ); - t.end(); -}); diff --git a/test/polyfill/test.map.js b/test/polyfill/test.map.js deleted file mode 100644 index 233d1d8..0000000 --- a/test/polyfill/test.map.js +++ /dev/null @@ -1,178 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 identity = require( '@stdlib/utils-identity-function' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `map` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'map' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.map ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.map.call( value, identity ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.map( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.map( identity ); - - t.strictEqual( instanceOf( out, Float16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - t.notEqual( out, arr, 'returns a new instance' ); - t.end(); -}); - -tape( 'the method returns a new floating-point number array containing elements which are the result of a provided callback function', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( -1.05 ), - toWord( -2.05 ), - toWord( -3.05 ), - toWord( -4.05 ) - ]); - actual = arr.map( invert ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.notEqual( actual, arr, 'returns a new instance' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); - - function invert( v ) { - return -v; - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var expected; - var actual; - var arr; - var buf; - var ctx; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( -1.05 ), - toWord( -2.05 ), - toWord( -3.05 ), - toWord( -4.05 ) - ]); - ctx = { - 'count': 0 - }; - actual = arr.map( invert, ctx ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.strictEqual( ctx.count, 6, 'returns expected value' ); - t.end(); - - function invert( v, i ) { - this.count += i; // eslint-disable-line no-invalid-this - return -v; - } -}); diff --git a/test/polyfill/test.of.js b/test/polyfill/test.of.js deleted file mode 100644 index 5031bb5..0000000 --- a/test/polyfill/test.of.js +++ /dev/null @@ -1,130 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `of` method for creating a 16-bit floating-point number array from a variable number of arguments', function test( t ) { - var arr; - - t.strictEqual( hasOwnProp( Float16Array, 'of' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.of ), true, 'has method' ); - - arr = Float16Array.of(); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a constructor', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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 Float16Array.of.call( value, true, true ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point array constructor', function test( t ) { - var values; - var i; - - values = [ - {}, - null, - 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 Float16Array.of.call( value, true, true ); - }; - } -}); - -tape( 'the method returns a floating-point number array', function test( t ) { - var arr; - var v; - - // No arguments: - arr = Float16Array.of(); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - // Numeric arguments: - arr = Float16Array.of( 1.0, 2.0, 3.0, 4.0 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - // Non-numeric arguments: - arr = Float16Array.of( 1, {}, 0, null, 'beep' ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 5, 'returns expected value' ); - - // Mixed arguments: - arr = Float16Array.of( true, 1, false, 0 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - t.end(); -}); diff --git a/test/polyfill/test.reduce.js b/test/polyfill/test.reduce.js deleted file mode 100644 index 7d9cbc0..0000000 --- a/test/polyfill/test.reduce.js +++ /dev/null @@ -1,189 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `reduce` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'reduce' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.reduce ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.reduce.call( value, reducer ); - }; - } - - function reducer( acc, value ) { - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.reduce( value ); - }; - } -}); - -tape( 'the method throws an error if not provided an initial value when operating on an empty floating-point number array', function test( t ) { - var arr; - - arr = new Float16Array( 0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - arr.reduce( reducer ); - } - - function reducer( acc, value ) { - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method uses the first element of the array as the initial value when an initial value is not provided', function test( t ) { - var valueArray; - var accArray; - var expected; - var actual; - var arr; - var ind; - - arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - accArray = [ 1.0, 3.0 ]; - valueArray = [ 2.0, 3.0 ]; - expected = float64ToFloat16( 6.0 ); - actual = arr.reduce( reducer ); - - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); - - function reducer( acc, value, index ) { - ind = index-1; - t.strictEqual( acc, float64ToFloat16( accArray[ ind ] ), 'returns expected value' ); - t.strictEqual( value, float64ToFloat16( valueArray[ ind ] ), 'returns expected value' ); - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method supports providing an initial value as the second argument', function test( t ) { - var valueArray; - var accArray; - var expected; - var actual; - var arr; - - arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - accArray = [ 2.0, 3.0, 5.0 ]; - valueArray = [ 1.0, 2.0, 3.0 ]; - expected = 8.0; - actual = arr.reduce( reducer, 2.0 ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value, index ) { - t.strictEqual( acc, float64ToFloat16( accArray[ index ] ), 'returns expected value' ); - t.strictEqual( value, float64ToFloat16( valueArray[ index ] ), 'returns expected value' ); - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method returns the accumulated result', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = float64ToFloat16( 10.20 ); - actual = arr.reduce( reducer ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value ) { - return float64ToFloat16( acc + value ); - } -}); diff --git a/test/polyfill/test.reduce_right.js b/test/polyfill/test.reduce_right.js deleted file mode 100644 index 0d27e43..0000000 --- a/test/polyfill/test.reduce_right.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `reduceRight` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'reduceRight' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.reduceRight ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.reduceRight.call( value, reducer ); - }; - } - - function reducer( acc, value ) { - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.reduceRight( value ); - }; - } -}); - -tape( 'the method throws an error if not provided an initial value when operating on an empty floating-point number array', function test( t ) { - var arr; - - arr = new Float16Array( 0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - arr.reduceRight( reducer ); - } - - function reducer( acc, value ) { - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method uses the last element of the array as the initial value when an initial value is not provided', function test( t ) { - var valueArray; - var accArray; - var expected; - var actual; - var arr; - var len; - - arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - len = arr.length; - accArray = [ 3.0, 5.0 ]; - valueArray = [ 2.0, 1.0 ]; - expected = float64ToFloat16( 6.0 ); - actual = arr.reduceRight( reducer ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value, index ) { - var ind = (len-index-2); - t.strictEqual( acc, float64ToFloat16( accArray[ ind ] ), 'returns expected value' ); - t.strictEqual( value, float64ToFloat16( valueArray[ ind ] ), 'returns expected value' ); - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method supports providing an initial value as the second argument', function test( t ) { - var valueArray; - var accArray; - var expected; - var actual; - var arr; - var len; - - arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - len = arr.length; - accArray = [ 2.0, 5.0, 7.0 ]; - valueArray = [ 3.0, 2.0, 1.0 ]; - expected = 8.0; - actual = arr.reduceRight( reducer, 2.0 ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value, index ) { - var ind = (len-index-1); - t.strictEqual( acc, float64ToFloat16( accArray[ ind ] ), 'returns expected value' ); - t.strictEqual( value, float64ToFloat16( valueArray[ ind ] ), 'returns expected value' ); - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method returns the accumulated result', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = float64ToFloat16( 10.20 ); - actual = arr.reduceRight( reducer ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value ) { - return float64ToFloat16( acc + value ); - } -}); diff --git a/test/polyfill/test.reverse.js b/test/polyfill/test.reverse.js deleted file mode 100644 index 080a4c3..0000000 --- a/test/polyfill/test.reverse.js +++ /dev/null @@ -1,122 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 instanceOf = require( '@stdlib/assert-instance-of' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, '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( Float16Array.prototype, 'reverse' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.reverse ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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 floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - 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 floating-point number array in-place', function test( t ) { - var expected; - var arr; - var buf; - var out; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05, 5.05 ] ); - expected = new Uint16Array([ - toWord( 5.05 ), - toWord( 4.05 ), - toWord( 3.05 ), - toWord( 2.05 ), - toWord( 1.05 ) - ]); - out = arr.reverse(); - buf = new Uint16Array( arr.buffer ); - - t.strictEqual( instanceOf( arr, Float16Array ), true, 'returns expected value' ); - t.strictEqual( out, arr, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 10 ); - out = arr.reverse(); - - t.strictEqual( out.length, 10, 'returns expected value' ); - t.end(); -}); diff --git a/test/polyfill/test.set.js b/test/polyfill/test.set.js deleted file mode 100644 index d5e0ebb..0000000 --- a/test/polyfill/test.set.js +++ /dev/null @@ -1,259 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `set` method for setting one or more array elements', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.set ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.set.call( value, 0 ); - }; - } -}); - -tape( 'the method throws an error if provided an index argument which is not a nonnegative integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - -5, - 3.14, - 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.set( [ 1.0 ], value ); - }; - } -}); - -tape( 'the method throws an error if provided an index argument which is out-of-bounds', function test( t ) { - var values; - var arr1; - var arr2; - var i; - - arr1 = new Float16Array( 10 ); - arr2 = []; - for ( i = 0; i < arr1.length; i++ ) { - arr2.push( 1.0 ); - } - - values = [ - 1, - 2, - 3, - 4, - 5 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr1.set( arr2, value ); - }; - } -}); - -tape( 'the method sets one or more array elements', function test( t ) { - var arr; - var v; - var i; - - arr = new Float16Array( 10 ); - - v = arr[ 0 ]; - t.strictEqual( v, 0.0, 'returns expected value' ); - - // No index argument: - arr.set( [ 1.0 ] ); - - v = arr[ 0 ]; - t.strictEqual( v, 1.0, 'returns expected value' ); - - arr.set( [ 0.0 ] ); - - // Index argument: - for ( i = 0; i < arr.length; i++ ) { - v = arr[ i ]; - t.strictEqual( v, 0.0, 'returns expected value' ); - - arr.set( [ 1.05 ], i ); - - v = arr[ i ]; - t.strictEqual( v, float64ToFloat16( 1.05 ), 'returns expected value' ); - } - - // Multiple values, no index argument: - arr.set( [ 1.05, 2.05 ] ); - - v = arr[ 0 ]; - t.strictEqual( v, float64ToFloat16( 1.05 ), 'returns expected value' ); - - v = arr[ 1 ]; - t.strictEqual( v, float64ToFloat16( 2.05 ), 'returns expected value' ); - - // Multiple values, index argument: - arr.set( [ 1.05, 2.05 ], 2 ); - - v = arr[ 2 ]; - t.strictEqual( v, float64ToFloat16( 1.05 ), 'returns expected value' ); - - v = arr[ 3 ]; - t.strictEqual( v, float64ToFloat16( 2.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method sets an array element (floating-point number array; shared buffer)', function test( t ) { - var byteOffset; - var arr; - var src; - var buf; - var ab; - var v; - var i; - - byteOffset = 112; - - ab = new ArrayBuffer( 240 ); - arr = new Float16Array( ab, byteOffset, 10 ); - - // Overlapping (requires copy), multiple values, no index argument: - buf = [ 1.05, 2.05 ]; - src = new Float16Array( ab, byteOffset-(1*arr.BYTES_PER_ELEMENT), 2 ); - for ( i = 0; i < buf.length; i++ ) { - src[ i ] = buf[ i ]; - } - arr.set( src ); - - v = arr[ 0 ]; - t.strictEqual( v, float64ToFloat16( buf[ 0 ] ), 'returns expected value' ); - - v = arr[ 1 ]; - t.strictEqual( v, float64ToFloat16( buf[ 1 ] ), 'returns expected value' ); - - // Overlapping (requires copy), multiple values, index argument: - buf = [ -1.05, -2.05 ]; - src = new Float16Array( ab, byteOffset+(1*arr.BYTES_PER_ELEMENT), 2 ); - for ( i = 0; i < buf.length; i++ ) { - src[ i ] = buf[ i ]; - } - arr.set( src, 2 ); - - v = arr[ 2 ]; - t.strictEqual( v, float64ToFloat16( buf[ 0 ] ), 'returns expected value' ); - - v = arr[ 3 ]; - t.strictEqual( v, float64ToFloat16( buf[ 1 ] ), 'returns expected value' ); - - // Overlapping (no copy), multiple values, no index argument: - buf = [ 3.05, 4.05 ]; - src = new Float16Array( ab, byteOffset+(1*arr.BYTES_PER_ELEMENT), 2 ); - for ( i = 0; i < buf.length; i++ ) { - src[ i ] = buf[ i ]; - } - arr.set( src ); - - v = arr[ 0 ]; - t.strictEqual( v, float64ToFloat16( buf[ 0 ] ), 'returns expected value' ); - - v = arr[ 1 ]; - t.strictEqual( v, float64ToFloat16( buf[ 1 ] ), 'returns expected value' ); - - // Overlapping (no copy), multiple values, index argument: - buf = [ -3.05, -4.05 ]; - src = new Float16Array( ab, byteOffset+(3*arr.BYTES_PER_ELEMENT), 2 ); - for ( i = 0; i < buf.length; i++ ) { - src[ i ] = buf[ i ]; - } - arr.set( src, 2 ); - - v = arr[ 2 ]; - t.strictEqual( v, float64ToFloat16( buf[ 0 ] ), 'returns expected value' ); - - v = arr[ 3 ]; - t.strictEqual( v, float64ToFloat16( buf[ 1 ] ), 'returns expected value' ); - - t.end(); -}); diff --git a/test/polyfill/test.slice.js b/test/polyfill/test.slice.js deleted file mode 100644 index f6743cb..0000000 --- a/test/polyfill/test.slice.js +++ /dev/null @@ -1,311 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 instanceOf = require( '@stdlib/assert-instance-of' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `slice` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'slice' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.slice ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.slice.call( value ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.slice( value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.slice( 0, value ); - }; - } -}); - -tape( 'the method returns an empty typed array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.slice(); - - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'if called without arguments, the method returns a typed array containing the same elements as the original array', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ) - ]); - actual = arr.slice(); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.notEqual( actual, arr, 'returns a new instance' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if called with one argument, the method returns a typed array containing elements starting from a specified beginning index (inclusive)', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ) - ]); - actual = arr.slice( 1 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if provided two arguments, the method returns a typed array containing elements starting from a specified beginning index (inclusive) and ending at a specified stop index (exclusive)', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ) - ]); - actual = arr.slice( 1, 3 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ) - ]); - actual = arr.slice( 1, 30 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method resolves negative indices relative to the last element', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ) - ]); - actual = arr.slice( -3, -1 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ) - ]); - actual = arr.slice( -30, -2 ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty typed array if a resolved beginning index exceeds a resolved ending index', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array( [] ); - actual = arr.slice( 2, 0 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty typed array if a resolved beginning index exceeds the maximum array index', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array( [] ); - actual = arr.slice( 5 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty typed array if a resolved ending index is less than or equal to zero', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); - expected = new Uint16Array( [] ); - actual = arr.slice( 2, -8 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - - actual = arr.slice( 1, 0 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); diff --git a/test/polyfill/test.some.js b/test/polyfill/test.some.js deleted file mode 100644 index dfa9cda..0000000 --- a/test/polyfill/test.some.js +++ /dev/null @@ -1,196 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `some` method for returning boolean indicating whether at least one element passes a test', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'some' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.some ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.some.call( value, predicate ); - }; - } - - function predicate( v ) { - return v === 1.0; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.some( value ); - }; - } -}); - -tape( 'the method returns `false` if operating on an empty floating-point number array', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( 0 ); - bool = arr.some( predicate ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns `true` if at least one element passes a test', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - bool = arr.some( predicate ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v === float64ToFloat16( 1.05 ); - } -}); - -tape( 'the method returns `false` if all elements fail a test', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - bool = arr.some( predicate ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v === float64ToFloat16( 5.05 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var bool; - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - bool = arr.some( predicate, ctx ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v === float64ToFloat16( 4.05 ); - } -}); - -tape( 'the method stops executing upon encountering the first element which passes a test', function test( t ) { - var bool; - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - bool = arr.some( predicate, ctx ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.strictEqual( ctx.count, 1, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v === float64ToFloat16( 1.05 ); - } -}); diff --git a/test/polyfill/test.sort.js b/test/polyfill/test.sort.js deleted file mode 100644 index 1ebbfd6..0000000 --- a/test/polyfill/test.sort.js +++ /dev/null @@ -1,189 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 instanceOf = require( '@stdlib/assert-instance-of' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Comparison function. -* -* @private -* @param {boolean} a - first value for comparison -* @param {boolean} b - second value for comparison -* @returns {number} comparison result -*/ -function compareFcn( a, b ) { - if ( a < b ) { - return -1; - } - if ( a > b ) { - return 1; - } - return 0; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `sort` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'sort' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.sort ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.sort.call( value, compareFcn ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.sort( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.sort( compareFcn ); - - t.strictEqual( out.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the method sorts elements of a floating-point number array in-place', function test( t ) { - var expected; - var arr; - var out; - var buf; - - arr = new Float16Array( [ 4.05, 3.05, 1.05, 5.05, 2.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ), - toWord( 5.05 ) - ]); - out = arr.sort( compareFcn ); - buf = new Uint16Array( out.buffer ); - - t.strictEqual( instanceOf( arr, Float16Array ), true, 'returns expected value' ); - t.strictEqual( out, arr, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - - arr = new Float16Array( [ 2.05, 1.05, -1.05, 0.05, -2.05 ] ); - expected = new Uint16Array([ - toWord( -2.05 ), - toWord( -1.05 ), - toWord( 0.05 ), - toWord( 1.05 ), - toWord( 2.05 ) - ]); - out = arr.sort( compareFcn ); - buf = new Uint16Array( out.buffer ); - - t.strictEqual( instanceOf( arr, Float16Array ), true, 'returns expected value' ); - t.strictEqual( out, arr, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Float16Array( [ 4.05, 3.05, 1.05, 5.05, 2.05 ] ); - out = arr.sort( compareFcn ); - - t.strictEqual( out.length, arr.length, 'returns expected value' ); - t.end(); -}); diff --git a/test/polyfill/test.subarray.js b/test/polyfill/test.subarray.js deleted file mode 100644 index c6d42d1..0000000 --- a/test/polyfill/test.subarray.js +++ /dev/null @@ -1,308 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 instanceOf = require( '@stdlib/assert-instance-of' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `subarray` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'subarray' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.subarray ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.subarray.call( value ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.subarray( value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.subarray( 0, value ); - }; - } -}); - -tape( 'the method returns empty array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.subarray(); - - t.strictEqual( out.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'if called without arguments, the method returns a view containing the same elements as the original array', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ) - ]); - actual = arr.subarray(); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if called with one argument, the method returns a view containing elements starting from a specified beginning index (inclusive)', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ) - ]); - actual = arr.subarray( 1 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if provided two arguments, the method returns a view containing elements starting from a specified beginning index (inclusive) and ending at a specified stop index (exclusive)', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ) - ]); - actual = arr.subarray( 1, 3 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method resolves negative indices relative to the last element', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ) - ]); - actual = arr.subarray( -3, -1 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 2.05 ) - ]); - actual = arr.subarray( -30, -2 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty view if a resolved beginning index exceeds a resolved ending index', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array( [] ); - actual = arr.subarray( 2, 0 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty view if a resolved beginning index exceeds the maximum array index', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array( [] ); - actual = arr.subarray( 5 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty view if a resolved ending index is less than or equal to zero', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array( [] ); - actual = arr.subarray( 2, -8 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - - actual = arr.subarray( 1, 0 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); diff --git a/test/polyfill/test.to_locale_string.js b/test/polyfill/test.to_locale_string.js deleted file mode 100644 index 96fb9b0..0000000 --- a/test/polyfill/test.to_locale_string.js +++ /dev/null @@ -1,187 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `toLocaleString` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'toLocaleString' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.toLocaleString ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.toLocaleString.call( value ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a string or an array of strings', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 0 ); - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - {}, - [ 1, 2, 3 ], - 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.toLocaleString( value ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a string or an array of strings (options)', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 0 ); - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - {}, - [ 1, 2, 3 ], - 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.toLocaleString( value, {} ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an object', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array(); - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - 'beep', - [], - 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.toLocaleString( 'en-GB', value ); - }; - } -}); - -tape( 'the method returns an empty string if invoked on an empty array', function test( t ) { - var str; - var arr; - - arr = new Float16Array( 0 ); - str = arr.toLocaleString(); - - t.strictEqual( str, '', 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a string representation of a floating-point number array', function test( t ) { - var expected; - var str; - var arr; - - arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - expected = '1,2,3'; - - str = arr.toLocaleString(); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); diff --git a/test/polyfill/test.to_reversed.js b/test/polyfill/test.to_reversed.js deleted file mode 100644 index a3f8da5..0000000 --- a/test/polyfill/test.to_reversed.js +++ /dev/null @@ -1,121 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 instanceOf = require( '@stdlib/assert-instance-of' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, '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( Float16Array.prototype, 'toReversed' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.toReversed ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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 floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - 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 buf; - var out; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05, 5.05 ] ); - expected = new Uint16Array([ - toWord( 5.05 ), - toWord( 4.05 ), - toWord( 3.05 ), - toWord( 2.05 ), - toWord( 1.05 ) - ]); - out = arr.toReversed(); - buf = new Uint16Array( out.buffer ); - - t.strictEqual( instanceOf( out, Float16Array ), true, 'returns expected value' ); - t.notEqual( out, arr, 'returns a new instance' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 10 ); - out = arr.toReversed(); - - t.strictEqual( out.length, 10, 'returns expected value' ); - t.end(); -}); diff --git a/test/polyfill/test.to_sorted.js b/test/polyfill/test.to_sorted.js deleted file mode 100644 index e011bef..0000000 --- a/test/polyfill/test.to_sorted.js +++ /dev/null @@ -1,172 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 instanceOf = require( '@stdlib/assert-instance-of' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// FUNCTIONS // - -/** -* Comparison function. -* -* @private -* @param {boolean} a - first value for comparison -* @param {boolean} b - second value for comparison -* @returns {number} comparison result -*/ -function compareFcn( a, b ) { - if ( a < b ) { - return -1; - } - if ( a > b ) { - return 1; - } - return 0; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `toSorted` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'toSorted' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.toSorted ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.toSorted.call( value, compareFcn ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.toSorted( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.toSorted( compareFcn ); - - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a new typed array containing elements in sorted order', function test( t ) { - var expected; - var arr; - var out; - var buf; - - arr = new Float16Array( [ 4.05, 3.05, 1.05, 5.05, 2.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ), - toWord( 5.05 ) - ]); - out = arr.toSorted( compareFcn ); - buf = new Uint16Array( out.buffer ); - - t.strictEqual( instanceOf( out, Float16Array ), true, 'returns expected value' ); - t.notEqual( out, arr, 'returns a new instance' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Float16Array( [ 4.05, 3.05, 1.05, 5.05, 2.05 ] ); - out = arr.toSorted( compareFcn ); - - t.strictEqual( out.length, arr.length, 'returns expected value' ); - t.end(); -}); diff --git a/test/polyfill/test.to_string.js b/test/polyfill/test.to_string.js deleted file mode 100644 index b0c098b..0000000 --- a/test/polyfill/test.to_string.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `toString` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.toString ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.toString.call( value ); - }; - } -}); - -tape( 'the method returns an empty string if invoked on an empty array', function test( t ) { - var str; - var arr; - - arr = new Float16Array( 0 ); - str = arr.toString(); - - t.strictEqual( str, '', 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a string representation of a floating-point number array', function test( t ) { - var expected; - var str; - var arr; - - arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - expected = '1,2,3,4'; - - str = arr.toString(); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); diff --git a/test/polyfill/test.values.js b/test/polyfill/test.values.js deleted file mode 100644 index ce5fc09..0000000 --- a/test/polyfill/test.values.js +++ /dev/null @@ -1,264 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 proxyquire = require( 'proxyquire' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var isNumber = require( '@stdlib/assert-is-number' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `values` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'values' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.values ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.values.call( value ); - }; - } -}); - -tape( 'the method returns an iterator protocol-compliant object', function test( t ) { - var expected; - var arr; - var it; - var i; - var r; - var e; - - arr = new Float16Array( [ 1.05, 2.05 ] ); - expected = [ - { - 'value': float64ToFloat16( 1.05 ), - 'done': false - }, - { - 'value': float64ToFloat16( 2.05 ), - 'done': false - }, - { - 'done': true - } - ]; - it = arr.values(); - - t.strictEqual( typeof it, 'object', 'returns expected value' ); - t.strictEqual( typeof it.next, 'function', 'has next method' ); - - for ( i = 0; i < expected.length; i++ ) { - r = it.next(); - e = expected[ i ]; - if ( e.value === void 0 ) { - t.deepEqual( r, e, 'returns expected value' ); - } else { - t.strictEqual( isNumber( r.value ), true, 'returns expected value' ); - t.strictEqual( r.value, e.value, 'returns expected value' ); - t.strictEqual( r.done, e.done, 'returns expected value' ); - } - } - - t.end(); -}); - -tape( 'the method returns an iterator which does not iterate over empty arrays', function test( t ) { - var expected; - var arr; - var it; - var i; - var v; - - arr = new Float16Array( [] ); - expected = [ - { - 'done': true - }, - { - 'done': true - }, - { - 'done': true - } - ]; - it = arr.values(); - - t.strictEqual( typeof it, 'object', 'returns expected value' ); - t.strictEqual( typeof it.next, 'function', 'has next method' ); - - for ( i = 0; i < expected.length; i++ ) { - v = it.next(); - t.deepEqual( v, expected[ i ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (no argument)', function test( t ) { - var arr; - var it; - var v; - - arr = new Float16Array( [ 1.05, 2.05, 3.05 ] ); - it = arr.values(); - - v = it.next(); - t.strictEqual( v.value, float64ToFloat16( 1.05 ), 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, float64ToFloat16( 2.05 ), 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.return(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (argument)', function test( t ) { - var arr; - var it; - var v; - - arr = new Float16Array( [ 1.05, 2.05, 3.05 ] ); - it = arr.values(); - - v = it.next(); - t.strictEqual( v.value, float64ToFloat16( 1.05 ), 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, float64ToFloat16( 2.05 ), 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.return( 'beep' ); - t.strictEqual( v.value, 'beep', 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'if an environment supports `Symbol.iterator`, the method returns an iterable', function test( t ) { - var Float16Array; - var arr; - var buf; - var it1; - var it2; - var v1; - var v2; - var i; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/symbol-iterator': '__ITERATOR_SYMBOL__' - }); - - buf = [ 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( buf ); - - it1 = arr.values(); - t.strictEqual( typeof it1[ '__ITERATOR_SYMBOL__' ], 'function', 'has method' ); - t.strictEqual( it1[ '__ITERATOR_SYMBOL__' ].length, 0, 'has zero arity' ); - - it2 = it1[ '__ITERATOR_SYMBOL__' ](); - t.strictEqual( typeof it2, 'object', 'returns expected value' ); - t.strictEqual( typeof it2.next, 'function', 'has `next` method' ); - t.strictEqual( typeof it2.return, 'function', 'has `return` method' ); - - for ( i = 0; i < arr.length; i++ ) { - v1 = it1.next().value; - v2 = it2.next().value; - t.strictEqual( v1, v2, 'returns expected value' ); - } - t.end(); -}); - -tape( 'if an environment does not support `Symbol.iterator`, the method does not return an "iterable"', function test( t ) { - var Float16Array; - var arr; - var buf; - var it; - - Float16Array = proxyquire( './../../lib/polyfill', { - '@stdlib/symbol-iterator': false - }); - - buf = [ 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( buf ); - - it = arr.values(); - t.strictEqual( it[ ITERATOR_SYMBOL ], void 0, 'does not have property' ); - - t.end(); -}); diff --git a/test/polyfill/test.with.js b/test/polyfill/test.with.js deleted file mode 100644 index 0b6eda1..0000000 --- a/test/polyfill/test.with.js +++ /dev/null @@ -1,213 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../../lib/polyfill' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `with` method', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array.prototype, 'with' ), true, 'has property' ); - t.strictEqual( isFunction( Float16Array.prototype.with ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.with.call( value, 0, true ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 3.14, - 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.with( value, true ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not in bounds', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - -11, - -12, - 11, - 12 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.with( value, 1.0 ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not a numeric value', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 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.with( 0, value ); - }; - } -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 10 ); - out = arr.with( 5, 1.0 ); - - t.strictEqual( out.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a new floating-point number array with the element at a provided index replaced with a provided value', function test( t ) { - var expected; - var arr; - var buf; - var out; - - arr = new Float16Array( [ 1.05, 1.05, 1.05, 1.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 1.05 ), - toWord( 1.05 ), - toWord( 2.05 ) - ]); - out = arr.with( 3, 2.05 ); - buf = new Uint16Array( out.buffer ); - - t.strictEqual( out instanceof Float16Array, true, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.notEqual( out, arr, 'returns new instance' ); - t.end(); -}); - -tape( 'the method supports negative indices', function test( t ) { - var expected; - var arr; - var buf; - var out; - - arr = new Float16Array( [ 1.05, 1.05, 1.05, 1.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 1.05 ), - toWord( 1.05 ), - toWord( 2.05 ) - ]); - out = arr.with( -1, 2.05 ); - buf = new Uint16Array( out.buffer ); - - t.strictEqual( out instanceof Float16Array, true, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.at.js b/test/test.at.js deleted file mode 100644 index 19df3bd..0000000 --- a/test/test.at.js +++ /dev/null @@ -1,111 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `at` method for returning an array element', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.at ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.at.call( value, 0 ); - }; - } -}); - -tape( 'the method returns `undefined` if provided an index which exceeds array dimensions', function test( t ) { - var arr; - var v; - var i; - - arr = new Float16Array( 10 ); - for ( i = -arr.length; i < arr.length; i++ ) { - if ( i < 0 ) { - v = arr.at( i-arr.length ); - t.strictEqual( v, void 0, 'returns expected value for index '+(i-arr.length) ); - } else { - v = arr.at( arr.length+i ); - t.strictEqual( v, void 0, 'returns expected value for index '+(arr.length+i) ); - } - } - t.end(); -}); - -tape( 'the method returns an array element', function test( t ) { - var arr; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( i+0.05 ); - } - - arr = new Float16Array( arr ); - - for ( i = -arr.length; i < arr.length; i++ ) { - v = arr.at( i ); - if ( i < 0 ) { - t.strictEqual( v, float64ToFloat16( arr.length + i + 0.05 ), 'returns expected value for index '+i ); - } else { - t.strictEqual( v, float64ToFloat16( i + 0.05 ), 'returns expected value for index '+i ); - } - } - t.end(); -}); diff --git a/test/test.copy_within.js b/test/test.copy_within.js deleted file mode 100644 index d286509..0000000 --- a/test/test.copy_within.js +++ /dev/null @@ -1,279 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `copyWithin` method for copying a sequence of array elements within a floating-point number array', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within an array', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( 0, 3 ); - buf = new Uint16Array( arr.buffer ); - - // Overwritten: - t.strictEqual( buf[ 0 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 4.05 ), 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 2 ], toWord( 2.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (negative target)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( -arr.length, 3 ); - buf = new Uint16Array( arr.buffer ); - - // Overwritten: - t.strictEqual( buf[ 0 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 4.05 ), 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 2 ], toWord( 2.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (negative start)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( 0, -2 ); - buf = new Uint16Array( arr.buffer ); - - // Overwritten: - t.strictEqual( buf[ 0 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 4.05 ), 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 2 ], toWord( 2.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (end=length)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( 0, 3, arr.length ); - buf = new Uint16Array( arr.buffer ); - - // Overwritten: - t.strictEqual( buf[ 0 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 4.05 ), 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 2 ], toWord( 2.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (non-inclusive end)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( 2, 0, 2 ); - buf = new Uint16Array( arr.buffer ); - - // Remain the same: - t.strictEqual( buf[ 0 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - - // Overwritten: - t.strictEqual( buf[ 2 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 1.05 ), 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (negative end)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( 2, 0, -3 ); - buf = new Uint16Array( arr.buffer ); - - // Remain the same: - t.strictEqual( buf[ 0 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - - // Overwritten: - t.strictEqual( buf[ 2 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 1.05 ), 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (target >= length)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( arr.length, 3 ); - buf = new Uint16Array( arr.buffer ); - - // Remain the same: - t.strictEqual( buf[ 0 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 2 ], toWord( 2.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 3.05 ), 'returns expected value' ); - t.strictEqual( buf[ 4 ], toWord( 4.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (target > start)', function test( t ) { - var arr; - var buf; - - arr = [ 0.05, 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( arr ); - - arr.copyWithin( 2, 0 ); - buf = new Uint16Array( arr.buffer ); - - // Remain the same: - t.strictEqual( buf[ 0 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - - // Overwritten: - t.strictEqual( buf[ 2 ], toWord( 0.05 ), 'returns expected value' ); - t.strictEqual( buf[ 3 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 4 ], toWord( 2.05 ), 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.entries.js b/test/test.entries.js deleted file mode 100644 index 396dd8e..0000000 --- a/test/test.entries.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isNumber = require( '@stdlib/assert-is-number' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `entries` method for returning an iterator for iterating over array key-value pairs', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.entries ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.entries.call( value ); - }; - } -}); - -tape( 'the method returns an iterator protocol-compliant object', function test( t ) { - var buf; - var arr; - var it; - var v; - var i; - - buf = [ 1.05, 2.05, 3.05, 4.05 ]; - arr = new Float16Array( buf ); - - it = arr.entries(); - t.strictEqual( it.next.length, 0, 'has zero arity' ); - - for ( i = 0; i < arr.length; i++ ) { - v = it.next(); - t.strictEqual( isArray( v.value ), true, 'returns expected value' ); - t.strictEqual( v.value[ 0 ], i, 'returns expected value' ); - t.strictEqual( isNumber( v.value[ 1 ] ), true, 'returns expected value' ); - t.strictEqual( v.value[ 1 ], float64ToFloat16( buf[ i ] ), 'returns expected value' ); - t.strictEqual( typeof v.done, 'boolean', 'returns expected value' ); - } - t.end(); -}); diff --git a/test/test.every.js b/test/test.every.js deleted file mode 100644 index 0742d6a..0000000 --- a/test/test.every.js +++ /dev/null @@ -1,172 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `every` method for returning boolean indicating whether all elements pass a test', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.every ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.every.call( value, predicate ); - }; - } - - function predicate( v ) { - return v === 0.0; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.every( value ); - }; - } -}); - -tape( 'the method returns `true` if operating on an empty floating-point number array', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( 0 ); - bool = arr.every( predicate ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns `true` if all elements pass a test', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 1.05, 1.05, 1.05 ] ); - bool = arr.every( predicate ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v === float64ToFloat16( 1.05 ); - } -}); - -tape( 'the method returns `false` if one or more elements fail a test', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 1.05, 0.05, 1.05 ] ); - bool = arr.every( predicate ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v === float64ToFloat16( 1.05 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var bool; - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ 1.05, 1.05, 1.05, 1.05 ] ); - bool = arr.every( predicate, ctx ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v === float64ToFloat16( 1.05 ); - } -}); diff --git a/test/test.fill.js b/test/test.fill.js deleted file mode 100644 index d434060..0000000 --- a/test/test.fill.js +++ /dev/null @@ -1,212 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `fill` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.fill ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.fill.call( value, 1.0 ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.fill( 1.05 ); - - t.strictEqual( out instanceof Float16Array, true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 10 ); - out = arr.fill( 1.05 ); - - t.strictEqual( out, arr, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'if called with one argument, the method sets each array element to the provided value', function test( t ) { - var arr; - var buf; - var i; - - arr = new Float16Array( 3 ); - arr.fill( 1.05 ); - - buf = new Uint16Array( arr.buffer ); - - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( buf[ i ], toWord( 1.05 ), 'returns expected value' ); - } - - t.end(); -}); - -tape( 'if called with two arguments, the method sets each array element to the provided value starting from a start index (inclusive)', function test( t ) { - var arr; - var buf; - - arr = new Float16Array( 3 ); - buf = new Uint16Array( arr.buffer ); - - arr.fill( 1.05, 1 ); - - t.strictEqual( buf[ 0 ], toWord( 0.0 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 2 ], toWord( 1.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'if called with three arguments, the method sets each array element to the provided value starting from a start index (inclusive) until a specified end index (exclusive)', function test( t ) { - var arr; - var buf; - - arr = new Float16Array( 3 ); - buf = new Uint16Array( arr.buffer ); - - arr.fill( 1.05, 0, 2 ); - - t.strictEqual( buf[ 0 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 2 ], toWord( 0.0 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method supports negative indices', function test( t ) { - var arr; - var buf; - - arr = new Float16Array( 3 ); - buf = new Uint16Array( arr.buffer ); - - arr.fill( 1.05, -3, -1 ); - - t.strictEqual( buf[ 0 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 1.05 ), 'returns expected value' ); - t.strictEqual( buf[ 2 ], toWord( 0.0 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'if a provided start index resolves to a negative index, the method fills an array starting from the first element', function test( t ) { - var arr; - var buf; - var i; - - arr = new Float16Array( 3 ); - buf = new Uint16Array( arr.buffer ); - - arr.fill( 1.05, -10 ); - - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( buf[ i ], toWord( 1.05 ), 'returns expected value' ); - } - - t.end(); -}); - -tape( 'if a provided end index resolves to an index exceeding the last array element index, the method fills an array until the last element (inclusive)', function test( t ) { - var arr; - var buf; - var i; - - arr = new Float16Array( 3 ); - buf = new Uint16Array( arr.buffer ); - - arr.fill( 1.05, 1, 10 ); - - t.strictEqual( buf[ 0 ], toWord( 0.0 ), 'returns expected value' ); - for ( i = 1; i < arr.length; i++ ) { - t.strictEqual( buf[ i ], toWord( 1.05 ), 'returns expected value' ); - } - - t.end(); -}); - -tape( 'if a provided start index resolves to an index which is greater than or equal to a resolved end index, the method does not fill an array', function test( t ) { - var arr; - var buf; - - arr = new Float16Array( 3 ); - buf = new Uint16Array( arr.buffer ); - - arr.fill( 1.0, 2, 1 ); - - t.strictEqual( buf[ 0 ], toWord( 0.0 ), 'returns expected value' ); - t.strictEqual( buf[ 1 ], toWord( 0.0 ), 'returns expected value' ); - t.strictEqual( buf[ 2 ], toWord( 0.0 ), 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.filter.js b/test/test.filter.js deleted file mode 100644 index 1b77a61..0000000 --- a/test/test.filter.js +++ /dev/null @@ -1,224 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `filter` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.filter ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.filter.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( v === 1.0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.filter( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.filter( predicate ); - - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v === 1.0 ); - } -}); - -tape( 'the method returns a new floating-point number array containing only those elements which satisfy a test condition', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 1.05, 2.05 ] ); - expected = new Uint16Array( [ toWord( 1.05 ), toWord( 1.05 ) ] ); - actual = arr.filter( predicate ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v === float64ToFloat16( 1.05 ) ); - } -}); - -tape( 'the method copies all elements to a new array if all elements satisfy a test condition', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ) - ]); - actual = arr.filter( predicate ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.notEqual( actual, arr, 'returns a new instance' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v > 1.0 ); - } -}); - -tape( 'the method returns an empty array if no elements satisfy a test condition', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array( [] ); - actual = arr.filter( predicate ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.notEqual( actual, arr, 'returns a new instance' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 1.0 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var expected; - var actual; - var arr; - var buf; - var ctx; - - arr = new Float16Array( [ 1.05, 2.05, 1.05, 1.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 1.05 ), - toWord( 1.05 ) - ]); - ctx = { - 'count': 0 - }; - actual = arr.filter( predicate, ctx ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v === float64ToFloat16( 1.05 ) ); - } -}); diff --git a/test/test.find.js b/test/test.find.js deleted file mode 100644 index 1836dc3..0000000 --- a/test/test.find.js +++ /dev/null @@ -1,172 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `find` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.find ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.find.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( v === 1.0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.find( value ); - }; - } -}); - -tape( 'the method returns `undefined` if operating on an empty floating-point number array', function test( t ) { - var arr; - var v; - - arr = new Float16Array( 0 ); - v = arr.find( predicate ); - - t.strictEqual( v, void 0, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns the first element which passes a test', function test( t ) { - var arr; - var v; - - arr = new Float16Array( [ 1.05, -2.05, 3.05, -4.05 ] ); - v = arr.find( predicate ); - - t.strictEqual( v, float64ToFloat16( -2.05 ), 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method returns `undefined` if all elements fail a test', function test( t ) { - var arr; - var v; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - v = arr.find( predicate ); - - t.strictEqual( v, void 0, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - var v; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ -1.05, -2.05, 3.05, 4.05, 5.05 ] ); - v = arr.find( predicate, ctx ); - - t.strictEqual( v, float64ToFloat16( 3.05 ), 'returns expected value' ); - t.strictEqual( ctx.count, 3, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v > 0.0 ); - } -}); diff --git a/test/test.find_index.js b/test/test.find_index.js deleted file mode 100644 index b3e9023..0000000 --- a/test/test.find_index.js +++ /dev/null @@ -1,171 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `findIndex` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.findIndex ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.findIndex.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( v === 1.0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.findIndex( value ); - }; - } -}); - -tape( 'the method returns `-1` if operating on an empty floating-point number array', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( 0 ); - idx = arr.findIndex( predicate ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns the index of the first element which passes a test', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( [ 1.05, -2.05, 3.05, -4.05 ] ); - idx = arr.findIndex( predicate ); - - t.strictEqual( idx, 1, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0); - } -}); - -tape( 'the method returns `-1` if all elements fail a test', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - idx = arr.findIndex( predicate ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - var idx; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ -1.05, -2.05, 3.05, 4.05, 5.05 ] ); - idx = arr.findIndex( predicate, ctx ); - - t.strictEqual( idx, 2, 'returns expected value' ); - t.strictEqual( ctx.count, 3, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v > 0.0 ); - } -}); diff --git a/test/test.find_last.js b/test/test.find_last.js deleted file mode 100644 index 4451b22..0000000 --- a/test/test.find_last.js +++ /dev/null @@ -1,172 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `findLast` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.findLast ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.findLast.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( v === 0.0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.findLast( value ); - }; - } -}); - -tape( 'the method returns `undefined` if operating on an empty floating-point number array', function test( t ) { - var arr; - var v; - - arr = new Float16Array( 0 ); - v = arr.findLast( predicate ); - - t.strictEqual( v, void 0, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns the last element which passes a test', function test( t ) { - var arr; - var v; - - arr = new Float16Array( [ 1.05, -2.05, 3.05, -4.05 ] ); - v = arr.findLast( predicate ); - - t.strictEqual( v, float64ToFloat16( -4.05 ), 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method returns `undefined` if all elements fail a test', function test( t ) { - var arr; - var v; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - v = arr.findLast( predicate ); - - t.strictEqual( v, void 0, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - var v; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ -1.05, -2.05, 3.05, 4.05, 5.05 ] ); - v = arr.findLast( predicate, ctx ); - - t.strictEqual( v, float64ToFloat16( 5.05 ), 'returns expected value' ); - t.strictEqual( ctx.count, 1, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v > 0.0 ); - } -}); diff --git a/test/test.find_last_index.js b/test/test.find_last_index.js deleted file mode 100644 index c303468..0000000 --- a/test/test.find_last_index.js +++ /dev/null @@ -1,171 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `findLastIndex` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.findLastIndex ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.findLastIndex.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( v === 1.0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.findLastIndex( value ); - }; - } -}); - -tape( 'the method returns `-1` if operating on an empty floating-point number array', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( 0 ); - idx = arr.findLastIndex( predicate ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns the index of the last element which passes a test', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( [ 1.05, -2.05, 3.05, -4.05 ] ); - idx = arr.findLastIndex( predicate ); - - t.strictEqual( idx, 3, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method returns `-1` if all elements fail a test', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - idx = arr.findLastIndex( predicate ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v < 0.0 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - var idx; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ -1.05, -2.05, 3.05, 4.05, 5.05 ] ); - idx = arr.findLastIndex( predicate, ctx ); - - t.strictEqual( idx, 4, 'returns expected value' ); - t.strictEqual( ctx.count, 1, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v > 0.0 ); - } -}); diff --git a/test/test.for_each.js b/test/test.for_each.js deleted file mode 100644 index af6afda..0000000 --- a/test/test.for_each.js +++ /dev/null @@ -1,194 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `forEach` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.forEach ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.forEach.call( value, fcn ); - }; - } - - function fcn( v ) { - if ( !isNumber( v ) ) { - t.fail( 'should be a number' ); - } - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.forEach( value ); - }; - } -}); - -tape( 'the method should not invoke a provided callback function if operating on an empty floating-point array', function test( t ) { - var arr; - - arr = new Float16Array( 0 ); - arr.forEach( fcn ); - - t.end(); - - function fcn() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns `undefined`', function test( t ) { - var arr; - var out; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - out = arr.forEach( fcn ); - - t.strictEqual( out, void 0, 'returns expected value' ); - t.end(); - - function fcn( v ) { - if ( !isNumber( v ) ) { - t.fail( 'should be a number' ); - } - } -}); - -tape( 'the method invokes a provided function for each element in an array', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var arr; - - indices = []; - values = []; - arrays = []; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - arr.forEach( fcn ); - - expected = [ - float64ToFloat16( 1.05 ), - float64ToFloat16( 2.05 ), - float64ToFloat16( 3.05 ), - float64ToFloat16( 4.05 ) - ]; - - t.deepEqual( values, expected, 'returns expected value' ); - t.deepEqual( indices, [ 0, 1, 2, 3 ], 'returns expected value' ); - t.strictEqual( arrays[ 0 ], arr, 'returns expected value' ); - t.strictEqual( arrays[ 1 ], arr, 'returns expected value' ); - t.strictEqual( arrays[ 2 ], arr, 'returns expected value' ); - t.strictEqual( arrays[ 3 ], arr, 'returns expected value' ); - - t.end(); - - function fcn( v, i, arr ) { - values.push( v ); - indices.push( i ); - arrays.push( arr ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - arr.forEach( fcn, ctx ); - - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function fcn() { - this.count += 1; // eslint-disable-line no-invalid-this - } -}); diff --git a/test/test.from.js b/test/test.from.js deleted file mode 100644 index 15a43a2..0000000 --- a/test/test.from.js +++ /dev/null @@ -1,309 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 Uint16Array = require( '@stdlib/array-uint16' ); -var isFunction = require( '@stdlib/assert-is-function' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is a `from` method for creating a 16-bit floating-point number array from an array-like object or an iterable', function test( t ) { - var arr; - - t.strictEqual( isFunction( Float16Array.from ), true, 'has method' ); - - arr = Float16Array.from( [] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a constructor', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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 Float16Array.from.call( value, [] ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array constructor', function test( t ) { - var values; - var i; - - values = [ - {}, - null, - 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 Float16Array.from.call( value, [] ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - {}, - [] - ]; - 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 Float16Array.from( [], value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not a function (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - {}, - [] - ]; - 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 Float16Array.from( [], value, {} ); - }; - } -}); - -tape( 'the method returns a floating-point number array', function test( t ) { - var arr; - var v; - - // Generic array: - arr = Float16Array.from( [] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Float16Array.from( [ 1.0, 2.0, 3.0, 4.0 ] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - // Generic array containing non-numeric values: - arr = Float16Array.from( [ 'beep' ] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - arr = Float16Array.from( [ null, 4 ] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - arr = Float16Array.from( [ true, {}, '' ] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 3, 'returns expected value' ); - - // Typed array: - arr = Float16Array.from( new Uint16Array( 0 ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Float16Array.from( new Uint16Array( [ 1, 1 ] ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // Floating-point number typed array: - arr = Float16Array.from( new Float16Array( 0 ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Float16Array.from( new Float16Array( [ 1.0, 2.0 ] ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method supports providing a "map" function which is invoked for each source element', function test( t ) { - var arr; - var v; - - // Generic array: - arr = Float16Array.from( [], clbk1 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Float16Array.from( [ 1.0, 2.0, 3.0, 4.0 ], clbk1 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - // Generic array containing non-numeric values: - arr = Float16Array.from( [ 'beep' ], clbk2 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - arr = Float16Array.from( [ null ], clbk2 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - arr = Float16Array.from( [ [], {} ], clbk1 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - arr = Float16Array.from( [ 4, 5 ], clbk1 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // Typed array: - arr = Float16Array.from( new Uint16Array( 0 ), clbk1 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Float16Array.from( new Uint16Array( [ 1, 1 ] ), clbk1 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // Floating-point number typed array: - arr = Float16Array.from( new Float16Array( 0 ), clbk2 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Float16Array.from( new Float16Array( [ true, true ] ), clbk2 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - t.end(); - - function clbk1( v ) { - return v; - } - - function clbk2() { - return true; - } -}); - -tape( 'the method supports providing a `this` context for a provided map function', function test( t ) { - var arr; - var ctx; - - ctx = { - 'count': 0 - }; - arr = Float16Array.from( [ 1.0, 2.0, 3.0, 4.0 ], clbk1, ctx ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function clbk1( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v; - } -}); diff --git a/test/test.includes.js b/test/test.includes.js deleted file mode 100644 index a367b40..0000000 --- a/test/test.includes.js +++ /dev/null @@ -1,160 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `includes` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.includes ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.includes.call( value, true ); - }; - } -}); - -tape( 'the method returns `false` if operating on an empty floating-point number array', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( 0 ); - bool = arr.includes( 1.0 ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `false` if a floating-point number is not found', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( 10 ); - bool = arr.includes( 1.0 ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `true` if an array contains a specified floating-point number', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05] ); - bool = arr.includes( float64ToFloat16( 1.05 ) ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `false` if provided a second argument which exceeds the input array length', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( 10 ); - bool = arr.includes( 0.0, 20 ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 1.05, 1.05, 1.05 ] ); - - bool = arr.includes( float64ToFloat16( 1.05 ), 0 ); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = arr.includes( float64ToFloat16( 2.05 ), 1 ); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = arr.includes( float64ToFloat16( 2.05 ), 3 ); - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index (negative)', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 1.05, 1.05, 1.05 ] ); - - bool = arr.includes( float64ToFloat16( 1.05 ), -5 ); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = arr.includes( float64ToFloat16( 2.05 ), -2 ); - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'when provided a starting index which resolves to an index which is less than zero, the method searches from the first array element', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 1.05, 1.05, 1.05 ] ); - - bool = arr.includes( float64ToFloat16( 1.05 ), -10 ); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = arr.includes( float64ToFloat16( 2.05 ), -10 ); - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.index_of.js b/test/test.index_of.js deleted file mode 100644 index 2a684aa..0000000 --- a/test/test.index_of.js +++ /dev/null @@ -1,160 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `indexOf` method for returning the index of an array element', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.indexOf ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.indexOf.call( value, 1.0 ); - }; - } -}); - -tape( 'the method returns `-1` if operating on an empty floating-point number array', function test( t ) { - var arr; - var idx; - - arr = new Float16Array(); - idx = arr.indexOf( 1.0 ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `-1` if a numeric value is not found', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( 10 ); - idx = arr.indexOf( 1.0 ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns the index of the first match if a numeric value is found', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - idx = arr.indexOf( float64ToFloat16( 2.05 ) ); - - t.strictEqual( idx, 1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `-1` if provided a second argument which exceeds the input array length', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( 10 ); - idx = arr.indexOf( 1.0, 20 ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 2.05, 5.05 ] ); - - idx = arr.indexOf( float64ToFloat16( 2.05 ), 0 ); - t.strictEqual( idx, 1, 'returns expected value' ); - - idx = arr.indexOf( float64ToFloat16( 2.05 ), 2 ); - t.strictEqual( idx, 3, 'returns expected value' ); - - idx = arr.indexOf( float64ToFloat16( 2.05 ), 4 ); - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index (negative)', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 2.05, 5.05 ] ); - - idx = arr.indexOf( float64ToFloat16( 2.05 ), -5 ); - t.strictEqual( idx, 1, 'returns expected value' ); - - idx = arr.indexOf( float64ToFloat16( 2.05 ), -1 ); - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'when provided a starting index which resolves to an index which is less than zero, the method searches from the first array element', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 2.05, 5.05 ] ); - - idx = arr.indexOf( float64ToFloat16( 2.05 ), -10 ); - t.strictEqual( idx, 1, 'returns expected value' ); - - idx = arr.indexOf( float64ToFloat16( 1.05 ), -10 ); - t.strictEqual( idx, 0, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.join.js b/test/test.join.js deleted file mode 100644 index 800bb1f..0000000 --- a/test/test.join.js +++ /dev/null @@ -1,141 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `join` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.join ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.join.call( value ); - }; - } -}); - -tape( 'the method returns an empty string if invoked on an empty array', function test( t ) { - var str; - var arr; - - arr = new Float16Array( 0 ); - str = arr.join(); - - t.strictEqual( str, '', 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a string representation of a floating-point number array with elements separated by a separator', function test( t ) { - var expected; - var str; - var arr; - var i; - - arr = new Float16Array( [ 0.05, 1.05, 2.05, 3.05, 4.05 ] ); - - expected = float64ToFloat16( 0.05 ); - for ( i = 1; i < arr.length; i++ ) { - expected += '@' + float64ToFloat16( i + 0.05 ); - } - - str = arr.join( '@' ); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a string representation of a floating-point number array with elements separated by a separator (single element)', function test( t ) { - var expected; - var str; - var arr; - - arr = new Float16Array( [ 1.05 ] ); - expected = '' + float64ToFloat16( 1.05 ); - - str = arr.join(); - - t.strictEqual( str, expected, 'returns expected value' ); - - arr = new Float16Array( [ 1.05 ] ); - expected = '' + float64ToFloat16( 1.05 ); - - str = arr.join( '@' ); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if the method is invoked without a separator argument, the method returns a string representation of a floating-point number array with elements separated by a comma', function test( t ) { - var expected; - var str; - var arr; - var i; - - arr = new Float16Array( [ 0.05, 1.05, 2.05, 3.05, 4.05 ] ); - - expected = float64ToFloat16( 0.05 ); - for ( i = 1; i < arr.length; i++ ) { - expected += ',' + float64ToFloat16( i + 0.05 ); - } - - str = arr.join(); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 930feef..0000000 --- a/test/test.js +++ /dev/null @@ -1,320 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 ArrayBuffer = require( '@stdlib/array-buffer' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var hasOwnProp = require( '@stdlib/assert-has-own-property' ); -var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var arr = new Float16Array( 0 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (no argument)', function test( t ) { - var arr = new Float16Array(); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (length)', function test( t ) { - var arr = new Float16Array( 10 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (array)', function test( t ) { - var arr = new Float16Array( [] ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (typed array)', function test( t ) { - var arr = new Float16Array( new Uint16Array( 0 ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (ArrayBuffer)', function test( t ) { - var arr = new Float16Array( new ArrayBuffer( 0 ) ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (ArrayBuffer, byte offset)', function test( t ) { - var arr = new Float16Array( new ArrayBuffer( 8 ), 8 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns a 16-bit floating-point number array (ArrayBuffer, byte offset, length)', function test( t ) { - var arr = new Float16Array( new ArrayBuffer( 8 ), 8, 0 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the constructor is a property returning the number of bytes per array element', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Float16Array.BYTES_PER_ELEMENT, 2, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the constructor is a property returning the constructor name', function test( t ) { - t.strictEqual( hasOwnProp( Float16Array, 'name' ), true, 'has property' ); - t.strictEqual( Float16Array.name, 'Float16Array', 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance having a `BYTES_PER_ELEMENT` property returning the number of bytes per array element', function test( t ) { - var arr; - - t.strictEqual( hasOwnProp( Float16Array.prototype, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Float16Array.prototype.BYTES_PER_ELEMENT, 2, 'returns expected value' ); - - arr = new Float16Array( 0 ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance having a `buffer` property for returning the underlying memory (i.e., ArrayBuffer)', function test( t ) { - var arr; - var buf; - - arr = new Float16Array( 0 ); - buf = arr.buffer; - t.strictEqual( isArrayBuffer( buf ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance having a `byteLength` property for returning the number of bytes belonging to the array view', function test( t ) { - var arr; - var v; - - arr = new Float16Array( 0 ); - v = arr.byteLength; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( new ArrayBuffer( 64 ), 8 ); - v = arr.byteLength; - t.strictEqual( v, 56, 'returns expected value' ); - - arr = new Float16Array( new ArrayBuffer( 64 ), 64 ); - v = arr.byteLength; - t.strictEqual( v, 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance having a `byteOffset` property for returning the byte offset pointing to the first array element in the underlying memory', function test( t ) { - var arr; - var v; - - arr = new Float16Array( 0 ); - v = arr.byteOffset; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( new ArrayBuffer( 64 ), 32 ); - v = arr.byteOffset; - t.strictEqual( v, 32, 'returns expected value' ); - - arr = new Float16Array( new ArrayBuffer( 64 ), 64 ); - v = arr.byteOffset; - t.strictEqual( v, 64, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance having a `length` property for returning the number of array elements', function test( t ) { - var arr; - var v; - - // No arguments: - arr = new Float16Array(); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - // Explicit array length: - arr = new Float16Array( 0 ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( 10 ); - v = arr.length; - t.strictEqual( v, 10, 'returns expected value' ); - - // Generic array: - arr = new Float16Array( [] ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - // Typed array: - arr = new Float16Array( new Uint16Array( 0 ) ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( new Uint16Array( [ 1.0, 1.0 ] ) ); - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // Float16 typed array: - arr = new Float16Array( new Float16Array( 0 ) ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( new Float16Array( [ 1.0, 2.0 ] ) ); - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // ArrayBuffer: - arr = new Float16Array( new ArrayBuffer( 64 ), 32 ); - v = arr.length; - t.strictEqual( v, 16, 'returns expected value' ); - - arr = new Float16Array( new ArrayBuffer( 64 ), 64 ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Float16Array( new ArrayBuffer( 64 ), 32, 2 ); - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor throws an error if provided an ArrayBuffer which is not a multiple of 2', function test( t ) { - var values; - var i; - - values = [ - 1, - 3, - 5, - 7, - 9, - 11, - 101, - 1001 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided an ArrayBuffer having a byte length equal to '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Float16Array( new ArrayBuffer( value ) ); - }; - } -}); - -tape( 'the constructor throws an error if provided a byte offset argument which is not a multiple of 2', function test( t ) { - var values; - var i; - - values = [ - 1, - 3, - 5, - 7, - 9, - 11, - 101, - 1001 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Float16Array( new ArrayBuffer( 1e3 ), value ); - }; - } -}); - -tape( 'the constructor throws an error if provided a byte offset argument such that the view byte length is not a multiple of 8', function test( t ) { - var values; - var i; - - values = [ - 2, - 4, - 6, - 8, - 10, - 12, - 14, - 16, - 18, - 20 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Float16Array( new ArrayBuffer( 101 ), value ); - }; - } -}); - -tape( 'the constructor throws an error if provided insufficient memory to accommodate byte offset and length arguments', function test( t ) { - var values; - var i; - - values = [ - 8, - 16, - 24, - 32 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Float16Array( new ArrayBuffer( 100 ), value, 1e3 ); - }; - } -}); diff --git a/test/test.keys.js b/test/test.keys.js deleted file mode 100644 index 283d682..0000000 --- a/test/test.keys.js +++ /dev/null @@ -1,144 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `keys` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.keys ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.keys.call( value ); - }; - } -}); - -tape( 'the method returns an iterator protocol-compliant object', function test( t ) { - var expected; - var arr; - var it; - var i; - var r; - var e; - - arr = new Float16Array( [ 1.05, 2.05 ] ); - expected = [ - { - 'value': 0, - 'done': false - }, - { - 'value': 1, - 'done': false - }, - { - 'done': true - } - ]; - it = arr.keys(); - - t.strictEqual( typeof it, 'object', 'returns expected value' ); - t.strictEqual( typeof it.next, 'function', 'has next method' ); - - for ( i = 0; i < expected.length; i++ ) { - r = it.next(); - e = expected[ i ]; - if ( e.value === void 0 ) { - t.strictEqual( r.value, e.value, 'returns expected value' ); - t.strictEqual( r.done, e.done, 'returns expected value' ); - } else { - t.strictEqual( r.value, e.value, 'returns expected value' ); - t.strictEqual( r.done, e.done, 'returns expected value' ); - } - } - - t.end(); -}); - -tape( 'the method returns an iterator which does not iterate over empty arrays', function test( t ) { - var expected; - var arr; - var it; - var i; - var v; - - arr = new Float16Array( [] ); - expected = [ - { - 'done': true - }, - { - 'done': true - }, - { - 'done': true - } - ]; - it = arr.keys(); - - t.strictEqual( typeof it, 'object', 'returns expected value' ); - t.strictEqual( typeof it.next, 'function', 'has next method' ); - - for ( i = 0; i < expected.length; i++ ) { - v = it.next(); - t.strictEqual( v.value, expected[ i ].value, 'returns expected value' ); - t.strictEqual( v.done, expected[ i ].done, 'returns expected value' ); - } - t.end(); -}); diff --git a/test/test.last_index_of.js b/test/test.last_index_of.js deleted file mode 100644 index 5a42168..0000000 --- a/test/test.last_index_of.js +++ /dev/null @@ -1,149 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `lastIndexOf` method for returning the index of an array element', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.lastIndexOf ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.lastIndexOf.call( value, true ); - }; - } -}); - -tape( 'the method returns `-1` if operating on an empty floating-point number array', function test( t ) { - var arr; - var idx; - - arr = new Float16Array( 0 ); - idx = arr.lastIndexOf( 0.0 ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `-1` if a numeric value is not found', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( 10 ); - idx = arr.lastIndexOf( 1.0 ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns the index of the first match when searching from the end of the array if a search element is found', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 1.05, 2.05 ] ); - idx = arr.lastIndexOf( float64ToFloat16( 1.05 ) ); - - t.strictEqual( idx, 2, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 2.05, 1.05, 1.05 ] ); - - idx = arr.lastIndexOf( float64ToFloat16( 1.05 ), 4 ); - t.strictEqual( idx, 4, 'returns expected value' ); - - idx = arr.lastIndexOf( float64ToFloat16( 2.05 ), 2 ); - t.strictEqual( idx, 2, 'returns expected value' ); - - idx = arr.lastIndexOf( float64ToFloat16( 2.05 ), 0 ); - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index (negative)', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 2.05, 1.05, 1.05 ] ); - - idx = arr.lastIndexOf( float64ToFloat16( 1.05 ), -3 ); - t.strictEqual( idx, 0, 'returns expected value' ); - - idx = arr.lastIndexOf( float64ToFloat16( 2.05 ), -1 ); - t.strictEqual( idx, 2, 'returns expected value' ); - t.end(); -}); - -tape( 'when the method is provided a starting index which resolves to an index which exceeds the maximum array index, the method searches from the last array element', function test( t ) { - var idx; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 2.05, 1.05, 1.05 ] ); - - idx = arr.lastIndexOf( float64ToFloat16( 1.05 ), 10 ); - t.strictEqual( idx, 4, 'returns expected value' ); - - idx = arr.lastIndexOf( float64ToFloat16( 2.05 ), 10 ); - t.strictEqual( idx, 2, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.map.js b/test/test.map.js deleted file mode 100644 index f7e5594..0000000 --- a/test/test.map.js +++ /dev/null @@ -1,176 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var identity = require( '@stdlib/utils-identity-function' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `map` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.map ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.map.call( value, identity ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.map( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.map( identity ); - - t.strictEqual( instanceOf( out, Float16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - t.notEqual( out, arr, 'returns a new instance' ); - t.end(); -}); - -tape( 'the method returns a new floating-point number array containing elements which are the result of a provided callback function', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( -1.05 ), - toWord( -2.05 ), - toWord( -3.05 ), - toWord( -4.05 ) - ]); - actual = arr.map( invert ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.notEqual( actual, arr, 'returns a new instance' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); - - function invert( v ) { - return -v; - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var expected; - var actual; - var arr; - var buf; - var ctx; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( -1.05 ), - toWord( -2.05 ), - toWord( -3.05 ), - toWord( -4.05 ) - ]); - ctx = { - 'count': 0 - }; - actual = arr.map( invert, ctx ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.strictEqual( ctx.count, 6, 'returns expected value' ); - t.end(); - - function invert( v, i ) { - this.count += i; // eslint-disable-line no-invalid-this - return -v; - } -}); diff --git a/test/test.of.js b/test/test.of.js deleted file mode 100644 index 6486686..0000000 --- a/test/test.of.js +++ /dev/null @@ -1,128 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `of` method for creating a 16-bit floating-point number array from a variable number of arguments', function test( t ) { - var arr; - - t.strictEqual( isFunction( Float16Array.of ), true, 'has method' ); - - arr = Float16Array.of(); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a constructor', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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 Float16Array.of.call( value, true, true ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point array constructor', function test( t ) { - var values; - var i; - - values = [ - {}, - null, - 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 Float16Array.of.call( value, true, true ); - }; - } -}); - -tape( 'the method returns a floating-point number array', function test( t ) { - var arr; - var v; - - // No arguments: - arr = Float16Array.of(); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - // Numeric arguments: - arr = Float16Array.of( 1.0, 2.0, 3.0, 4.0 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - // Non-numeric arguments: - arr = Float16Array.of( 1, {}, 0, null, 'beep' ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 5, 'returns expected value' ); - - // Mixed arguments: - arr = Float16Array.of( true, 1, false, 0 ); - t.strictEqual( arr instanceof Float16Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.polyfill.js b/test/test.polyfill.js deleted file mode 100644 index 2010bde..0000000 --- a/test/test.polyfill.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 proxyquire = require( 'proxyquire' ); -var hasFloat16ArraySupport = require( '@stdlib/assert-has-float16array-support' ); -var polyfill = require( './../lib/polyfill' ); -var ctor = require( './../lib' ); - - -// VARIABLES // - -var hasFloat16Arrays = hasFloat16ArraySupport(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports `Float16Array`, the export is an alias for `Float16Array`', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-float16array-support': isTrue, - './main.js': Mock - }); - t.strictEqual( Foo, Mock, 'returns builtin' ); - - if ( hasFloat16Arrays ) { - t.strictEqual( ctor, Float16Array, 'is alias' ); // eslint-disable-line stdlib/require-globals, no-undef - } - - t.end(); - - function Mock() { - return this; - } - - function isTrue() { - return true; - } -}); - -tape( 'if an environment does not support `Float16Array`, the export is a polyfill', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert-has-float16array-support': isFalse - }); - - t.strictEqual( Foo, polyfill, 'returns polyfill' ); - t.end(); - - function isFalse() { - return false; - } -}); diff --git a/test/test.reduce.js b/test/test.reduce.js deleted file mode 100644 index 34786fc..0000000 --- a/test/test.reduce.js +++ /dev/null @@ -1,187 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `reduce` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.reduce ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.reduce.call( value, reducer ); - }; - } - - function reducer( acc, value ) { - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.reduce( value ); - }; - } -}); - -tape( 'the method throws an error if not provided an initial value when operating on an empty floating-point number array', function test( t ) { - var arr; - - arr = new Float16Array( 0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - arr.reduce( reducer ); - } - - function reducer( acc, value ) { - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method uses the first element of the array as the initial value when an initial value is not provided', function test( t ) { - var valueArray; - var accArray; - var expected; - var actual; - var arr; - var ind; - - arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - accArray = [ 1.0, 3.0 ]; - valueArray = [ 2.0, 3.0 ]; - expected = float64ToFloat16( 6.0 ); - actual = arr.reduce( reducer ); - - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); - - function reducer( acc, value, index ) { - ind = index-1; - t.strictEqual( acc, float64ToFloat16( accArray[ ind ] ), 'returns expected value' ); - t.strictEqual( value, float64ToFloat16( valueArray[ ind ] ), 'returns expected value' ); - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method supports providing an initial value as the second argument', function test( t ) { - var valueArray; - var accArray; - var expected; - var actual; - var arr; - - arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - accArray = [ 2.0, 3.0, 5.0 ]; - valueArray = [ 1.0, 2.0, 3.0 ]; - expected = 8.0; - actual = arr.reduce( reducer, 2.0 ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value, index ) { - t.strictEqual( acc, float64ToFloat16( accArray[ index ] ), 'returns expected value' ); - t.strictEqual( value, float64ToFloat16( valueArray[ index ] ), 'returns expected value' ); - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method returns the accumulated result', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = float64ToFloat16( 10.20 ); - actual = arr.reduce( reducer ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value ) { - return float64ToFloat16( acc + value ); - } -}); diff --git a/test/test.reduce_right.js b/test/test.reduce_right.js deleted file mode 100644 index 313b948..0000000 --- a/test/test.reduce_right.js +++ /dev/null @@ -1,190 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `reduceRight` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.reduceRight ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.reduceRight.call( value, reducer ); - }; - } - - function reducer( acc, value ) { - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.reduceRight( value ); - }; - } -}); - -tape( 'the method throws an error if not provided an initial value when operating on an empty floating-point number array', function test( t ) { - var arr; - - arr = new Float16Array( 0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - arr.reduceRight( reducer ); - } - - function reducer( acc, value ) { - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method uses the last element of the array as the initial value when an initial value is not provided', function test( t ) { - var valueArray; - var accArray; - var expected; - var actual; - var arr; - var len; - - arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - len = arr.length; - accArray = [ 3.0, 5.0 ]; - valueArray = [ 2.0, 1.0 ]; - expected = float64ToFloat16( 6.0 ); - actual = arr.reduceRight( reducer ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value, index ) { - var ind = (len-index-2); - t.strictEqual( acc, float64ToFloat16( accArray[ ind ] ), 'returns expected value' ); - t.strictEqual( value, float64ToFloat16( valueArray[ ind ] ), 'returns expected value' ); - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method supports providing an initial value as the second argument', function test( t ) { - var valueArray; - var accArray; - var expected; - var actual; - var arr; - var len; - - arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - len = arr.length; - accArray = [ 2.0, 5.0, 7.0 ]; - valueArray = [ 3.0, 2.0, 1.0 ]; - expected = 8.0; - actual = arr.reduceRight( reducer, 2.0 ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value, index ) { - var ind = (len-index-1); - t.strictEqual( acc, float64ToFloat16( accArray[ ind ] ), 'returns expected value' ); - t.strictEqual( value, float64ToFloat16( valueArray[ ind ] ), 'returns expected value' ); - return float64ToFloat16( acc + value ); - } -}); - -tape( 'the method returns the accumulated result', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = float64ToFloat16( 10.20 ); - actual = arr.reduceRight( reducer ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value ) { - return float64ToFloat16( acc + value ); - } -}); diff --git a/test/test.reverse.js b/test/test.reverse.js deleted file mode 100644 index 147a4a0..0000000 --- a/test/test.reverse.js +++ /dev/null @@ -1,120 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, '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( isFunction( Float16Array.prototype.reverse ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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 floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - 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 floating-point number array in-place', function test( t ) { - var expected; - var arr; - var buf; - var out; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05, 5.05 ] ); - expected = new Uint16Array([ - toWord( 5.05 ), - toWord( 4.05 ), - toWord( 3.05 ), - toWord( 2.05 ), - toWord( 1.05 ) - ]); - out = arr.reverse(); - buf = new Uint16Array( arr.buffer ); - - t.strictEqual( instanceOf( arr, Float16Array ), true, 'returns expected value' ); - t.strictEqual( out, arr, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 10 ); - out = arr.reverse(); - - t.strictEqual( out.length, 10, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.set.js b/test/test.set.js deleted file mode 100644 index 559efab..0000000 --- a/test/test.set.js +++ /dev/null @@ -1,225 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var ArrayBuffer = require( '@stdlib/array-buffer' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `set` method for setting one or more array elements', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.set ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.set.call( value, 0 ); - }; - } -}); - -tape( 'the method throws an error if provided an index argument which is out-of-bounds', function test( t ) { - var values; - var arr1; - var arr2; - var i; - - arr1 = new Float16Array( 10 ); - arr2 = []; - for ( i = 0; i < arr1.length; i++ ) { - arr2.push( 1.0 ); - } - - values = [ - 1, - 2, - 3, - 4, - 5 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr1.set( arr2, value ); - }; - } -}); - -tape( 'the method sets one or more array elements', function test( t ) { - var arr; - var v; - var i; - - arr = new Float16Array( 10 ); - - v = arr[ 0 ]; - t.strictEqual( v, 0.0, 'returns expected value' ); - - // No index argument: - arr.set( [ 1.0 ] ); - - v = arr[ 0 ]; - t.strictEqual( v, 1.0, 'returns expected value' ); - - arr.set( [ 0.0 ] ); - - // Index argument: - for ( i = 0; i < arr.length; i++ ) { - v = arr[ i ]; - t.strictEqual( v, 0.0, 'returns expected value' ); - - arr.set( [ 1.05 ], i ); - - v = arr[ i ]; - t.strictEqual( v, float64ToFloat16( 1.05 ), 'returns expected value' ); - } - - // Multiple values, no index argument: - arr.set( [ 1.05, 2.05 ] ); - - v = arr[ 0 ]; - t.strictEqual( v, float64ToFloat16( 1.05 ), 'returns expected value' ); - - v = arr[ 1 ]; - t.strictEqual( v, float64ToFloat16( 2.05 ), 'returns expected value' ); - - // Multiple values, index argument: - arr.set( [ 1.05, 2.05 ], 2 ); - - v = arr[ 2 ]; - t.strictEqual( v, float64ToFloat16( 1.05 ), 'returns expected value' ); - - v = arr[ 3 ]; - t.strictEqual( v, float64ToFloat16( 2.05 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the method sets an array element (floating-point number array; shared buffer)', function test( t ) { - var byteOffset; - var arr; - var src; - var buf; - var ab; - var v; - var i; - - byteOffset = 112; - - ab = new ArrayBuffer( 240 ); - arr = new Float16Array( ab, byteOffset, 10 ); - - // Overlapping (requires copy), multiple values, no index argument: - buf = [ 1.05, 2.05 ]; - src = new Float16Array( ab, byteOffset-(1*arr.BYTES_PER_ELEMENT), 2 ); - for ( i = 0; i < buf.length; i++ ) { - src[ i ] = buf[ i ]; - } - arr.set( src ); - - v = arr[ 0 ]; - t.strictEqual( v, float64ToFloat16( buf[ 0 ] ), 'returns expected value' ); - - v = arr[ 1 ]; - t.strictEqual( v, float64ToFloat16( buf[ 1 ] ), 'returns expected value' ); - - // Overlapping (requires copy), multiple values, index argument: - buf = [ -1.05, -2.05 ]; - src = new Float16Array( ab, byteOffset+(1*arr.BYTES_PER_ELEMENT), 2 ); - for ( i = 0; i < buf.length; i++ ) { - src[ i ] = buf[ i ]; - } - arr.set( src, 2 ); - - v = arr[ 2 ]; - t.strictEqual( v, float64ToFloat16( buf[ 0 ] ), 'returns expected value' ); - - v = arr[ 3 ]; - t.strictEqual( v, float64ToFloat16( buf[ 1 ] ), 'returns expected value' ); - - // Overlapping (no copy), multiple values, no index argument: - buf = [ 3.05, 4.05 ]; - src = new Float16Array( ab, byteOffset+(1*arr.BYTES_PER_ELEMENT), 2 ); - for ( i = 0; i < buf.length; i++ ) { - src[ i ] = buf[ i ]; - } - arr.set( src ); - - v = arr[ 0 ]; - t.strictEqual( v, float64ToFloat16( buf[ 0 ] ), 'returns expected value' ); - - v = arr[ 1 ]; - t.strictEqual( v, float64ToFloat16( buf[ 1 ] ), 'returns expected value' ); - - // Overlapping (no copy), multiple values, index argument: - buf = [ -3.05, -4.05 ]; - src = new Float16Array( ab, byteOffset+(3*arr.BYTES_PER_ELEMENT), 2 ); - for ( i = 0; i < buf.length; i++ ) { - src[ i ] = buf[ i ]; - } - arr.set( src, 2 ); - - v = arr[ 2 ]; - t.strictEqual( v, float64ToFloat16( buf[ 0 ] ), 'returns expected value' ); - - v = arr[ 3 ]; - t.strictEqual( v, float64ToFloat16( buf[ 1 ] ), 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.slice.js b/test/test.slice.js deleted file mode 100644 index a9f9e04..0000000 --- a/test/test.slice.js +++ /dev/null @@ -1,249 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `slice` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.slice ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.slice.call( value ); - }; - } -}); - -tape( 'the method returns an empty typed array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.slice(); - - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'if called without arguments, the method returns a typed array containing the same elements as the original array', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ) - ]); - actual = arr.slice(); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.notEqual( actual, arr, 'returns a new instance' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if called with one argument, the method returns a typed array containing elements starting from a specified beginning index (inclusive)', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ) - ]); - actual = arr.slice( 1 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if provided two arguments, the method returns a typed array containing elements starting from a specified beginning index (inclusive) and ending at a specified stop index (exclusive)', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ) - ]); - actual = arr.slice( 1, 3 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ) - ]); - actual = arr.slice( 1, 30 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method resolves negative indices relative to the last element', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ) - ]); - actual = arr.slice( -3, -1 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ) - ]); - actual = arr.slice( -30, -2 ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty typed array if a resolved beginning index exceeds a resolved ending index', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array( [] ); - actual = arr.slice( 2, 0 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty typed array if a resolved beginning index exceeds the maximum array index', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array( [] ); - actual = arr.slice( 5 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty typed array if a resolved ending index is less than or equal to zero', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); - expected = new Uint16Array( [] ); - actual = arr.slice( 2, -8 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - - actual = arr.slice( 1, 0 ); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.some.js b/test/test.some.js deleted file mode 100644 index 238d1d9..0000000 --- a/test/test.some.js +++ /dev/null @@ -1,194 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `some` method for returning boolean indicating whether at least one element passes a test', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.some ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.some.call( value, predicate ); - }; - } - - function predicate( v ) { - return v === 1.0; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - 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.some( value ); - }; - } -}); - -tape( 'the method returns `false` if operating on an empty floating-point number array', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( 0 ); - bool = arr.some( predicate ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns `true` if at least one element passes a test', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - bool = arr.some( predicate ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v === float64ToFloat16( 1.05 ); - } -}); - -tape( 'the method returns `false` if all elements fail a test', function test( t ) { - var bool; - var arr; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - bool = arr.some( predicate ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v === float64ToFloat16( 5.05 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var bool; - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - bool = arr.some( predicate, ctx ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v === float64ToFloat16( 4.05 ); - } -}); - -tape( 'the method stops executing upon encountering the first element which passes a test', function test( t ) { - var bool; - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - bool = arr.some( predicate, ctx ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.strictEqual( ctx.count, 1, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v === float64ToFloat16( 1.05 ); - } -}); diff --git a/test/test.sort.js b/test/test.sort.js deleted file mode 100644 index e976a68..0000000 --- a/test/test.sort.js +++ /dev/null @@ -1,186 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Comparison function. -* -* @private -* @param {boolean} a - first value for comparison -* @param {boolean} b - second value for comparison -* @returns {number} comparison result -*/ -function compareFcn( a, b ) { - if ( a < b ) { - return -1; - } - if ( a > b ) { - return 1; - } - return 0; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `sort` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.sort ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.sort.call( value, compareFcn ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - {}, - [] - ]; - 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.sort( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.sort( compareFcn ); - - t.strictEqual( out.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the method sorts elements of a floating-point number array in-place', function test( t ) { - var expected; - var arr; - var out; - var buf; - - arr = new Float16Array( [ 4.05, 3.05, 1.05, 5.05, 2.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ), - toWord( 5.05 ) - ]); - out = arr.sort( compareFcn ); - buf = new Uint16Array( out.buffer ); - - t.strictEqual( instanceOf( arr, Float16Array ), true, 'returns expected value' ); - t.strictEqual( out, arr, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - - arr = new Float16Array( [ 2.05, 1.05, -1.05, 0.05, -2.05 ] ); - expected = new Uint16Array([ - toWord( -2.05 ), - toWord( -1.05 ), - toWord( 0.05 ), - toWord( 1.05 ), - toWord( 2.05 ) - ]); - out = arr.sort( compareFcn ); - buf = new Uint16Array( out.buffer ); - - t.strictEqual( instanceOf( arr, Float16Array ), true, 'returns expected value' ); - t.strictEqual( out, arr, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Float16Array( [ 4.05, 3.05, 1.05, 5.05, 2.05 ] ); - out = arr.sort( compareFcn ); - - t.strictEqual( out.length, arr.length, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.subarray.js b/test/test.subarray.js deleted file mode 100644 index 6684448..0000000 --- a/test/test.subarray.js +++ /dev/null @@ -1,246 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `subarray` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.subarray ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.subarray.call( value ); - }; - } -}); - -tape( 'the method returns empty array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.subarray(); - - t.strictEqual( out.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'if called without arguments, the method returns a view containing the same elements as the original array', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ) - ]); - actual = arr.subarray(); - buf = new Uint16Array( actual.buffer ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if called with one argument, the method returns a view containing elements starting from a specified beginning index (inclusive)', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ) - ]); - actual = arr.subarray( 1 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if provided two arguments, the method returns a view containing elements starting from a specified beginning index (inclusive) and ending at a specified stop index (exclusive)', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ) - ]); - actual = arr.subarray( 1, 3 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method resolves negative indices relative to the last element', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array([ - toWord( 2.05 ), - toWord( 3.05 ) - ]); - actual = arr.subarray( -3, -1 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 2.05 ) - ]); - actual = arr.subarray( -30, -2 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty view if a resolved beginning index exceeds a resolved ending index', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array( [] ); - actual = arr.subarray( 2, 0 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty view if a resolved beginning index exceeds the maximum array index', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array( [] ); - actual = arr.subarray( 5 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty view if a resolved ending index is less than or equal to zero', function test( t ) { - var expected; - var actual; - var arr; - var buf; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05 ] ); - expected = new Uint16Array( [] ); - actual = arr.subarray( 2, -8 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - - actual = arr.subarray( 1, 0 ); - buf = new Uint16Array( actual.buffer, actual.byteOffset, actual.length ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Float16Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.to_locale_string.js b/test/test.to_locale_string.js deleted file mode 100644 index 6359a2c..0000000 --- a/test/test.to_locale_string.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `toLocaleString` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.toLocaleString ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.toLocaleString.call( value ); - }; - } -}); - -tape( 'the method returns an empty string if invoked on an empty array', function test( t ) { - var str; - var arr; - - arr = new Float16Array( 0 ); - str = arr.toLocaleString(); - - t.strictEqual( str, '', 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a string representation of a floating-point number array', function test( t ) { - var expected; - var str; - var arr; - - arr = new Float16Array( [ 1.0, 2.0, 3.0 ] ); - expected = '1,2,3'; - - str = arr.toLocaleString(); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.to_reversed.js b/test/test.to_reversed.js deleted file mode 100644 index a82ad13..0000000 --- a/test/test.to_reversed.js +++ /dev/null @@ -1,119 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, '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( isFunction( Float16Array.prototype.toReversed ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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 floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - 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 buf; - var out; - - arr = new Float16Array( [ 1.05, 2.05, 3.05, 4.05, 5.05 ] ); - expected = new Uint16Array([ - toWord( 5.05 ), - toWord( 4.05 ), - toWord( 3.05 ), - toWord( 2.05 ), - toWord( 1.05 ) - ]); - out = arr.toReversed(); - buf = new Uint16Array( out.buffer ); - - t.strictEqual( instanceOf( out, Float16Array ), true, 'returns expected value' ); - t.notEqual( out, arr, 'returns a new instance' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 10 ); - out = arr.toReversed(); - - t.strictEqual( out.length, 10, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.to_sorted.js b/test/test.to_sorted.js deleted file mode 100644 index 77508b5..0000000 --- a/test/test.to_sorted.js +++ /dev/null @@ -1,169 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var instanceOf = require( '@stdlib/assert-instance-of' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Comparison function. -* -* @private -* @param {boolean} a - first value for comparison -* @param {boolean} b - second value for comparison -* @returns {number} comparison result -*/ -function compareFcn( a, b ) { - if ( a < b ) { - return -1; - } - if ( a > b ) { - return 1; - } - return 0; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `toSorted` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.toSorted ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.toSorted.call( value, compareFcn ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - {}, - [] - ]; - 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.toSorted( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty floating-point number array', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 0 ); - out = arr.toSorted( compareFcn ); - - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a new typed array containing elements in sorted order', function test( t ) { - var expected; - var arr; - var out; - var buf; - - arr = new Float16Array( [ 4.05, 3.05, 1.05, 5.05, 2.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 2.05 ), - toWord( 3.05 ), - toWord( 4.05 ), - toWord( 5.05 ) - ]); - out = arr.toSorted( compareFcn ); - buf = new Uint16Array( out.buffer ); - - t.strictEqual( instanceOf( out, Float16Array ), true, 'returns expected value' ); - t.notEqual( out, arr, 'returns a new instance' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Float16Array( [ 4.05, 3.05, 1.05, 5.05, 2.05 ] ); - out = arr.toSorted( compareFcn ); - - t.strictEqual( out.length, arr.length, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.to_string.js b/test/test.to_string.js deleted file mode 100644 index a2bb9e3..0000000 --- a/test/test.to_string.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `toString` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.toString ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with an invalid `this` context', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 5 ); - - values = [ - null, - void 0 - ]; - 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.toString.call( value ); - }; - } -}); - -tape( 'the method returns an empty string if invoked on an empty array', function test( t ) { - var str; - var arr; - - arr = new Float16Array( 0 ); - str = arr.toString(); - - t.strictEqual( str, '', 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a string representation of a floating-point number array', function test( t ) { - var expected; - var str; - var arr; - - arr = new Float16Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - expected = '1,2,3,4'; - - str = arr.toString(); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); diff --git a/test/test.values.js b/test/test.values.js deleted file mode 100644 index 225b3fe..0000000 --- a/test/test.values.js +++ /dev/null @@ -1,147 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var float64ToFloat16 = require( '@stdlib/number-float64-base-to-float16' ); -var isNumber = require( '@stdlib/assert-is-number' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `values` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.values ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.values.call( value ); - }; - } -}); - -tape( 'the method returns an iterator protocol-compliant object', function test( t ) { - var expected; - var arr; - var it; - var i; - var r; - var e; - - arr = new Float16Array( [ 1.05, 2.05 ] ); - expected = [ - { - 'value': float64ToFloat16( 1.05 ), - 'done': false - }, - { - 'value': float64ToFloat16( 2.05 ), - 'done': false - }, - { - 'done': true - } - ]; - it = arr.values(); - - t.strictEqual( typeof it, 'object', 'returns expected value' ); - t.strictEqual( typeof it.next, 'function', 'has next method' ); - - for ( i = 0; i < expected.length; i++ ) { - r = it.next(); - e = expected[ i ]; - if ( e.value === void 0 ) { - t.strictEqual( r.value, e.value, 'returns expected value' ); - t.strictEqual( r.done, e.done, 'returns expected value' ); - } else { - t.strictEqual( isNumber( r.value ), true, 'returns expected value' ); - t.strictEqual( r.value, e.value, 'returns expected value' ); - t.strictEqual( r.done, e.done, 'returns expected value' ); - } - } - - t.end(); -}); - -tape( 'the method returns an iterator which does not iterate over empty arrays', function test( t ) { - var expected; - var arr; - var it; - var i; - var v; - - arr = new Float16Array( [] ); - expected = [ - { - 'done': true - }, - { - 'done': true - }, - { - 'done': true - } - ]; - it = arr.values(); - - t.strictEqual( typeof it, 'object', 'returns expected value' ); - t.strictEqual( typeof it.next, 'function', 'has next method' ); - - for ( i = 0; i < expected.length; i++ ) { - v = it.next(); - t.strictEqual( v.value, expected[ i ].value, 'returns expected value' ); - t.strictEqual( v.done, expected[ i ].done, 'returns expected value' ); - } - t.end(); -}); diff --git a/test/test.with.js b/test/test.with.js deleted file mode 100644 index de134c8..0000000 --- a/test/test.with.js +++ /dev/null @@ -1,151 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2026 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 isFunction = require( '@stdlib/assert-is-function' ); -var toWord = require( '@stdlib/number-float16-base-to-word' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Float16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `with` method', function test( t ) { - t.strictEqual( isFunction( Float16Array.prototype.with ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a floating-point number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 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.with.call( value, 0, true ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not in bounds', function test( t ) { - var values; - var arr; - var i; - - arr = new Float16Array( 10 ); - - values = [ - -11, - -12, - 11, - 12 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.with( value, 1.0 ); - }; - } -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Float16Array( 10 ); - out = arr.with( 5, 1.0 ); - - t.strictEqual( out.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a new floating-point number array with the element at a provided index replaced with a provided value', function test( t ) { - var expected; - var arr; - var buf; - var out; - - arr = new Float16Array( [ 1.05, 1.05, 1.05, 1.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 1.05 ), - toWord( 1.05 ), - toWord( 2.05 ) - ]); - out = arr.with( 3, 2.05 ); - buf = new Uint16Array( out.buffer ); - - t.strictEqual( out instanceof Float16Array, true, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.notEqual( out, arr, 'returns new instance' ); - t.end(); -}); - -tape( 'the method supports negative indices', function test( t ) { - var expected; - var arr; - var buf; - var out; - - arr = new Float16Array( [ 1.05, 1.05, 1.05, 1.05 ] ); - expected = new Uint16Array([ - toWord( 1.05 ), - toWord( 1.05 ), - toWord( 1.05 ), - toWord( 2.05 ) - ]); - out = arr.with( -1, 2.05 ); - buf = new Uint16Array( out.buffer ); - - t.strictEqual( out instanceof Float16Array, true, 'returns expected value' ); - t.deepEqual( buf, expected, 'returns expected value' ); - t.end(); -});